# Path: rophako/settings.py
# class ConfigHandler(object):
#     def load_settings(self):
#     def print_settings(self):
#     def load_plugins(self):
#     def __getattr__(self, section):
# 
# Path: rophako/plugin.py
# def load_plugin(name, as_blueprint=True, template_path=None):
#     """Load a Rophako CMS plugin.
# 
#     * `name` is a Python module name, i.e. `rophako.modules.blog`
#     * `as_blueprint` is True if the module exports a blueprint object called
#       `mod` that can be attached to the Flask app. Set this value to False if
#       you simply need to include a Python module that isn't a blueprint.
#     * `template_path` is a filesystem path where the blueprint's templates
#       can be found. If not provided, the path is automatically determined
#       based on the module name, which is suitable for the built-in plugins."""
#     from rophako.app import app, BLUEPRINT_PATHS
#     module = import_module(name)
#     if as_blueprint:
#         mod = getattr(module, "mod")
#         app.register_blueprint(mod)
# 
#         # Get the template path to add to the BLUEPRINT_PATHS.
#         if template_path is None:
#             module_path   = name.replace(".", "/")
#             template_path = os.path.join(module_path, "templates")
# 
#         BLUEPRINT_PATHS.append(template_path)
# 
# Path: rophako/log.py
# class LogHandler(logging.Handler):
#     def emit(self, record):


from flask import (Flask, g, request, session, render_template, send_file,
    abort, redirect)
from flask_sslify import SSLify
from flask_compress import Compress
from rophako.settings import Config
from rophako.plugin import load_plugin
from rophako.log import logger
            from rophako.modules.account import logout
import jinja2
import os.path
import datetime
import sys
import rophako.utils
import rophako.model.emoticons as Emoticons
        import rophako.model.user as User
# and default templates. The base list of template paths to check includes
# your custom path (from config.SITE_ROOT), the "rophako/www" path for normal
# pages, and then the blueprint paths for all imported plugins. This list will
# be extended while blueprints are being loaded and passed in below to the
# jinja2.ChoiceLoader.
BLUEPRINT_PATHS = []

Config.load_settings()
Config.load_plugins()

#import rophako.model.tracking as Tracking

# String escaping for the secret key (processes \ escapes properly), the
# escape encoding name varies between Python 2 and 3.
string_escape = "string_escape" if sys.version_info[0] == 2 \
                else "unicode_escape"

app.DEBUG      = Config.site.debug == "true"
app.secret_key = bytes(Config.security.secret_key.encode("utf-8")) \
                 .decode(string_escape)

# Make templates easier to edit live.
app.config["TEMPLATES_AUTO_RELOAD"] = True

# Security?
if Config.security.force_ssl == True:
    app.config['SESSION_COOKIE_SECURE'] = True
    sslify = SSLify(app)

# Load all the built-in essential plugins.

# Path: rophako/settings.py
# class ConfigHandler(object):
#     def load_settings(self):
#     def print_settings(self):
#     def load_plugins(self):
#     def __getattr__(self, section):
# 
# Path: rophako/plugin.py
# def load_plugin(name, as_blueprint=True, template_path=None):
#     """Load a Rophako CMS plugin.
# 
#     * `name` is a Python module name, i.e. `rophako.modules.blog`
#     * `as_blueprint` is True if the module exports a blueprint object called
#       `mod` that can be attached to the Flask app. Set this value to False if
#       you simply need to include a Python module that isn't a blueprint.
#     * `template_path` is a filesystem path where the blueprint's templates
#       can be found. If not provided, the path is automatically determined
#       based on the module name, which is suitable for the built-in plugins."""
#     from rophako.app import app, BLUEPRINT_PATHS
#     module = import_module(name)
#     if as_blueprint:
#         mod = getattr(module, "mod")
#         app.register_blueprint(mod)
# 
#         # Get the template path to add to the BLUEPRINT_PATHS.
#         if template_path is None:
#             module_path   = name.replace(".", "/")
#             template_path = os.path.join(module_path, "templates")
# 
#         BLUEPRINT_PATHS.append(template_path)
# 
# Path: rophako/log.py
# class LogHandler(logging.Handler):
#     def emit(self, record):


# Path: rophako/app.py
from flask import (Flask, g, request, session, render_template, send_file,
    abort, redirect)
from flask_sslify import SSLify
from flask_compress import Compress
from rophako.settings import Config
from rophako.plugin import load_plugin
from rophako.log import logger
            from rophako.modules.account import logout
import jinja2
import os.path
import datetime
import sys
import rophako.utils
import rophako.model.emoticons as Emoticons
        import rophako.model.user as User

# and default templates. The base list of template paths to check includes
# your custom path (from config.SITE_ROOT), the "rophako/www" path for normal
# pages, and then the blueprint paths for all imported plugins. This list will
# be extended while blueprints are being loaded and passed in below to the
# jinja2.ChoiceLoader.
BLUEPRINT_PATHS = []

Config.load_settings()
Config.load_plugins()

#import rophako.model.tracking as Tracking

# String escaping for the secret key (processes \ escapes properly), the
# escape encoding name varies between Python 2 and 3.
string_escape = "string_escape" if sys.version_info[0] == 2 \
                else "unicode_escape"

app.DEBUG      = Config.site.debug == "true"
app.secret_key = bytes(Config.security.secret_key.encode("utf-8")) \
                 .decode(string_escape)

# Make templates easier to edit live.
app.config["TEMPLATES_AUTO_RELOAD"] = True

# Security?
if Config.security.force_ssl == True:
    app.config['SESSION_COOKIE_SECURE'] = True
    sslify = SSLify(app)

# Load all the built-in essential plugins.

load_plugin("rophako.modules.admin")