當前位置: 首頁>>代碼示例>>Python>>正文


Python elements.Navbar方法代碼示例

本文整理匯總了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) 
開發者ID:calvinmclean,項目名稱:azhackerz17,代碼行數:22,代碼來源:home.py

示例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 
開發者ID:soasme,項目名稱:hreftoday,代碼行數:18,代碼來源:consts.py

示例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) 
開發者ID:yichengchen,項目名稱:ActivityManager,代碼行數:21,代碼來源:Navigations.py

示例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 
開發者ID:pygame,項目名稱:pygameweb,代碼行數:36,代碼來源:views.py

示例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')) 
開發者ID:lfd,項目名稱:PaStA,代碼行數:6,代碼來源:pasta_web.py

示例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)) 
開發者ID:D4D3VD4V3,項目名稱:srp,代碼行數:6,代碼來源:__init__.py

示例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'),
    ) 
開發者ID:MISP,項目名稱:PyTaxonomies,代碼行數:8,代碼來源:__init__.py

示例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'),
    ) 
開發者ID:yichengchen,項目名稱:ActivityManager,代碼行數:11,代碼來源:Navigations.py

示例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')) 
開發者ID:themadhatterz,項目名稱:cpapi,代碼行數:11,代碼來源:views.py

示例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) 
開發者ID:avalentino,項目名稱:slim,代碼行數:56,代碼來源:nav.py


注:本文中的flask_nav.elements.Navbar方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。