<commit_before># -*- coding: utf-8 -*-
# Django common settings for oneflow project.
# These are overridden in hostname.py specific files.
#
# Here we define the settings for the test platform.
# Production will override only the needed directives.

import os
import sys
import warnings


from django.core.urlresolvers import reverse_lazy
from django.utils.translation import ugettext_lazy

# dummy ugettext function, as django's docs say
ugettext = lambda s: s

# This is imported here to benefit to all other included snippets.
from sparks import platform # NOQA

MAIN_SERVER = os.environ.get('MAIN_SERVER', None)

if MAIN_SERVER is None:
    raise RuntimeError('MAIN_SERVER setting must be defined '
                       'before common.py inclusion!')

# We need to go down 2 times because the starting point of these settings is
# `project/settings/__init__.py`, instead of good old `project/settings.py`.
# NOTE: the `execfile()` on snippets doesn't add depth: even if the current
# file is `project/settings/snippets/common.py`, this doesn't count.
PROJECT_ROOT = os.path.dirname(os.path.dirname(__file__))
BASE_ROOT    = os.path.dirname(PROJECT_ROOT)

ADMINS   = (('<NAME>', '<EMAIL>'), )
MANAGERS = ADMINS

from oneflow import VERSION

GRAPPELLI_ADMIN_TITLE = u'1flow v%s administration%s' % (VERSION, u' — DEVEL'
                                                         if DEBUG else u'')
MONGOADMIN_OVERRIDE_ADMIN = True

ALLOWED_HOSTS = []
TIME_ZONE     = 'Europe/Paris'
LANGUAGE_CODE = 'en'

# Translation workflows:
# - in the DB: all languages variants are accessible and empty by default.
#      'en' takes precedence on 'en-US'. As translators have access to all
#       translations, this is a bit awkward, but we don't have the choice
#       because we must match the Django application languages. We could
#       manually hide the 'en-us' to avoid confusion, but this would imply
#       dirty hacking in all admin modules and I don't find it worth.
# - in the webapp: 'en' is *always* defined because the developers create
#       english strings. For translators to be able to override them
#       without needing commit access, we use the 'en-us' language, which
#       takes precedence. This is not perfect, because other 'en-*'
#       users will get the 'bare' strings which can have errors, but at
#       least our translators have access to en-US strings the same way
#       they access other languages.
LANGUAGES = (
    ('en', ugettext(u'English')),
    # We're not ready to handle a british translation (no resource…)
    #('en-gb', ugettext(u'English (UK)')),
    ('fr', ugettext(u'Français')),

    # Activate these later when we need them.
    #    ('es', ugettext(u'Español')),
    #    ('fr-CA', ugettext(u'Français (FR)')),
    #    ('es-XX', ugettext(u'Español (ES)')),
)

TRANSMETA_LANGUAGES = LANGUAGES + (
    # The 'nt' fake language is used by translators to keep
    # variants and translations notes handy in the admin interface.
    ('nt', ugettext(u'Notes — variants')),
)

# We use oneflow.base.models.User as a drop-in replacement.
AUTH_USER_MODEL = 'base.User'
SOCIAL_AUTH_USER_MODEL = 'base.User'

USE_I18N = True
USE_L10N = True
USE_TZ   = True

# Activate if bandwidth is limited, at some CPU cost.
#USE_ETAGS = True

MEDIA_ROOT = os.path.join(BASE_ROOT, 'media')
MEDIA_URL  = '/media/'

STATIC_ROOT = os.path.join(BASE_ROOT, 'static')
STATIC_URL  = '/static/'

SECRET_KEY = '1!ps20!7iya1ptgluj@2u50)r!fvl*%+6qbxar2jn9y$@=eme!'

ROOT_URLCONF = 'oneflow.urls'

WSGI_APPLICATION = 'oneflow.wsgi.application'

STATICFILES_DIRS = (
)

STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)

STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage'

#PIPELINE_ENABLED = False

# Until our own modules are ready to be wrapped, don't use this.
PIPELINE_DISABLE_WRAPPER = True

