# 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
        abspath = os.path.abspath("{}/{}".format(root, path))
        if os.path.isfile(abspath):
            return send_file(abspath)

        # The exact file wasn't found, look for some extensions and index pages.
        suffixes = [
            ".html",
            "/index.html",
            ".md",         # Markdown formatted pages.
            "/index.md",
        ]
        for suffix in suffixes:
            if not "." in path and os.path.isfile(abspath + suffix):
                # HTML, or Markdown?
                if suffix.endswith(".html"):
                    return rophako.utils.template(path + suffix)
                else:
                    return rophako.utils.markdown_template(abspath + suffix)

    return not_found("404")


@app.route("/")
def index():
    return catchall("index")


@app.errorhandler(Exception)
def catch_exception(error):
    """Catch unexpected Python exceptions and e-mail them out."""

# 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

        abspath = os.path.abspath("{}/{}".format(root, path))
        if os.path.isfile(abspath):
            return send_file(abspath)

        # The exact file wasn't found, look for some extensions and index pages.
        suffixes = [
            ".html",
            "/index.html",
            ".md",         # Markdown formatted pages.
            "/index.md",
        ]
        for suffix in suffixes:
            if not "." in path and os.path.isfile(abspath + suffix):
                # HTML, or Markdown?
                if suffix.endswith(".html"):
                    return rophako.utils.template(path + suffix)
                else:
                    return rophako.utils.markdown_template(abspath + suffix)

    return not_found("404")


@app.route("/")
def index():
    return catchall("index")


@app.errorhandler(Exception)
def catch_exception(error):
    """Catch unexpected Python exceptions and e-mail them out."""

    logger.error("INTERNAL SERVER ERROR: {}".format(str(error)))