Exemplo n.º 1
0
def plugin_load_wsgi():
    from pytsite import lang, router
    from plugins import settings, auth_ui, auth_google
    from . import _driver, _eh, _settings_form, _controllers

    # Language globals
    lang.register_global(
        'auth_ui_google_admin_settings_url',
        lambda language, args: settings.form_url('auth_google'))

    # Event handlers
    router.on_dispatch(_eh.router_dispatch)

    # Settings
    settings.define('auth_google', _settings_form.Form,
                    'auth_ui_google@auth_google', 'fa fa-google', 'dev')

    try:
        auth_ui.register_driver(_driver.UI(auth_google.get_client_id()))
        router.handle(_controllers.Authorization,
                      '/auth_google/authorization',
                      'auth_ui_google@authorization',
                      filters=auth_ui.AuthFilter)

    except auth_google.error.ClientIdNotDefined:
        pass
Exemplo n.º 2
0
def _init():
    from os import path, makedirs
    from pytsite import tpl, lang, reg, cleanup
    from . import _eh

    # Resources
    tpl.register_package(__name__)
    lang.register_package(__name__)

    # Create directory to store session data
    session_storage_path = reg.get('paths.session')
    if not path.exists(session_storage_path):
        makedirs(session_storage_path, 0o755, True)

    # Lang globals
    lang.register_global('base_url', lambda language, args: base_url(language))

    # Tpl globals
    tpl.register_global('url', url)
    tpl.register_global('is_rule_defined', has_rule)
    tpl.register_global('rule_url', rule_url)
    tpl.register_global('current_url', current_url)
    tpl.register_global('current_path', current_path)
    tpl.register_global('base_url', base_url)
    tpl.register_global('is_base_url', is_base_url)
    tpl.register_global('is_main_host', is_main_host)
    tpl.register_global('session_messages', lambda x: session().get_messages(x) if session() else ())

    # Clear flash messages from all sessions
    s_store = get_session_store()
    for sid in s_store.list():
        s_store.save_if_modified(s_store.get(sid).clear_messages())

    # Events handlers
    cleanup.on_cleanup(_eh.on_cleanup)
Exemplo n.º 3
0
def plugin_load_wsgi():
    from pytsite import lang, router
    from plugins import settings
    from . import _eh, _settings_form

    # Resources
    lang.register_global(
        'google_maps_admin_settings_url',
        lambda language, args: settings.form_url('google_maps'))

    # Settings
    settings.define('google_maps', _settings_form.Form,
                    'google_maps_ui@google_maps', 'fa fa-map', 'dev')

    # Event handlers
    router.on_dispatch(_eh.on_router_dispatch)
Exemplo n.º 4
0
def plugin_load_uwsgi():
    from pytsite import lang, router
    from plugins import settings
    from . import _settings_form, _eh

    # Resources
    lang.register_package(__name__)

    # Lang globals
    lang.register_global('tumblr_admin_settings_url', lambda language, args: settings.form_url('tumblr'))

    # Settings
    settings.define('tumblr', _settings_form.Form, 'tumblr@tumblr', 'fa fa-tumblr', 'dev')

    # Event handlers
    router.on_dispatch(_eh.router_dispatch)
Exemplo n.º 5
0
def plugin_load_uwsgi():
    from pytsite import lang, router
    from plugins import settings
    from . import _eh, _settings_form, _controllers

    # Lang globals
    lang.register_global('facebook_admin_settings_url', lambda language, args: settings.form_url('facebook'))

    # Routes
    router.handle(_controllers.Authorize, '/facebook/authorize', 'facebook@authorize')

    # Settings
    settings.define('facebook', _settings_form.Form, 'facebook@facebook', 'fa fa-facebook', 'dev')

    # Event handlers
    router.on_dispatch(_eh.router_dispatch)
Exemplo n.º 6
0
def plugin_load_wsgi():
    from pytsite import lang, router
    from plugins import settings
    from . import _settings_form, _eh

    # Lang globals
    lang.register_global(
        'google_analytics_admin_settings_url',
        lambda language, args: settings.form_url('google_analytics'))

    # Settings
    settings.define('google_analytics', _settings_form.Form,
                    'google_analytics@google_analytics', 'fa fa-line-chart',
                    'dev')

    # Event handlers
    router.on_dispatch(_eh.router_dispatch)
Exemplo n.º 7
0
def plugin_load_wsgi():
    """Hook
    """
    from pytsite import lang, router
    from plugins import settings
    from . import _settings_form, _eh

    # Lang globals
    lang.register_global('addthis_admin_settings_url',
                         lambda language, args: settings.form_url('addthis'))

    # Settings
    settings.define('addthis', _settings_form.Form, 'addthis@addthis',
                    'fa fas fa-plus-square', 'dev')

    # Events
    router.on_dispatch(_eh.router_dispatch)
Exemplo n.º 8
0
def plugin_load_wsgi():
    from pytsite import lang, router
    from plugins import comments, settings
    from . import _eh, _comments, _settings_form

    # Lang globals
    lang.register_global('disqus_admin_settings_url',
                         lambda language, args: settings.form_url('disqus'))

    # Comments driver
    comments.register_driver(_comments.Driver())

    # Settings
    settings.define('disqus', _settings_form.Form, 'disqus@disqus',
                    'fa fa-comments', 'dev')

    # Event handlers
    router.on_dispatch(_eh.router_dispatch)