PIPELINE_COMPILERS = (
    'pipeline.compilers.less.LessCompiler',
    # We don't use the from django-pipeline-compass compiler,
    # it breaks bootstrap-responsive.
    #       'pipeline_compass.compiler.CompassCompiler',
    #
    # Intead, we use the one from django-pipeline-compass-rubygem, which
    # runs the official 'compass' Ruby binary in a subshell.
    #
    # WARNING, though: both packages install at the same location.
    # As of 20130524, django-pipeline-compass-rubygem is itself broken,
    # because it doesn't ship the __init__.py. Thus it doesn't work alone;
    # but it doesn't depend on django-pipeline-compass, which makes the
    # whole process heavily error-prone because we need to install both,
    # but it's not issued anywhere.
    #
    # Finally, after installing 2 python packages and Ruby + the rubygem,
    # everything works as expected. I personally prefer using the official
    # 'compass' and have a working CSS, than an un-maintained python erzatz
    # which doesnt work and breaks CSSs without any error displayed.
    'pipeline_compass.compass.CompassCompiler',
    'pipeline.compilers.coffee.CoffeeScriptCompiler',
)

PIPELINE_CSS = {

    # •••••••••••••••••••••••••••••••••••••••••••••••••••••••••• vendor

    # TODO: the 'vendor-all' target.

    'bootstrap': {
        'source_filenames': (
            'vendor/bootstrap/less/bootstrap.less',
        ),
        'output_filename': 'css/bootstrap.css',
    },
    'bootstrap-responsive': {
        'source_filenames': (
            'vendor/bootstrap/less/bootstrap.less',
            'vendor/bootstrap/less/responsive.less',
        ),
        'output_filename': 'css/bootstrap-responsive.css',
    },

    'font-awesome': {
        'source_filenames': (
            'vendor/font-awesome/font-awesome.less',
        ),
        'output_filename': 'css/font-awesome.css',
    },
    'font-awesome-ie7': {
        'source_filenames': (
            'vendor/font-awesome/font-awesome-ie7.less',
        ),
        'output_filename': 'css/font-awesome-ie7.css',
    },

    # ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 1flow

    'landing': {
        # This one is not "compiled" but simply copied. We wanted it
        # to be integrated into the pipeline for consistency only.
        'source_filenames': (
            'css/landing-styles.css',
        ),
        'output_filename': 'css/landing.css',
    },

    'core-bootstrap-detail': {
        'source_filenames': (
            'sass/detail-admin/bootstrap-overrides.scss',
            'sass/styles-core-bootstrap-detail.scss',
        ),
        'output_filename': 'css/core-details.css',
    },

    'core-bootstrap-bare': {
        'source_filenames': (
            'sass/styles-core-bootstrap-bare.scss',
        ),
        'output_filename': 'css/core.css',
    }
}

