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
def meunavbar(): if not session.get('autenticado'): menu = Navbar('Eleições') menu.items = [View('Login', 'autenticar')] elif session.get('adm'): menu = Navbar('Eleições - ADM') menu.items = [ View('Home', 'inicio'), View('Votar', 'votar'), View('Resultados', 'resultados') ] menu.items.append( Subgroup('Cadastrar', View('Eleitores', 'inserir'), View('Pessoas', 'inserir_pessoa'))) menu.items.append( Subgroup('Criar', View('Eleição', 'criar_eleicao'), View('Questão', 'set_eleicao_questao'), View('Alternativa', 'set_q_a'))) menu.items.append( Subgroup('Regular estado', View('Abrir eleição', 'abrir'), View('Encerrar eleição', 'encerrar'))) menu.items.append(View('Apuração', 'apuracao')) menu.items.append(Link('Logout', 'logout')) elif session.get('autenticado') and not session.get('adm'): menu = Navbar('Eleições - Eleitor') menu.items = [ View('Home', 'inicio'), View('Votar', 'votar'), View('Resultados', 'resultados') ] menu.items.append(Link('Logout', 'logout')) return menu
def ctxbar(): bar = [] if not is_authenticated(): bar.append(View('Login', 'login')) else: uname = session['uname'] links = [] wx = workspaces(uname) if wx: for w in wx: w = w['wsname'] links.append(Link(w, f'/{w}')) bar.append(Subgroup('Workspaces', *links)) if 'wsname' in session: links = [] wsname = session['wsname'] cx = channels(uname, wsname) for c in cx: c = c['chname'] links.append(Link(c, f'/{wsname}/{c}')) bar.append(Subgroup(wsname, *links)) bar.append(Subgroup(uname, View('Logout', 'logout'))) return Navbar(current_app.config.get('SITE_NAME'), *bar)
def mynavbar(): if current_user.is_anonymous: usergroup = Subgroup( "User", Text("Not logged in"), View('Forgot password', 'security.forgot_password'), ) else: usergroup = Subgroup( "User", Text(current_user.email), View('Change password', 'security.change_password'), Separator, View('Logout', 'security.logout') ) return Navbar( View('nashi', 'index'), Subgroup( 'Links', Link('Philosophie Uni Würzburg', 'https://www.philosophie.' + 'uni-wuerzburg.de/forschung/forschungsstellephilosophie-un/'), Link('AL-Corpus', 'http://arabic-latin-corpus.philosophie.' + 'uni-wuerzburg.de/'), Link('nashi on Github', 'https://github.com/andbue/nashi'), ), usergroup )
def createFuzzjobLinks(): fuzzjobLinks = [ Link('Overview', '/projects'), Separator(), Link('Create Fuzzjob', '/projects/createProject'), Separator() ] return createFuzzjobsNav(fuzzjobLinks)
def createLocationsLinks(): locationsLinks = [ Link('Overview', '/locations'), Separator(), Link('Create Location', '/locations/createLocation'), Separator() ] return createLocationsNav(locationsLinks)
def database_navbar(): return Navbar( '', View('Database', 'database.database'), Link('Collections', '#'), Link('History', '#'), Link('Statistics', '#'), View('Settings', 'database.settings'), )
def main_navbar(): return TopNavbar( 'ABCD', View('Home', 'index.index'), View('API', 'api.index'), View('Databases', 'database.database', database_name='default'), Link('Docs', 'https://libatoms.github.io/abcd/'), Link('Github', 'https://github.com/libatoms/abcd'), )
def mynavbar(): return Navbar( "Flasked Altair Demo", View("Home", "index"), View("Cars charts", "show_cars"), View("Electricity charts", "show_electricity"), Subgroup( "References", Link("Altair", "https://altair-viz.github.io/index.html"), Link("Vega-Lite", "https://vega.github.io/vega-lite/"), Link("D3", "http://d3js.org/"), Link("Flask", "http://flask.pocoo.org/"), ), )
def mynavbar(): return Navbar( 'Sample App', View('Standard', 'index'), View('Alternative', 'alternative'), Subgroup( 'Products', View('Standard SG1', 'index'), Separator(), View('Alternative SG1', 'alternative'), Link('Github', '//github.com/hfilimonescu/flask-bs4/'), ), Link('Github', '//github.com/hfilimonescu/flask-bs4/'), )
def process_navbar(): # get images here lockimage = img(src='static/img/lock.png', height='20', width='20') unlockimage = img(src='static/img/unlock.png', height='20', width='20') separator = img(src='static/img/separate.png', height='25', width='10') # Find all the samples in the data directory dir_list = [] if current_user.is_authenticated: current_app.config['DATA_DIR'] = current_app.config['ALL_DATA_DIR'] else: current_app.config['DATA_DIR'] = current_app.config[ 'PUBLISHED_DATA_DIR'] dir_list = next(walk(current_app.config['DATA_DIR'] + "/ensembles"))[1] published_dir_list = next( walk(current_app.config['PUBLISHED_DATA_DIR'] + "/ensembles"))[1] dir_list_links = [] first = True for x in dir_list: if not first: dir_list_links.append(Text(separator)) dir_list_links.append(Link(x, "/" + x)) if current_user.is_authenticated: # x is public: add unlockimage if x in published_dir_list: dir_list_links.append(Text(unlockimage)) # x is private: add lockimage else: dir_list_links.append(Text(lockimage)) first = False nav.register_element('frontend_top', Navbar('', *dir_list_links))
def createLocationsNav(listLinks): locations = db.session.query(models.Locations).distinct(models.Locations.Name) for location in locations: listLinks.append(Link(location.Name, '/locations/view/' + str(location.id))) return listLinks
def mynavbar(): return Navbar( Link('CILO', '/'), View('DataFrame Grid', 'frontend.grid'), View('Computational Graph', 'frontend.graph'), View('Plots', 'frontend.plots'), )
def createFuzzjobsNav(listLinks): projects = models.Fuzzjob.query.all() for project in projects: listLinks.append(Link(project.name[:15], '/projects/view/%d' % project.id)) return listLinks
def get_authors(): r = requests.get(api_baseurl + "/users") authors_list = ['Auteurs'] for item in r.json(): author_name = item['first_name'] + " " + item['last_name'] print(author_name) authors_list.append(Link(author_name, "/author/" + str(author_name))) return authors_list
def build_nav(): user = g.user elements = [ View('Home', 'frontend.home'), View('Projects', 'frontend.info') ] if user is None: link = Link('Login', '/login') else: elements.append(View('Manage Users', 'users.users_view')) name = fullname(user) elements.append(Link(name, '/user/%d' % user['id'])) link = Link('Logout', '/logout') elements.append(link) return Navbar(*elements)
def meunavbar(): menu = Navbar('Minha aplicação') menu.items = [View('Home', 'inicio'), View('Registro', 'cadastro')] menu.items.append( Subgroup('Menu de opções', View('Aluno', 'aluno'), View('Professor', 'professor'))) menu.items.append(View('Login', 'autenticar')) menu.items.append(Link('Ajuda', 'https://www.google.com')) return menu
def mynavbar(): nav = [ 'SREServer', Link('Home', '/'), View('Hub', 'hub'), ] for plugin in app.config['PLUGINS_REGISTRY'].itervalues(): if 'navbar' in plugin: nav += plugin['navbar'] return Navbar(*nav)
def createFuzzjobsNav(listLinks): projects = [] try: projects = models.Fuzzjob.query.all() for project in projects: listLinks.append(Link(project.name[:15], '/projects/view/%d' % project.ID)) except Exception as e: print("Please check your database connection and make sure the hostname db.fluffi is available with user fluffi_gm. " + str(e)) return listLinks
def createLocationsNav(listLinks): locations = [] try: locations = db.session.query(models.Locations).distinct(models.Locations.Name) for location in locations: listLinks.append(Link(location.Name, '/locations/view/' + str(location.ID))) except Exception as e: print("Please check your database connection and make sure the hostname db.fluffi is available with user fluffi_gm. " + str(e)) return listLinks
def mynavbar(): """ Create the navbar. """ return Navbar( 'Employee Insights', View('Home', 'views.index'), View('Age', 'views.age'), View('Location', 'views.location'), View('Job Title', 'views.job_title'), Subgroup( 'Data', View('Import', 'views.import_'), Link('Export', '/export'), ))
def navbar(): if current_user.is_active(): if excomm_permission.can(): return Navbar(Link("Members@Calaphio", "/"), Link("My Profile: " + current_user.fullname, "/"), View("News", "core.NewsView:index"), View("Calendar", "core.EventsView:index"), View("Post News", "core.NewsView:create"), View("Logout", "core.UsersView:logout")) else: return Navbar(Link("Members@Calaphio", "/"), Link("My Profile: " + current_user.fullname, "/"), View("News", "core.NewsView:index"), View("Calendar", "core.EventsView:index"), View("Logout", "core.UsersView:logout")) else: return Navbar( Link("Members@Calaphio", "/"), View("News", "core.NewsView:index"), Tag(tags.a, "Login", href="#", data_toggle="modal", data_target="#loginModal"))
def menunav(): menu = Navbar('BankQA System') if session.get('logged_in'): menu.items = [ View('Home', 'home'), View('Minhas Disciplinas', 'disciplinas'), View('Minhas Provas', 'home'), View('Gera Provas', 'selecionadisciplina'), View('Sair', 'sair') ] menu.items.append(Link('Ajuda', 'https://www.google.com')) else: menu.items = [ View('Login', 'autenticar'), View('Cadastrar', 'cadastra') ] return menu
def homenavbar(): return Navbar( 'Story Tracker', View('Flask-Bootstrap', 'storys.index'), View('Home', 'storys.index'), View('Register', 'users.register'), View('Login', 'users.login'), # View('Forms Example', '.example_form'), # View('Debug-Info', 'debug.debug_root'), Subgroup( 'Docs', Link('Flask-Bootstrap', 'http://pythonhosted.org/Flask-Bootstrap'), Link('Flask-AppConfig', 'https://github.com/mbr/flask-appconfig'), Link('Flask-Debug', 'https://github.com/mbr/flask-debug'), Separator(), Text('Bootstrap'), Link('Getting started', 'http://getbootstrap.com/getting-started/'), Link('CSS', 'http://getbootstrap.com/css/'), Link('Components', 'http://getbootstrap.com/components/'), Link('Javascript', 'http://getbootstrap.com/javascript/'), Link('Customize', 'http://getbootstrap.com/customize/'), ), Text('Using Flask-Bootstrap {}'.format(FLASK_BOOTSTRAP_VERSION)), )
def top_nav(): return Navbar( View('Flask-Bootstrap', '.index'), View('Home', '.index'), View('Logout', '.logout') if session.get('logged_in') else View( 'Login', '.form_login'), View('Artikel', '.artikel'), Subgroup( 'Docs', Link('Flask-Bootstrap', 'http://pythonhosted.org/Flask-Bootstrap'), Link('Flask-AppConfig', 'https://github.com/mbr/flask-appconfig'), Link('Flask-Debug', 'https://github.com/mbr/flask-debug'), Separator(), Text('Bootstrap'), Link('Getting started', 'http://getbootstrap.com/getting-started/'), Link('CSS', 'http://getbootstrap.com/css/'), Link('Components', 'http://getbootstrap.com/components/'), Link('Javascript', 'http://getbootstrap.com/javascript/'), Link('Customize', 'http://getbootstrap.com/customize/'), ), # Text('Using Flask-Bootstrap {}'.format(FLASK_BOOTSTRAP_VERSION)), )
def frontend_top(): # Sample navbar with left and right align # TODO: Adapt to dnd map and incorporate dynamic logged in/out nav items return ExtendedNavbar( title=View('Flask-Bootstrap', 'frontend.index'), root_class='navbar navbar-inverse', items=( View('Home', 'frontend.index'), View('Debug-Info', 'frontend.index'), Subgroup( 'Docs', Link( 'Flask-Bootstrap', 'http://pythonhosted.org/Flask-Bootstrap', ), Link( 'Flask-AppConfig', 'https://github.com/mbr/flask-appconfig' ), Link('Flask-Debug', 'https://github.com/mbr/flask-debug'), Separator(), Text('Bootstrap'), Link( 'Getting started', 'http://getbootstrap.com/getting-started/', ), Link('CSS', 'http://getbootstrap.com/css/'), Link('Components', 'http://getbootstrap.com/components/'), Link('Javascript', 'http://getbootstrap.com/javascript/'), Link('Customize', 'http://getbootstrap.com/customize/'), ), ), right_items=( Text('Using Flask-Bootstrap {}'.format(FLASK_BOOTSTRAP_VERSION)), View('SignUp', 'frontend.index'), ), )
frontend = Blueprint('frontend', __name__) # We're adding a navbar as well through flask-navbar. In our example, the # navbar has an usual amount of Link-Elements, more commonly you will have a # lot more View instances. nav.register_element( 'frontend_top', Navbar( View('PyLoggi', '.index'), View('Home', '.index'), View('Forms Example', '.example_form'), View('Debug-Info', 'debug.debug_root'), View('About', '.about'), Subgroup( 'Docs', Link('About', '/about'), Link('Flask-AppConfig', 'https://github.com/mbr/flask-appconfig'), Link('Flask-Debug', 'https://github.com/mbr/flask-debug'), Separator(), Text('Bootstrap'), Link('Getting started', 'http://getbootstrap.com/getting-started/'), Link('CSS', 'http://getbootstrap.com/css/'), Link('Components', 'http://getbootstrap.com/components/'), Link('Javascript', 'http://getbootstrap.com/javascript/'), Link('Customize', 'http://getbootstrap.com/customize/'), ), Text('Using Flask-Bootstrap {}'.format(FLASK_BOOTSTRAP_VERSION)), ))
""" Register the top menu for the frontend. """ from flask_nav import Nav from flask_nav.elements import (Navbar, View, Link) nav = Nav() nav.register_element( 'frontend_top', Navbar( View('Home', 'frontend_blueprint.index'), View('Processors', 'processors_blueprint.processors'), View('Workflows', 'workflows_blueprint.workflows'), View('Tasks', 'tasks_blueprint.tasks'), View('Compare', 'compare_blueprint.compare'), Link('API', dest='/api'), Link('Queue Backend', dest='/flower/'), ))
# firebase = Firebase(config) nav.register_element( 'my_navbar', Navbar( 'thenav', Text('HazzahPlay'), Separator(), View('Home', 'index'), Separator(), View('Item One', 'item', item=1), Separator(), View('Item two', 'item', item=2), Separator(), Link('Google Classroom', 'https://www.google.com'), )) @app.route('/', methods=['GET', 'POST']) def index(): uname = '' psw = '' # auth = firebase.auth() user = '' if (request.method == "POST"): if request.form['action'] == "login": uname = request.form['uname']
from flask_nav.elements import Navbar, View, Subgroup, Link, Text, Separator from flask_bootstrap import __version__ as FLASK_BOOTSTRAP_VERSION # To keep things clean, we keep our Flask-Nav instance in here. We will define # frontend-specific navbars in the respective frontend, but it is also possible # to put share navigational items in here. nav = Nav() # Menu / navbar nav.register_element( 'frontend_top', Navbar( View('Home', 'frontend.index'), Link('GitHub', 'https://github.com'), Subgroup( 'Tropo', Link('My Tropo Apps', 'https://www.tropo.com/applications'), Link('My Tropo Logs', 'https://www.tropo.com/mylogs'), Link('Python Module', 'https://github.com/cisco-sre/ciscotropowebapi'), Link( 'SparkLog4Tropo', 'https://gist.github.com/ObjectIsAdvantag/b73db0cffcedb1152a2d6669cb3d27b0' ), Link('WebAPI Docs', 'https://www.tropo.com/docs/webapi'), Link('Forums', 'https://support.tropo.com/hc/en-us/community/topics'), Link('IRC Chat', 'https://www.tropo.com/help/irc-chat/'), Link('Coding Tips', 'https://www.tropo.com/docs/coding-tips'),