# 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
# -*- coding: utf-8 -*-



def create_app(config=None):
    """Create a Flask app (Flask Application Factory)."""
    app = Flask(__name__, instance_relative_config=True)
    configure_app(app, config=config)
    configure_extensions(app)
    configure_blueprints(app)
    configure_template_filters(app)

    return app


def configure_app(app, config=None, config_file=None):
    """Configure app in different ways."""
    # http://flask.pocoo.org/docs/api/#configuration
    app.config.from_object(DefaultConfig)
    if config:
        app.config.from_object(config)


def configure_extensions(app):
    """Initialize Flask extensions."""

# 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

# -*- coding: utf-8 -*-



def create_app(config=None):
    """Create a Flask app (Flask Application Factory)."""
    app = Flask(__name__, instance_relative_config=True)
    configure_app(app, config=config)
    configure_extensions(app)
    configure_blueprints(app)
    configure_template_filters(app)

    return app


def configure_app(app, config=None, config_file=None):
    """Configure app in different ways."""
    # http://flask.pocoo.org/docs/api/#configuration
    app.config.from_object(DefaultConfig)
    if config:
        app.config.from_object(config)


def configure_extensions(app):
    """Initialize Flask extensions."""

    api.init_app(app)