PIPELINE_JS = {

    # •••••••••••••••••••••••••••••••••••••••••••••••••••••••••• vendor

    'vendor-all': {
        # This one includes all external dependancies
        # (eg. non 1flow sources) for a one-file-only dep.
        'source_filenames': (
            # WARNING: order matters: tooltip must be included before popover.
            'vendor/bootstrap/js/bootstrap-[a-o]*.js',
            'vendor/bootstrap/js/bootstrap-t*.js',
            'vendor/bootstrap/js/bootstrap-p*.js',
            'vendor/bootstrap/js/bootstrap-[q-s]*.js',
            'vendor/bootstrap/js/bootstrap-[u-z]*.js',

            'vendor/showdown/showdown.js',
            'vendor/showdown/extensions/twitter.js',

            'vendor/moment/moment.js',
            'vendor/moment/langs/*.js',

            'vendor/other/*.js',

            # NOTE: we use or own implementation
            # of django-endless-pagination JS.
        ),
        'output_filename': 'js/min/vendor-all.js',
    },

    'vendor-bootstrap': {
        'source_filenames': (
            # WARNING: order matters: tooltip must be included before popover.
            'vendor/bootstrap/js/bootstrap-[a-o]*.js',
            'vendor/bootstrap/js/bootstrap-t*.js',
            'vendor/bootstrap/js/bootstrap-p*.js',
            'vendor/bootstrap/js/bootstrap-[q-s]*.js',
            'vendor/bootstrap/js/bootstrap-[u-z]*.js',
        ),
        'output_filename': 'js/min/bootstrap.js',
    },

    'vendor-showdown': {
        'source_filenames': (
            'vendor/showdown/showdown.js',
            'vendor/showdown/extensions/twitter.js',
        ),
        'output_filename': 'js/min/showdown.js',
    },

    'vendor-moment': {
        'source_filenames': (
            'vendor/moment/moment.js',
            'vendor/moment/langs/*.js',
        ),
        'output_filename': 'js/min/moment.js',
    },

    # NOTE: we use or own implementation
    # of django-endless-pagination JS.
    'vendor-endless-pagination': {
        'source_filenames': (
            'endless_pagination/js/endless-pagination.js',
        ),
        'output_filename': 'js/min/endless-pagination.js',
    },

    # ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 1flow

    'utils': {
        'source_filenames': (
            'js/utils/*.js',
        ),
        'output_filename': 'js/min/utils.js',
    },

    'read': {
        'source_filenames': (
            'js/utils/*.js',
            'js/common.js',
            'js/read.js',
        ),
        'output_filename': 'js/min/read.js',
    },

    'core': {
        'source_filenames': (
            'js/utils/*.js',
            'js/common.js',
        ),
        'output_filename': 'js/min/core.js',
    },

    'ember-core': {
        'source_filenames': (
            'js/ember-core/core.js',
            'js/ember-core/controllers/*.js',
            'js/ember-core/models/*.js',
            'js/ember-core/views/*.js',
            'js/ember-core/routes/*.js',
            'js/ember-core/helpers/*.js',
            'js/ember-core/end.js',
        ),
        'output_filename': 'js/min/ember-core.js',
    }
}

if TEMPLATE_DEBUG:
    # Because Django's cached templates doesn't use a proper caching
    # engine, it doesn't benefit from our DummyCache development setting…
    # We have to deactivate it completely for development.
    # cf. http://stackoverflow.com/a/4071488/654755
    TEMPLATE_LOADERS = (
        'django.template.loaders.filesystem.Loader',
        'django.template.loaders.app_directories.Loader',
    )

else:
    TEMPLATE_LOADERS = (
        ('django.template.loaders.cached.Loader', (
            'django.template.loaders.filesystem.Loader',
            'django.template.loaders.app_directories.Loader',
        )),
    )

# We always include the *Cache* middlewares. In development &
# pre-production it's a dummy cache, allowing to keep them here.
MIDDLEWARE_CLASSES = (
    #'ConditionalGetMiddleware',
    ('raven.contrib.django.raven_compat.middleware.'
        'SentryResponseErrorIdMiddleware'),
    'raven.contrib.django.raven_compat.middleware.Sentry404CatchMiddleware',
    'django.middleware.cache.UpdateCacheMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.locale.LocaleMiddleware',
    'django.middleware.common.CommonMiddleware',
    # TODO: test and activate this.
    #'django.middleware.transaction.TransactionMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    # TODO: activate this if needed.
    #'social_auth.middleware.SocialAuthExceptionMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'maintenancemode.middleware.MaintenanceModeMiddleware',
    'django.middleware.gzip.GZipMiddleware',
    'django.middleware.cache.FetchFromCacheMiddleware',
)

if not DEBUG:
    MIDDLEWARE_CLASSES = MIDDLEWARE_CLASSES[:-1] + (
        'pipeline.middleware.MinifyHTMLMiddleware',
    ) + MIDDLEWARE_CLASSES[-1:]

#SESSION_ENGINE = "django.contrib.sessions.backends.cached_db"
SESSION_ENGINE = 'redis_sessions.session'

TEMPLATE_DIRS = (
    os.path.join(PROJECT_ROOT, 'templates')
)

# cf. https://docs.djangoproject.com/en/1.5/ref/settings/#template-context-processors # NOQA
TEMPLATE_CONTEXT_PROCESSORS = (
    # NOTE: ….debug is added only if DEBUG=True, later in another snippet.
    'django.core.context_processors.i18n',
    'django.core.context_processors.media',
    'django.core.context_processors.static',
    'django.core.context_processors.tz',
    'django.core.context_processors.request',
    'absolute.context_processors.absolute',
    'constance.context_processors.config',
    'django.contrib.auth.context_processors.auth',
    'django.contrib.messages.context_processors.messages',

    # TODO: activate one of these when needed.
    #'social_auth.context_processors.social_auth_by_name_backends',
    'social_auth.context_processors.social_auth_backends',
    #'social_auth.context_processors.social_auth_login_redirect',

    # `base` processors
    'oneflow.base.context_processors.oneflow_version',
    'oneflow.base.context_processors.django_settings',
    'oneflow.base.context_processors.maintenance_mode',

    # `core` processors
    'oneflow.core.context_processors.mongodb_user',
    'oneflow.core.context_processors.social_things',
)


