# Path: chanjo_report/server/config.py
# class DefaultConfig(BaseConfig):
# 
#     """Default config values during development."""
# 
#     DEBUG = True
#     ACCEPT_LANGUAGES = {'en': 'English', 'sv': 'Svenska'}
# 
# Path: chanjo_report/server/extensions.py

# 
# Path: chanjo_report/server/utils.py
# def pretty_date(date, default=None):
#     """Return string representing "time since": 3 days ago, 5 hours ago.
# 
#     Ref: https://bitbucket.org/danjac/newsmeme/src/a281babb9ca3/newsmeme/
#     """
#     if default is None:
#         default = 'just now'
# 
#     now = datetime.utcnow()
#     diff = now - date
# 
#     periods = ((diff.days / 365, 'year', 'years'),
#                (diff.days / 30, 'month', 'months'),
#                (diff.days / 7, 'week', 'weeks'),
#                (diff.days, 'day', 'days'),
#                (diff.seconds / 3600, 'hour', 'hours'),
#                (diff.seconds / 60, 'minute', 'minutes'),
#                (diff.seconds, 'second', 'seconds'))
# 
#     for period, singular, plural in periods:
#         if not period:
#             continue
#         if period == 1:
#             return "%d %s ago" % (period, singular)
#         else:
#             return "%d %s ago" % (period, plural)
#     return default
# 
# Path: chanjo_report/server/constants.py
# LEVELS = OrderedDict([
#     (10, 'completeness_10'),
#     (15, 'completeness_15'),
#     (20, 'completeness_20'),
#     (50, 'completeness_50'),
#     (100, 'completeness_100'),
# ])


from flask import current_app, Flask, request
from flask_babel import Babel
from .config import DefaultConfig
from .extensions import api
from .utils import pretty_date
from .constants import LEVELS
        """Determine locale to use for translations."""
        accept_languages = current_app.config.get('ACCEPT_LANGUAGES')

        # first check request args
        session_language = request.args.get('lang')
        if session_language in accept_languages:
            return session_language

        # language can be forced in config
        user_language = current_app.config.get('CHANJO_LANGUAGE')
        if user_language:
            return user_language

        # try to guess the language from the user accept header that
        # the browser transmits.  We support de/fr/en in this example.
        # The best match wins.
        return request.accept_languages.best_match(accept_languages)


def configure_blueprints(app):
    """Configure blueprints in views."""
    for blueprint in app.config.get('BLUEPRINTS', []):
        app.register_blueprint(blueprint)


def configure_template_filters(app):
    """Configure custom Jinja2 template filters."""

    @app.context_processor
    def inject_levels():

# Path: chanjo_report/server/config.py
# class DefaultConfig(BaseConfig):
# 
#     """Default config values during development."""
# 
#     DEBUG = True
#     ACCEPT_LANGUAGES = {'en': 'English', 'sv': 'Svenska'}
# 
# Path: chanjo_report/server/extensions.py

# 
# Path: chanjo_report/server/utils.py
# def pretty_date(date, default=None):
#     """Return string representing "time since": 3 days ago, 5 hours ago.
# 
#     Ref: https://bitbucket.org/danjac/newsmeme/src/a281babb9ca3/newsmeme/
#     """
#     if default is None:
#         default = 'just now'
# 
#     now = datetime.utcnow()
#     diff = now - date
# 
#     periods = ((diff.days / 365, 'year', 'years'),
#                (diff.days / 30, 'month', 'months'),
#                (diff.days / 7, 'week', 'weeks'),
#                (diff.days, 'day', 'days'),
#                (diff.seconds / 3600, 'hour', 'hours'),
#                (diff.seconds / 60, 'minute', 'minutes'),
#                (diff.seconds, 'second', 'seconds'))
# 
#     for period, singular, plural in periods:
#         if not period:
#             continue
#         if period == 1:
#             return "%d %s ago" % (period, singular)
#         else:
#             return "%d %s ago" % (period, plural)
#     return default
# 
# Path: chanjo_report/server/constants.py
# LEVELS = OrderedDict([
#     (10, 'completeness_10'),
#     (15, 'completeness_15'),
#     (20, 'completeness_20'),
#     (50, 'completeness_50'),
#     (100, 'completeness_100'),
# ])


# Path: chanjo_report/server/app.py
from flask import current_app, Flask, request
from flask_babel import Babel
from .config import DefaultConfig
from .extensions import api
from .utils import pretty_date
from .constants import LEVELS

        """Determine locale to use for translations."""
        accept_languages = current_app.config.get('ACCEPT_LANGUAGES')

        # first check request args
        session_language = request.args.get('lang')
        if session_language in accept_languages:
            return session_language

        # language can be forced in config
        user_language = current_app.config.get('CHANJO_LANGUAGE')
        if user_language:
            return user_language

        # try to guess the language from the user accept header that
        # the browser transmits.  We support de/fr/en in this example.
        # The best match wins.
        return request.accept_languages.best_match(accept_languages)


def configure_blueprints(app):
    """Configure blueprints in views."""
    for blueprint in app.config.get('BLUEPRINTS', []):
        app.register_blueprint(blueprint)


def configure_template_filters(app):
    """Configure custom Jinja2 template filters."""

    @app.context_processor
    def inject_levels():

        return dict(levels=LEVELS)