本文整理汇总了Python中flask_nav.elements.Navbar方法的典型用法代码示例。如果您正苦于以下问题:Python elements.Navbar方法的具体用法?Python elements.Navbar怎么用?Python elements.Navbar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类flask_nav.elements
的用法示例。
在下文中一共展示了elements.Navbar方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: navbar
# 需要导入模块: from flask_nav import elements [as 别名]
# 或者: from flask_nav.elements import Navbar [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 Navbar [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 Navbar [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 Navbar [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: mynavbar
# 需要导入模块: from flask_nav import elements [as 别名]
# 或者: from flask_nav.elements import Navbar [as 别名]
def mynavbar():
return Navbar('PaStA shiny webfrontend',
View('Home', 'home'),
View('Mbox', 'mbox'))
示例6: bar
# 需要导入模块: from flask_nav import elements [as 别名]
# 或者: from flask_nav.elements import Navbar [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))
示例7: mynavbar
# 需要导入模块: from flask_nav import elements [as 别名]
# 或者: from flask_nav.elements import Navbar [as 别名]
def mynavbar():
return Navbar(
'MISP taxonomies viewer and editor',
View('Taxonomies', 'taxonomies'),
View('Search', 'search'),
)
示例8: nav_bar_admin
# 需要导入模块: from flask_nav import elements [as 别名]
# 或者: from flask_nav.elements import Navbar [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'),
)
示例9: mynavbar
# 需要导入模块: from flask_nav import elements [as 别名]
# 或者: from flask_nav.elements import Navbar [as 别名]
def mynavbar():
return Navbar(
'cpapi',
View('Custom', 'custom'),
View('Add Object', 'addobject'),
View('Import Objects', 'importobj'),
View('Show Rules', 'showrules'),
View('Run Command', 'runcommand'),
View('Logout', 'logout'))
示例10: topnavbar
# 需要导入模块: from flask_nav import elements [as 别名]
# 或者: from flask_nav.elements import Navbar [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)