INSTALLED_APPS = (
    'raven.contrib.django.raven_compat',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    #'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    #'grappelli.dashboard',
    'grappelli',
    'mongoadmin',
    'django.contrib.admin',
    #'django.contrib.admindocs',
    'django_reset',
    'django_shell_ipynb',
    'gunicorn',
    'south',
    'south_admin',
    #'maintenancemode', — not needed at all, the middleware is sufficient.
    'transmeta',
    'logentry_admin',
    'constance',
    'tastypie',
    'tastypie_mongoengine',
    'overextends',
    'redis_sessions',
    #'redisboard',
    'djcelery',
    'memcache_status',
    'markdown_deux',
    'djangojs',
    'pipeline',
    'absolute',
    'endless_pagination',

    # `infinite_pagination` doesn't work on MongoEngine QuerySet.
    #'infinite_pagination',

    # We don't use `mathfilters` as of 20130831.
    #'mathfilters',

    'widget_tweaks',
    'oneflow.base',
    'oneflow.profiles',
    'oneflow.landing',
    'oneflow.core',
    # OMG: order matters! as DSA depends on user model,
    # it must come after 'oneflow.base' wich contains it.
    # Without this, tests fail to create database!
    'social_auth',
)

ENDLESS_PAGINATION_PER_PAGE = 100

# This is done directly in the templates.
#ENDLESS_PAGINATION_LOADING  = ugettext_lazy(u'loading more entries…')

JS_CONTEXT_PROCESSOR = 'oneflow.base.utils.JsContextSerializer'

RAVEN_CONFIG = {
    # We send flower bugs to a dedicated sentry project,
    # it pollutes us too much.
    'dsn': os.environ.get('RAVEN_DSN_FLOWER'
                          if 'flower' in sys.argv or 'shell_ipynb' in sys.argv
                          else 'RAVEN_DSN'),
}

STATSD_HOST   = os.environ.get('STATSD_HOST')
STATSD_PORT   = int(os.environ.get('STATSD_PORT', 8125))
STATSD_PREFIX = os.environ.get('STATSD_PREFIX', '1flow')

MAINTENANCE_MODE = os.path.exists(os.path.join(BASE_ROOT, 'MAINTENANCE_MODE'))

MAINTENANCE_IGNORE_URLS = (
    r'^/admin/.*',
)

MARKDOWN_DEUX_STYLES = {
    'default': {
        'extras': {
            'code-friendly': None,
            'cuddled-lists': None,

        },
        'safe_mode': 'escape',
    },
    'raw': {
        'extras': {
            'code-friendly': None,
            'cuddled-lists': None,

        },
        'safe_mode': False,
    }
}

# CONSTANCE_* is to be found in 'snippets/constance*'

# Defaults to ['json', 'xml', 'yaml', 'html', 'plist']
TASTYPIE_DEFAULT_FORMATS = ('json', )
API_LIMIT_PER_PAGE = 10


