import sys

for module in ('mf2py', 'mf2util'):
    if module not in sys.path:
        sys.path.append(module)

from flask import Flask
#from flask_debugtoolbar import DebugToolbarExtension
from flask.ext.assets import Environment, Bundle
from werkzeug.datastructures import ImmutableDict
from redis import Redis
from config import Configuration

# half-hearted "theme" support was more trouble than it's worth. maybe
#revisit later on.
#app = Flask( __name__,
#template_folder=os.path.join(Configuration.THEME, 'templates'),
#static_folder=os.path.join(Configuration.THEME, 'static'))

app = Flask(__name__)

app.config.from_object(Configuration)
redis = Redis()

assets = Environment(app)
assets.register(
    'css_all', Bundle('css/base.css', 'css/skeleton.css',
                      'css/layout.css',
                      filters='cssmin', output='css/site.css'))

app.jinja_options = ImmutableDict(
    trim_blocks=True,
    lstrip_blocks=True,
    extensions=['jinja2.ext.autoescape', 'jinja2.ext.with_', 'jinja2.ext.i18n']
)

if app.debug:
    #toolbar = DebugToolbarExtension(app)
    app.config['SITE_URL'] = 'http://localhost:5000'

if not app.debug:
    import logging
    from logging.handlers import RotatingFileHandler
    app.logger.setLevel(logging.DEBUG)

    file_handler = RotatingFileHandler('app.log', maxBytes=1048576,
                                       backupCount=20)
    formatter = logging.Formatter(
        '%(asctime)s - %(name)s - %(levelname)s - %(message)s')
    file_handler.setFormatter(formatter)
    app.logger.addHandler(file_handler)

    error_handler = RotatingFileHandler('app.error.log', maxBytes=1048576,
                                        backupCount=20)
    error_handler.setLevel(logging.ERROR)
    error_handler.setFormatter(formatter)
    app.logger.addHandler(error_handler)

from . import controllers

import sys

for module in ('mf2py', 'mf2util'):
    if module not in sys.path:
        sys.path.append(module)

from flask import Flask
#from flask_debugtoolbar import DebugToolbarExtension
from flask.ext.assets import Environment, Bundle
from werkzeug.datastructures import ImmutableDict
from redis import Redis
from config import Configuration

# half-hearted "theme" support was more trouble than it's worth. maybe
#revisit later on.
#app = Flask( __name__,
#template_folder=os.path.join(Configuration.THEME, 'templates'),
#static_folder=os.path.join(Configuration.THEME, 'static'))

app = Flask(__name__)

app.config.from_object(Configuration)
redis = Redis()

assets = Environment(app)
assets.register(
    'css_all', Bundle('css/base.css', 'css/skeleton.css',
                      'css/layout.css', 'css/pygments.css',
                      filters='cssmin', output='css/site.css'))

app.jinja_options = ImmutableDict(
    trim_blocks=True,
    lstrip_blocks=True,
    extensions=['jinja2.ext.autoescape', 'jinja2.ext.with_', 'jinja2.ext.i18n']
)

if app.debug:
    #toolbar = DebugToolbarExtension(app)
    app.config['SITE_URL'] = 'http://localhost:5000'

if not app.debug:
    import logging
    from logging.handlers import RotatingFileHandler
    app.logger.setLevel(logging.DEBUG)

    file_handler = RotatingFileHandler('app.log', maxBytes=1048576,
                                       backupCount=20)
    formatter = logging.Formatter(
        '%(asctime)s - %(name)s - %(levelname)s - %(message)s')
    file_handler.setFormatter(formatter)
    app.logger.addHandler(file_handler)

    error_handler = RotatingFileHandler('app.error.log', maxBytes=1048576,
                                        backupCount=20)
    error_handler.setLevel(logging.ERROR)
    error_handler.setFormatter(formatter)
    app.logger.addHandler(error_handler)

from . import controllers

add pygments to css bundle