Example #1
0
File: app.py Project: npk/june
def create_application():
    settings = dict(
        debug=options.debug,
        autoescape=options.autoescape,
        cookie_secret=options.cookie_secret,
        xsrf_cookies=True,
        login_url=options.login_url,
        template_path=options.template_path,
        static_path=options.static_path,
        static_url_prefix=options.static_url_prefix,
    )
    #: init application
    application = JulyApplication(**settings)

    #: register account app
    application.register_app("june.account.handlers.app", url_prefix="/account")
    application.register_app("june.account.service.app", url_prefix="/social")
    application.add_handler(("/members", "june.account.handlers.MembersHandler"))
    application.add_handler(("/city/(.*)", "june.account.handlers.CityMembersHandler"))

    #: register node app
    application.register_app("june.node.handlers.app", url_prefix="/node")

    from june.node.handlers import NodeListHandler

    application.add_handler(("/nodes", NodeListHandler))

    #: register topic app
    application.register_app("june.topic.handlers.app", url_prefix="/topic")

    from june.topic.handlers import CreateNodeTopicHandler
    from june.topic.handlers import ReplyHandler

    application.add_handler(("/node/(\w+)/create", CreateNodeTopicHandler))
    application.add_handler(("/reply/(\d+)", ReplyHandler))

    #: register dashboard app
    application.register_app("june.dashboard.handlers.app", url_prefix="/dashboard")

    #: register mail service
    application.register_app("july.ext.mail.handlers.app", url_prefix="/mail")

    #: register front app
    application.register_app("june.front.handlers.app", url_prefix="")

    #: register feedback app
    # application.register_app('june.feedback.handlers.app')

    for key in ["sitename", "siteurl", "sitefeed", "version", "ga", "gcse"]:
        application.register_context(key, options[key].value())

    import datetime

    application.register_context("now", datetime.datetime.utcnow)
    application.register_context("debug", options.debug)

    from june.filters import markdown, xmldatetime, localtime, timesince
    from june.filters import topiclink, normal_markdown

    application.register_filter("markdown", markdown)
    application.register_filter("normal_markdown", normal_markdown)
    application.register_filter("xmldatetime", xmldatetime)
    application.register_filter("localtime", localtime)
    application.register_filter("timesince", timesince)
    application.register_filter("topiclink", topiclink)

    return application
Example #2
0
File: app.py Project: askender/june
def create_application():
    settings = dict(
        debug=options.debug,
        autoescape=options.autoescape,
        cookie_secret=options.cookie_secret,
        xsrf_cookies=True,
        login_url=options.login_url,

        template_path=options.template_path,
        static_path=options.static_path,
        static_url_prefix=options.static_url_prefix,
    )
    #: init application
    application = JulyApplication(**settings)

    #: register account app
    application.register_app(
        'june.account.handlers.app',
        url_prefix='/account'
    )
    application.register_app('june.account.service.app', url_prefix='/social')
    application.add_handler(
        ('/members', 'june.account.handlers.MembersHandler')
    )
    application.add_handler(
        ('/city/(.*)', 'june.account.handlers.CityMembersHandler')
    )

    #: register node app
    application.register_app('june.node.handlers.app', url_prefix='/node')

    from june.node.handlers import NodeListHandler
    application.add_handler(('/nodes', NodeListHandler))

    #: register topic app
    application.register_app('june.topic.handlers.app', url_prefix='/topic')

    from june.topic.handlers import CreateNodeTopicHandler
    from june.topic.handlers import ReplyHandler
    application.add_handler(('/node/(\w+)/create', CreateNodeTopicHandler))
    application.add_handler(('/reply/(\d+)', ReplyHandler))

    #: register dashboard app
    application.register_app(
        'june.dashboard.handlers.app',
        url_prefix='/dashboard'
    )

    #: register mail service
    application.register_app('july.ext.mail.handlers.app', url_prefix='/mail')

    #: register front app
    application.register_app('june.front.handlers.app', url_prefix='')

    #: register feedback app
    # application.register_app('june.feedback.handlers.app')

    for key in ['sitename', 'siteurl', 'sitefeed', 'version', 'ga', 'gcse']:
        application.register_context(key, options[key].value())

    import datetime
    application.register_context('now', datetime.datetime.utcnow)

    from june.filters import markdown, xmldatetime, localtime, timesince
    from june.filters import topiclink, normal_markdown
    application.register_filter('markdown', markdown)
    application.register_filter('normal_markdown', normal_markdown)
    application.register_filter('xmldatetime', xmldatetime)
    application.register_filter('localtime', localtime)
    application.register_filter('timesince', timesince)
    application.register_filter('topiclink', topiclink)

    return application