AUTHENTICATION_BACKENDS = (
    # WARNING: when activating Twitter, we MUST implement the email pipeline,
    # else the social-only registration will fail because user has no mail.
    #'social_auth.backends.twitter.TwitterBackend',
    #'social_auth.backends.facebook.FacebookBackend',
    #'social_auth.backends.google.GoogleOAuthBackend',
    'social_auth.backends.google.GoogleOAuth2Backend',<commit_msg>Disable code-friendly plugin for default markdown2 configuration, this doesn't play well with `html2text` default options.<commit_after># -*- coding: utf-8 -*-
# Django common settings for oneflow project.
# These are overridden in hostname.py specific files.
#
# Here we define the settings for the test platform.
# Production will override only the needed directives.

import os
import sys
import warnings


from django.core.urlresolvers import reverse_lazy
from django.utils.translation import ugettext_lazy

# dummy ugettext function, as django's docs say
ugettext = lambda s: s

# This is imported here to benefit to all other included snippets.
from sparks import platform # NOQA

MAIN_SERVER = os.environ.get('MAIN_SERVER', None)

if MAIN_SERVER is None:
    raise RuntimeError('MAIN_SERVER setting must be defined '
                       'before common.py inclusion!')

# We need to go down 2 times because the starting point of these settings is
# `project/settings/__init__.py`, instead of good old `project/settings.py`.
# NOTE: the `execfile()` on snippets doesn't add depth: even if the current
# file is `project/settings/snippets/common.py`, this doesn't count.
PROJECT_ROOT = os.path.dirname(os.path.dirname(__file__))
BASE_ROOT    = os.path.dirname(PROJECT_ROOT)

ADMINS   = (('<NAME>', '<EMAIL>'), )
MANAGERS = ADMINS

from oneflow import VERSION

GRAPPELLI_ADMIN_TITLE = u'1flow v%s administration%s' % (VERSION, u' — DEVEL'
                                                         if DEBUG else u'')
MONGOADMIN_OVERRIDE_ADMIN = True

ALLOWED_HOSTS = []
TIME_ZONE     = 'Europe/Paris'
LANGUAGE_CODE = 'en'

# Translation workflows:
# - in the DB: all languages variants are accessible and empty by default.
#      'en' takes precedence on 'en-US'. As translators have access to all
#       translations, this is a bit awkward, but we don't have the choice
#       because we must match the Django application languages. We could
#       manually hide the 'en-us' to avoid confusion, but this would imply
#       dirty hacking in all admin modules and I don't find it worth.
# - in the webapp: 'en' is *always* defined because the developers create
#       english strings. For translators to be able to override them
#       without needing commit access, we use the 'en-us' language, which
#       takes precedence. This is not perfect, because other 'en-*'
#       users will get the 'bare' strings which can have errors, but at
#       least our translators have access to en-US strings the same way
#       they access other languages.
LANGUAGES = (
    ('en', ugettext(u'English')),
    # We're not ready to handle a british translation (no resource…)
    #('en-gb', ugettext(u'English (UK)')),
    ('fr', ugettext(u'Français')),

    # Activate these later when we need them.
    #    ('es', ugettext(u'Español')),
    #    ('fr-CA', ugettext(u'Français (FR)')),
    #    ('es-XX', ugettext(u'Español (ES)')),
)

TRANSMETA_LANGUAGES = LANGUAGES + (
    # The 'nt' fake language is used by translators to keep
    # variants and translations notes handy in the admin interface.
    ('nt', ugettext(u'Notes — variants')),
)

# We use oneflow.base.models.User as a drop-in replacement.
AUTH_USER_MODEL = 'base.User'
SOCIAL_AUTH_USER_MODEL = 'base.User'

USE_I18N = True
USE_L10N = True
USE_TZ   = True

# Activate if bandwidth is limited, at some CPU cost.
#USE_ETAGS = True

MEDIA_ROOT = os.path.join(BASE_ROOT, 'media')
MEDIA_URL  = '/media/'

STATIC_ROOT = os.path.join(BASE_ROOT, 'static')
STATIC_URL  = '/static/'

SECRET_KEY = '<KEY>

ROOT_URLCONF = 'oneflow.urls'

WSGI_APPLICATION = 'oneflow.wsgi.application'

STATICFILES_DIRS = (
)

STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)

STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage'

#PIPELINE_ENABLED = False

# Until our own modules are ready to be wrapped, don't use this.
PIPELINE_DISABLE_WRAPPER = True

