<commit_before>from pyramid_layout.panel import panel_config
from pyramid.security import authenticated_userid, has_permission
from pyramid.httpexceptions import HTTPException, HTTPFound, HTTPNotFound

from deform import Form, ValidationFailure
from phoenix import models

import logging
logger = logging.getLogger(__name__)

# navbar
# ------
@panel_config(name='navbar', renderer='phoenix:templates/panels/navbar.pt')
def navbar(context, request):
    def nav_item(name, url, icon=None):
        active = request.current_route_url() == url
        return dict(name=name, url=url, active=active, icon=icon)

    items = []
    if has_permission('edit', request.context, request):
        items.append( nav_item('Processes', request.route_path('processes_overview')) )
    if has_permission('submit', request.context, request):
        items.append( nav_item('My Jobs', request.route_path('myjobs_overview')) )
        items.append( nav_item('Wizard', request.route_path('wizard')) )
    items.append( nav_item('Help', request.route_url('readthedocs')) )
    
    subitems = []
    if has_permission('edit', request.context, request):
        subitems.append( nav_item('Profile', request.route_path('profile', tab='account'), icon="glyphicon-user") )
        subitems.append( nav_item('Dashboard', request.route_path('dashboard', tab='jobs'), icon='glyphicon-dashboard') )
    if has_permission('admin', request.context, request):
        subitems.append( nav_item('Settings', request.route_path('settings'), icon="glyphicon-cog") )
    
    login = request.current_route_url() == request.route_url('account_login', protocol='esgf')

    return dict(title='Phoenix', items=items, subitems=subitems, username=authenticated_userid(request), login=login)

@panel_config(name='breadcrumbs', renderer='phoenix:templates/panels/breadcrumbs.pt')
def breadcrumbs(context, request):
    lm = request.layout_manager
    return dict(breadcrumbs=lm.layout.breadcrumbs)<commit_msg>fixed navbar active<commit_after>from pyramid_layout.panel import panel_config
from pyramid.security import authenticated_userid, has_permission
from pyramid.httpexceptions import HTTPException, HTTPFound, HTTPNotFound

from deform import Form, ValidationFailure
from phoenix import models

import logging
logger = logging.getLogger(__name__)

# navbar
# ------
@panel_config(name='navbar', renderer='phoenix:templates/panels/navbar.pt')
def navbar(context, request):
    def nav_item(name, url, icon=None):
        active = request.current_route_path() == url
        return dict(name=name, url=url, active=active, icon=icon)

    items = []
    if has_permission('edit', request.context, request):
        items.append( nav_item('Processes', request.route_path('processes_overview')) )
    if has_permission('submit', request.context, request):
        items.append( nav_item('My Jobs', request.route_path('myjobs_overview')) )
        items.append( nav_item('Wizard', request.route_path('wizard')) )
    items.append( nav_item('Help', request.route_url('readthedocs')) )
    
    subitems = []
    if has_permission('edit', request.context, request):
        subitems.append( nav_item('Profile', request.route_path('profile', tab='account'), icon="glyphicon-user") )
        subitems.append( nav_item('Dashboard', request.route_path('dashboard', tab='jobs'), icon='glyphicon-dashboard') )
    if has_permission('admin', request.context, request):
        subitems.append( nav_item('Settings', request.route_path('settings'), icon="glyphicon-cog") )
    
    login = request.current_route_url() == request.route_url('account_login', protocol='esgf')

    return dict(title='Phoenix', items=items, subitems=subitems, username=authenticated_userid(request), login=login)

@panel_config(name='breadcrumbs', renderer='phoenix:templates/panels/breadcrumbs.pt')
def breadcrumbs(context, request):
    lm = request.layout_manager
    return dict(breadcrumbs=lm.layout.breadcrumbs)
{'fraction_non_alphanumeric': 0.13593710372812579, 'fraction_numerical': 0.0, 'mean_word_length': 5.540630182421228, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1176536', 'n_tokens_mistral': 1196, 'n_tokens_neox': 1160, 'n_words': 221}