<commit_before># -*- coding: utf-8 -*-

"""
byceps.blueprints.core.views
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2014 <NAME>
"""

from importlib import import_module

from flask import current_app, render_template

from ... import config
from ...config import SiteMode
from ...util.framework import create_blueprint


navigation_modules = {
    mode: import_module('config.navigation_{}'.format(mode.name))
    for mode in SiteMode}


blueprint = create_blueprint('core', __name__)


@blueprint.app_errorhandler(403)
def forbidden(error):
    return render_template('error/forbidden.html'), 403


@blueprint.app_errorhandler(404)
def not_found(error):
    return render_template('error/not_found.html'), 404


@blueprint.app_context_processor
def inject_navigation():
    navigation_module = navigation_modules[config.get_site_mode()]
    return {
        'navigation_blocks': navigation_module.get_blocks(),
    }


@blueprint.app_template_global()
def add_page_arg(args, page):<commit_msg>Revised navigation blocks loading.<commit_after># -*- coding: utf-8 -*-

"""
byceps.blueprints.core.views
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2014 <NAME>
"""

from importlib import import_module

from flask import current_app, render_template

from ... import config
from ...config import SiteMode
from ...util.framework import create_blueprint


blueprint = create_blueprint('core', __name__)


def _get_navigation_blocks(site_mode):
    """Import navigation module for the given mode and return the blocks."""
    module_name = 'config.navigation_{}'.format(site_mode.name)
    module = import_module(module_name)
    return module.get_blocks()


NAVIGATION_BLOCKS_BY_SITE_MODE \
    = {mode: _get_navigation_blocks(mode) for mode in SiteMode}


@blueprint.app_errorhandler(403)
def forbidden(error):
    return render_template('error/forbidden.html'), 403


@blueprint.app_errorhandler(404)
def not_found(error):
    return render_template('error/not_found.html'), 404


@blueprint.app_context_processor
def inject_navigation():
    navigation_blocks = NAVIGATION_BLOCKS_BY_SITE_MODE[config.get_site_mode()]
    return {
        'navigation_blocks': navigation_blocks,
    }


@blueprint.app_template_global()
def add_page_arg(args, page):
{'fraction_non_alphanumeric': 0.1332741003998223, 'fraction_numerical': 0.018658374055975122, 'mean_word_length': 5.325842696629214, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '3817560', 'n_tokens_mistral': 727, 'n_tokens_neox': 676, 'n_words': 143}