PIPELINE_COMPILERS = (
    'pipeline.compilers.less.LessCompiler',
    # We don't use the from django-pipeline-compass compiler,
    # it breaks bootstrap-responsive.
    #       'pipeline_compass.compiler.CompassCompiler',
    #
    # Intead, we use the one from django-pipeline-compass-rubygem, which
    # runs the official 'compass' Ruby binary in a subshell.
    #
    # WARNING, though: both packages install at the same location.
    # As of 20130524, django-pipeline-compass-rubygem is itself broken,
    # because it doesn't ship the __init__.py. Thus it doesn't work alone;
    # but it doesn't depend on django-pipeline-compass, which makes the
    # whole process heavily error-prone because we need to install both,
    # but it's not issued anywhere.
    #
    # Finally, after installing 2 python packages and Ruby + the rubygem,
    # everything works as expected. I personally prefer using the official
    # 'compass' and have a working CSS, than an un-maintained python erzatz
    # which doesnt work and breaks CSSs without any error displayed.
    'pipeline_compass.compass.CompassCompiler',
    'pipeline.compilers.coffee.CoffeeScriptCompiler',
)

PIPELINE_CSS = {

    # •••••••••••••••••••••••••••••••••••••••••••••••••••••••••• vendor

    # TODO: the 'vendor-all' target.

    'bootstrap': {
        'source_filenames': (
            'vendor/bootstrap/less/bootstrap.less',
        ),
        'output_filename': 'css/bootstrap.css',
    },
    'bootstrap-responsive': {
        'source_filenames': (
            'vendor/bootstrap/less/bootstrap.less',
            'vendor/bootstrap/less/responsive.less',
        ),
        'output_filename': 'css/bootstrap-responsive.css',
    },

    'font-awesome': {
        'source_filenames': (
            'vendor/font-awesome/font-awesome.less',
        ),
        'output_filename': 'css/font-awesome.css',
    },
    'font-awesome-ie7': {
        'source_filenames': (
            'vendor/font-awesome/font-awesome-ie7.less',
        ),
        'output_filename': 'css/font-awesome-ie7.css',
    },

    # ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 1flow

    'landing': {
        # This one is not "compiled" but simply copied. We wanted it
        # to be integrated into the pipeline for consistency only.
        'source_filenames': (
            'css/landing-styles.css',
        ),
        'output_filename': 'css/landing.css',
    },

    'core-bootstrap-detail': {
        'source_filenames': (
            'sass/detail-admin/bootstrap-overrides.scss',
            'sass/styles-core-bootstrap-detail.scss',
        ),
        'output_filename': 'css/core-details.css',
    },

    'core-bootstrap-bare': {
        'source_filenames': (
            'sass/styles-core-bootstrap-bare.scss',
        ),
        'output_filename': 'css/core.css',
    }
}

PIPELINE_JS = {

    # •••••••••••••••••••••••••••••••••••••••••••••••••••••••••• vendor

    'vendor-all': {
        # This one includes all external dependancies
        # (eg. non 1flow sources) for a one-file-only dep.
        'source_filenames': (
            # WARNING: order matters: tooltip must be included before popover.
            'vendor/bootstrap/js/bootstrap-[a-o]*.js',
            'vendor/bootstrap/js/bootstrap-t*.js',
            'vendor/bootstrap/js/bootstrap-p*.js',
            'vendor/bootstrap/js/bootstrap-[q-s]*.js',
            'vendor/bootstrap/js/bootstrap-[u-z]*.js',

            'vendor/showdown/showdown.js',
            'vendor/showdown/extensions/twitter.js',

            'vendor/moment/moment.js',
            'vendor/moment/langs/*.js',

            'vendor/other/*.js',

            # NOTE: we use or own implementation
            # of django-endless-pagination JS.
        ),
        'output_filename': 'js/min/vendor-all.js',
    },

    'vendor-bootstrap': {
        'source_filenames': (
            # WARNING: order matters: tooltip must be included before popover.
            'vendor/bootstrap/js/bootstrap-[a-o]*.js',
            'vendor/bootstrap/js/bootstrap-t*.js',
            'vendor/bootstrap/js/bootstrap-p*.js',
            'vendor/bootstrap/js/bootstrap-[q-s]*.js',
            'vendor/bootstrap/js/bootstrap-[u-z]*.js',
        ),
        'output_filename': 'js/min/bootstrap.js',
    },

    'vendor-showdown': {
        'source_filenames': (
            'vendor/showdown/showdown.js',
            'vendor/showdown/extensions/twitter.js',
        ),
        'output_filename': 'js/min/showdown.js',
    },

    'vendor-moment': {
        'source_filenames': (
            'vendor/moment/moment.js',
            'vendor/moment/langs/*.js',
        ),
        'output_filename': 'js/min/moment.js',
    },

    # NOTE: we use or own implementation
    # of django-endless-pagination JS.
    'vendor-endless-pagination': {
        'source_filenames': (
            'endless_pagination/js/endless-pagination.js',
        ),
        'output_filename': 'js/min/endless-pagination.js',
    },

    # ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 1flow

    'utils': {
        'source_filenames': (
            'js/utils/*.js',
        ),
        'output_filename': 'js/min/utils.js',
    },

    'read': {
        'source_filenames': (
            'js/utils/*.js',
            'js/common.js',
            'js/read.js',
        ),
        'output_filename': 'js/min/read.js',
    },

    'core': {
        'source_filenames': (
            'js/utils/*.js',
            'js/common.js',
        ),
        'output_filename': 'js/min/core.js',
    },

    'ember-core': {
        'source_filenames': (
            'js/ember-core/core.js',
            'js/ember-core/controllers/*.js',
            'js/ember-core/models/*.js',
            'js/ember-core/views/*.js',
            'js/ember-core/routes/*.js',
            'js/ember-core/helpers/*.js',
            'js/ember-core/end.js',
        ),
        'output_filename': 'js/min/ember-core.js',
    }
}

