Example #1
0
def create_app(config_name):
    app = Flask(__name__)
    app.config.from_object(config[config_name])
    config[config_name].init_app(app)

    moment.init_app(app)
    bootstrap.init_app(app)

    configure_blueprints(app)

    # initialize Wiki and place it in current_app
    with app.app_context():
        app.wiki = Wiki()

    return app
Example #2
0
CACHE_DIR = os.path.join(app.config.get("CONTENT_DIR"), "cache")
cache.init_app(app, config={"CACHE_TYPE": "filesystem", "CACHE_DIR": CACHE_DIR})
manager = Manager(app)

loginmanager = LoginManager()
loginmanager.init_app(app)
loginmanager.login_view = "user_login"
markup = dict([(klass.NAME, klass) for klass in Markup.__subclasses__()])[app.config.get("MARKUP")]

wiki = Wiki(app.config.get("CONTENT_DIR"))

# FIX ME: This monkeypatching is pollution crap .
#         Should be possible to import them wherever,
#         Wiki class should be a singleton.
app.wiki = wiki
app.signals = wiki_signals
app.EditorForm = EditorForm


users = UserManager(app.config.get("CONTENT_DIR"))


@loginmanager.user_loader
def load_user(name):
    return users.get_user(name)


"""
    Routes
    ~~~~~~