示例#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
示例#2
0
def plugin_load_wsgi():
    from pytsite import router
    from plugins import http_api
    from . import _http_api_controllers, _eh

    router.on_dispatch(_eh.router_dispatch)

    http_api.handle('POST', 'reload', _http_api_controllers.PostReload,
                    'reload_ui@reload')
示例#3
0
def plugin_load_wsgi():
    from pytsite import router, tpl

    tpl.register_global('asset_url', url)
    tpl.register_global('css', css)
    tpl.register_global('js', js)
    tpl.register_global('inline_js', inline_js)

    router.on_dispatch(reset, -999, '*')
    router.on_xhr_dispatch(reset, -999, '*')
示例#4
0
def _init():
    from pytsite import lang, router, tpl

    lang.register_package(__name__)
    router.on_dispatch(reset, -999, '*')
    router.on_xhr_dispatch(reset, -999, '*')
    router.on_exception(lambda args: reset(args.get('title')), -999)

    tpl.register_global('metatag', dump)
    tpl.register_global('metatags', dump_all)
    tpl.register_global('metatag_get', get)
示例#5
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)
示例#6
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)
示例#7
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)
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)
示例#9
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)
示例#10
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)
示例#11
0
def plugin_load_wsgi():
    from pytsite import router
    from plugins import http_api, settings
    from . import _api, _eh, _http_api_controllers, _error, _settings_form

    # Settings
    settings.define('theme', _settings_form.Form, 'theming@appearance',
                    'fa fa-paint-brush')

    # Events handlers
    router.on_dispatch(_eh.on_router_dispatch)

    # HTTP API handlers
    http_api.handle('POST', 'theme', _http_api_controllers.Install,
                    'theming@install')
    http_api.handle('PATCH', 'theme', _http_api_controllers.Switch,
                    'theming@switch')
    http_api.handle('DELETE', 'theme', _http_api_controllers.Uninstall,
                    'theming@uninstall')
示例#12
0
def plugin_load_wsgi():
    from pytsite import router
    from plugins import admin, auth_ui
    from . import _controllers, _eh

    # Routing
    abp = admin.base_path()
    router.handle(_controllers.GetForm,
                  abp + '/settings/<uid>',
                  'settings@get_form',
                  filters=auth_ui.AuthFilter)

    # Admin sidebar's section
    admin.sidebar.add_section('settings', __name__ + '@settings', 2000,
                              'title')

    # Define default application settings form
    define('app', _frm.Application, __name__ + '@application', 'fa fa-cube')

    # Event handlers
    router.on_dispatch(_eh.on_dispatch)
示例#13
0
def theme_load_wsgi():
    from pytsite import reg, tpl, router, events
    from . import controllers, eh

    # Home page route
    router.handle(controllers.Home, '/', 'home')

    # Following routes required by 'content' plugin as final point while processing request
    router.handle(controllers.ContentIndex, name='content_index')
    router.handle(controllers.ContentView, name='content_view')
    router.handle(controllers.ContentModify, name='content_modify')

    # "Article index by section" route
    router.handle('content@index', '/section/<term_alias>',
                  'article_index_by_section', {
                      'model': 'article',
                      'term_field': 'section',
                  })

    # "Article index by tag" route
    router.handle('content@index', '/tag/<term_alias>', 'article_index_by_tag',
                  {
                      'model': 'article',
                      'term_field': 'tags',
                  })

    # "Article index by author" route
    router.handle('content@index', '/author/<author>',
                  'article_index_by_author', {
                      'model': 'article',
                  })

    # Event handlers
    router.on_dispatch(eh.on_router_dispatch)
    tpl.on_render(eh.on_tpl_render)
    events.listen('[email protected]_widgets.theme',
                  eh.settings_form_setup_widgets_setup_widgets_theme)

    # Force Twitter Bootstrap v3 on the password authentication page
    reg.put('auth_ui_password.twitter_bootstrap_version', 3)