if TEMPLATE_DEBUG:
    # Because Django's cached templates doesn't use a proper caching
    # engine, it doesn't benefit from our DummyCache development setting…
    # We have to deactivate it completely for development.
    # cf. http://stackoverflow.com/a/4071488/654755
    TEMPLATE_LOADERS = (
        'django.template.loaders.filesystem.Loader',
        'django.template.loaders.app_directories.Loader',
    )

else:
    TEMPLATE_LOADERS = (
        ('django.template.loaders.cached.Loader', (
            'django.template.loaders.filesystem.Loader',
            'django.template.loaders.app_directories.Loader',
        )),
    )

# We always include the *Cache* middlewares. In development &
# pre-production it's a dummy cache, allowing to keep them here.
MIDDLEWARE_CLASSES = (
    #'ConditionalGetMiddleware',
    ('raven.contrib.django.raven_compat.middleware.'
        'SentryResponseErrorIdMiddleware'),
    'raven.contrib.django.raven_compat.middleware.Sentry404CatchMiddleware',
    'django.middleware.cache.UpdateCacheMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.locale.LocaleMiddleware',
    'django.middleware.common.CommonMiddleware',
    # TODO: test and activate this.
    #'django.middleware.transaction.TransactionMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    # TODO: activate this if needed.
    #'social_auth.middleware.SocialAuthExceptionMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'maintenancemode.middleware.MaintenanceModeMiddleware',
    'django.middleware.gzip.GZipMiddleware',
    'django.middleware.cache.FetchFromCacheMiddleware',
)

if not DEBUG:
    MIDDLEWARE_CLASSES = MIDDLEWARE_CLASSES[:-1] + (
        'pipeline.middleware.MinifyHTMLMiddleware',
    ) + MIDDLEWARE_CLASSES[-1:]

#SESSION_ENGINE = "django.contrib.sessions.backends.cached_db"
SESSION_ENGINE = 'redis_sessions.session'

TEMPLATE_DIRS = (
    os.path.join(PROJECT_ROOT, 'templates')
)

# cf. https://docs.djangoproject.com/en/1.5/ref/settings/#template-context-processors # NOQA
TEMPLATE_CONTEXT_PROCESSORS = (
    # NOTE: ….debug is added only if DEBUG=True, later in another snippet.
    'django.core.context_processors.i18n',
    'django.core.context_processors.media',
    'django.core.context_processors.static',
    'django.core.context_processors.tz',
    'django.core.context_processors.request',
    'absolute.context_processors.absolute',
    'constance.context_processors.config',
    'django.contrib.auth.context_processors.auth',
    'django.contrib.messages.context_processors.messages',

    # TODO: activate one of these when needed.
    #'social_auth.context_processors.social_auth_by_name_backends',
    'social_auth.context_processors.social_auth_backends',
    #'social_auth.context_processors.social_auth_login_redirect',

    # `base` processors
    'oneflow.base.context_processors.oneflow_version',
    'oneflow.base.context_processors.django_settings',
    'oneflow.base.context_processors.maintenance_mode',

    # `core` processors
    'oneflow.core.context_processors.mongodb_user',
    'oneflow.core.context_processors.social_things',
)


