本文整理匯總了Python中flask_nav.elements.View方法的典型用法代碼示例。如果您正苦於以下問題:Python elements.View方法的具體用法?Python elements.View怎麽用?Python elements.View使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類flask_nav.elements
的用法示例。
在下文中一共展示了elements.View方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: navbar
# 需要導入模塊: from flask_nav import elements [as 別名]
# 或者: from flask_nav.elements import View [as 別名]
def navbar():
fb_btn = Text('Logged in to Facebook')
sp_btn = Text('Logged in to Spotify')
signout = Text('')
if not fb_logged_in():
fb_btn = View('Log In To Facebook', 'facebook.facebook_login')
else:
fb_btn = Text('fb: ' + fb_data('')['name'])
if not sp_logged_in():
sp_btn = View('Log In To Spotify', 'spotify.spotify_login')
else:
sp_btn = Text('sp: ' + sp_data('')['email'])
if fb_logged_in() or sp_logged_in():
signout = View('Logout', '.logout')
return Navbar('Spotiflyt',
View('Home', '.index'),
fb_btn, sp_btn, signout)
示例2: get_navbar
# 需要導入模塊: from flask_nav import elements [as 別名]
# 或者: from flask_nav.elements import View [as 別名]
def get_navbar():
navbar = Navbar('', *[
View('Href Today', 'dashboard.get_links'),
])
navbar.logo = Logo('images/logo.png', 'dashboard.get_links')
if current_user.is_anonymous:
navbar.right_side_items = [View('Login', 'user.login')]
else:
navbar.right_side_items = [
Subgroup(
'Account',
View('Change Password', 'user.change_password'),
View('Logout', 'user.logout'),
)
]
return navbar
示例3: nav_bar
# 需要導入模塊: from flask_nav import elements [as 別名]
# 或者: from flask_nav.elements import View [as 別名]
def nav_bar():
nav.renderer()
act_name = request.base_url.split('/')[-2]
act = Activities.query.filter_by(activity_name=act_name).first()
items = [View('??', 'index')]
if is_authenticated(act_name):
items.append(View('????', 'register_success', activity=act_name))
if act.upload_enable:
items.append(View('????', 'upload', activity=act_name))
items.append(View('??', 'logout', activity=act_name))
else:
if act.reg_enable:
items.append(View('??', 'reg', activity=act_name))
if act.upload_enable:
items.append(View('??/??', 'login', activity=act_name))
else:
items.append(View('????', 'login', activity=act_name))
return Navbar('?????????', *items)
示例4: make_nav
# 需要導入模塊: from flask_nav import elements [as 別名]
# 或者: from flask_nav.elements import View [as 別名]
def make_nav(session):
""" Creates the navigation using flask-nav.
"""
pages = (session
.query(Page)
.filter(Page.hidden == 0)
.order_by(Page.orders)
.all())
parts = []
groups = {}
for page in pages:
dest = '/' + page.link if page.uri is None else page.uri
# add all pages with the same nav_group into a Subgroup.
if page.nav_group:
if page.nav_group not in groups:
groups[page.nav_group] = Subgroup(page.nav_group)
parts.append(groups[page.nav_group])
groups[page.nav_group].items.append(Link(page.name, dest))
else:
parts.append(Link(page.name, dest))
title = 'pygame'
endpoint = 'news.index'
# in tests, news.index might not exist. So we don't link there if not.
try:
url_for(endpoint)
nav_bar = Navbar(View(title, endpoint))
except (BuildError, RuntimeError):
nav_bar = Navbar(title)
nav_bar.items.extend(parts)
return nav_bar
示例5: bar
# 需要導入模塊: from flask_nav import elements [as 別名]
# 或者: from flask_nav.elements import View [as 別名]
def bar():
if current_user.is_authenticated:
return Navbar(View("Home", "bp.home"), View("Log out", "bp.logout"))
return Navbar(View("Home", "bp.home"), View("Sign Up", "bp.signup"), View("Login", "bp.login", next=request.path))
示例6: nav_bar_admin
# 需要導入模塊: from flask_nav import elements [as 別名]
# 或者: from flask_nav.elements import View [as 別名]
def nav_bar_admin():
act_name = request.args.get('act')
return Navbar(
'???',
View('????', 'admin_home'),
View('????', 'memberlist', act=act_name),
View('????', 'submitlist', act=act_name),
View('??', 'logout_admin'),
)
示例7: topnavbar
# 需要導入模塊: from flask_nav import elements [as 別名]
# 或者: from flask_nav.elements import View [as 別名]
def topnavbar():
# support link
support_email = current_app.config['SLIM_SUPPORT_EMAIL']
support_link = utils.make_support_link(support_email)
# navigation path
server_name = current_app.config['SERVER_NAME']
server_name = server_name if server_name else 'localhost'
url_adapter = current_app.url_map.bind(server_name)
match = partial(url_adapter.match, return_rule=True)
path_views = []
path_parts = request.path.strip(posixpath.sep).split(posixpath.sep)
for idx, item in enumerate(path_parts[:-1], start=1):
label = item.strip(posixpath.sep)
path = posixpath.join('/', *path_parts[:idx])
try:
rule, _ = match(path)
except Exception:
# compatibility with Python < 3.5
del path_views[:]
# path_views.clear()
break
target = rule.endpoint
path_views.append(View('> ' + label.capitalize(), target))
# navbar
app_name = current_app.config.get('SLIM_APPNAME', 'SLiM')
items = [
View(app_name, 'index'),
View('Home', 'index'),
]
if current_user.has_role('admin'):
items.extend([
View('Admin', 'admin.index'),
])
items.extend([
Link('Support', support_link),
View('About', 'about'),
])
if current_user.is_authenticated:
subgroup = Subgroup(
current_user.email,
View('Profile', 'user_profile'),
View('Logout', 'security.logout'),
)
items.append(subgroup)
if path_views:
items[2:2] = path_views
return Navbar(*items)