INSTALLED_APPS = (
    'raven.contrib.django.raven_compat',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    #'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    #'grappelli.dashboard',
    'grappelli',
    'mongoadmin',
    'django.contrib.admin',
    #'django.contrib.admindocs',
    'django_reset',
    'django_shell_ipynb',
    'gunicorn',
    'south',
    'south_admin',
    #'maintenancemode', — not needed at all, the middleware is sufficient.
    'transmeta',
    'logentry_admin',
    'constance',
    'tastypie',
    'tastypie_mongoengine',
    'overextends',
    'redis_sessions',
    #'redisboard',
    'djcelery',
    'memcache_status',
    'markdown_deux',
    'djangojs',
    'pipeline',
    'absolute',
    'endless_pagination',

    # `infinite_pagination` doesn't work on MongoEngine QuerySet.
    #'infinite_pagination',

    # We don't use `mathfilters` as of 20130831.
    #'mathfilters',

    'widget_tweaks',
    'oneflow.base',
    'oneflow.profiles',
    'oneflow.landing',
    'oneflow.core',
    # OMG: order matters! as DSA depends on user model,
    # it must come after 'oneflow.base' wich contains it.
    # Without this, tests fail to create database!
    'social_auth',
)

ENDLESS_PAGINATION_PER_PAGE = 100

# This is done directly in the templates.
#ENDLESS_PAGINATION_LOADING  = ugettext_lazy(u'loading more entries…')

JS_CONTEXT_PROCESSOR = 'oneflow.base.utils.JsContextSerializer'

RAVEN_CONFIG = {
    # We send flower bugs to a dedicated sentry project,
    # it pollutes us too much.
    'dsn': os.environ.get('RAVEN_DSN_FLOWER'
                          if 'flower' in sys.argv or 'shell_ipynb' in sys.argv
                          else 'RAVEN_DSN'),
}

STATSD_HOST   = os.environ.get('STATSD_HOST')
STATSD_PORT   = int(os.environ.get('STATSD_PORT', 8125))
STATSD_PREFIX = os.environ.get('STATSD_PREFIX', '1flow')

MAINTENANCE_MODE = os.path.exists(os.path.join(BASE_ROOT, 'MAINTENANCE_MODE'))

MAINTENANCE_IGNORE_URLS = (
    r'^/admin/.*',
)

MARKDOWN_DEUX_STYLES = {
    'default': {
        'extras': {
            # html2text uses _ by default for EM…
            #'code-friendly': None,
            'cuddled-lists': None,

        },
        'safe_mode': 'escape',
    },
    'code': {
        'extras': {
            'code-friendly': None,
            'cuddled-lists': None,

        },
        'safe_mode': 'escape',
    },
    'raw': {
        'extras': {
            # html2text uses _ by default for EM…
            #'code-friendly': None,
            'cuddled-lists': None,

        },
        'safe_mode': False,
    },
    'code-raw': {
        'extras': {
            'code-friendly': None,
            'cuddled-lists': None,

        },
        'safe_mode': False,
    }
}

# CONSTANCE_* is to be found in 'snippets/constance*'

# Defaults to ['json', 'xml', 'yaml', 'html', 'plist']
TASTYPIE_DEFAULT_FORMATS = ('json', )
API_LIMIT_PER_PAGE = 10


AUTHENTICATION_BACKENDS = (
    # WARNING: when activating Twitter, we MUST implement the email pipeline,
    # else the social-only registration will fail because user has no mail.
    #'social_auth.backends.twitter.TwitterBackend',
    #'social_auth.backends.facebook.FacebookBackend',
    #'social_auth.backends.google.GoogleOAuthBackend',
    'social_auth.backends.google.GoogleOAuth2Backend',
{'fraction_non_alphanumeric': 0.13709137395750898, 'fraction_numerical': 0.00429171485968223, 'mean_word_length': 2.8725836869401227, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4494619', 'n_tokens_mistral': 11062, 'n_tokens_neox': 10787, 'n_words': 2201}