Example #1
0
def plugin_load_wsgi():
    from pytsite import cron, events, router
    from plugins import http_api, settings, robots_txt, flag
    from . import _eh, _controllers, _http_api_controllers, _settings_form

    # Events listeners
    cron.hourly(_eh.on_cron_hourly)
    cron.daily(_eh.on_cron_daily)
    on_content_view(_eh.on_content_view)
    events.listen('comments@create_comment', _eh.on_comments_create_comment)
    flag.on_flag_create(_eh.on_flag_toggle)
    flag.on_flag_delete(_eh.on_flag_toggle)

    # Routes
    router.handle(_controllers.Index, 'content/index/<model>', 'content@index')

    # HTTP API endpoints
    http_api.handle('PATCH', 'content/view/<model>/<uid>',
                    _http_api_controllers.PatchViewsCount,
                    'content@patch_view_count')
    http_api.handle('POST', 'content/abuse/<model>/<uid>',
                    _http_api_controllers.PostAbuse, 'content@post_abuse')

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

    # Sitemap location in robots.txt
    robots_txt.sitemap('/sitemap/index.xml')
Example #2
0
def plugin_load_wsgi():
    from plugins import http_api
    from . import _http_api_controllers

    http_api.handle('POST', 'file', _http_api_controllers.Post, 'file_ui@post')
    http_api.handle('GET', 'file/<uid>', _http_api_controllers.Get,
                    'file_ui@get')
Example #3
0
def plugin_load():
    from plugins import http_api
    from . import _http_api
    from ._const import GET_WIDGETS_PATH, SUBMIT_PATH

    http_api.handle('GET', GET_WIDGETS_PATH, _http_api.GetWidgets,
                    'form2@widgets')
    http_api.handle('POST', SUBMIT_PATH, _http_api.Submit, 'form2@submit')
Example #4
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')
Example #5
0
def plugin_load_wsgi():
    from pytsite import reg

    if reg.get('odm_http_api.enabled'):
        from plugins import http_api
        from . import _controllers

        http_api.handle('GET', 'odm/entities/<model>', _controllers.GetEntities, 'odm_http_api@get_entities')
        http_api.handle('GET', 'odm/entity/<ref>', _controllers.GetEntity, 'odm_http_api@get_entity')
        http_api.handle('POST', 'odm/entity/<model>', _controllers.PostEntity, 'odm_http_api@post_entity')
        http_api.handle('PATCH', 'odm/entity/<ref>', _controllers.PatchEntity, 'odm_http_api@patch_entity')
        http_api.handle('DELETE', 'odm/entity/<ref>', _controllers.DeleteEntity, 'odm_http_api@delete_entity')
Example #6
0
def plugin_load_wsgi():
    from pytsite import router, cron
    from plugins import settings, http_api
    from . import _eh, _model, _settings_form, _controllers, _http_api_controllers

    # Event handlers
    cron.every_min(_eh.on_cron_every_min)

    # Routes
    router.handle(_controllers.Unsubscribe,
                  '/content_digest/unsubscribe/<sid>',
                  'content_digest@unsubscribe')

    # HTTP API handlers
    http_api.handle('POST', 'content_digest/subscribe',
                    _http_api_controllers.PostSubscribe,
                    'content_digest@post_subscribe')

    # Settings
    settings.define('content_digest', _settings_form.Form,
                    'content_digest@content_digest', 'fa fa-rocket')
Example #7
0
def plugin_load_wsgi():
    from pytsite import router
    from plugins import auth_ui, settings, admin, http_api
    from . import _frm, _controllers, _http_api_controllers

    # Settings form
    settings.define('auth', _frm.Settings, 'auth_admin@security', 'fa fa-user', 'dev')

    # BAse path for route rules
    abp = admin.base_path() + '/auth'

    # HTTP API rules
    http_api.handle('GET', abp + '/browse/<e_type>', _http_api_controllers.GetBrowserRows, 'auth_admin@browser_rows')

    # Admin routes
    flt = auth_ui.AuthFilter
    router.handle(_controllers.Browser, abp + '/browse/role', 'auth_admin@browse_roles',
                  {'e_type': 'role'}, filters=flt)
    router.handle(_controllers.Browser, abp + '/browse/user', 'auth_admin@browse_users',
                  {'e_type': 'user'}, filters=flt)
    router.handle(_controllers.ModifyForm, abp + '/modify/role/<uid>', 'auth_admin@form_role_modify',
                  {'e_type': 'role'}, filters=flt)
    router.handle(_controllers.ModifyForm, abp + '/modify/user/<uid>', 'auth_admin@form_user_modify',
                  {'e_type': 'user'}, filters=flt)
    router.handle(_controllers.DeleteForm, abp + '/delete/role', 'auth_admin@form_role_delete',
                  {'e_type': 'role'}, ('GET', 'POST'), flt)
    router.handle(_controllers.DeleteForm, abp + '/delete/user', 'auth_admin@form_user_delete',
                  {'e_type': 'user'}, ('GET', 'POST'), flt)

    # 'Security' admin sidebar section
    admin.sidebar.add_section('security', 'auth_admin@security', 1000)

    # 'Users' admin sidebar menu
    admin.sidebar.add_menu('security', 'users', 'auth_admin@users', router.rule_path('auth_admin@browse_users'),
                           'fa fa-users', weight=10)

    # 'Roles' admin sidebar menu
    admin.sidebar.add_menu('security', 'roles', 'auth_admin@roles', router.rule_path('auth_admin@browse_roles'),
                           'fa fa-key', weight=20, roles='dev')
Example #8
0
def plugin_load_wsgi():
    from pytsite import router
    from plugins import robots_txt, auth, http_api
    from . import _controllers, _http_api_controllers, _eh

    # Routes
    bp = base_path()
    router.handle(_controllers.Form, bp + '/sign-in',
                  'auth_ui@sign_in_default')
    router.handle(_controllers.Form, bp + '/sign-in/<driver>',
                  'auth_ui@sign_in')
    router.handle(_controllers.Form, bp + '/sign-up',
                  'auth_ui@sign_up_default')
    router.handle(_controllers.Form, bp + '/sign-up/<driver>',
                  'auth_ui@sign_up')
    router.handle(_controllers.Form, bp + '/restore/<driver>',
                  'auth_ui@restore_account')
    router.handle(_controllers.SignUpConfirm, bp + '/sign-up/confirm/<code>',
                  'auth_ui@sign_up_confirm')
    router.handle(_controllers.SignOut, bp + '/sign-out', 'auth_ui@sign_out')
    router.handle(_controllers.UserProfileView, bp + '/user/<nickname>',
                  'auth_ui@user_profile_view')
    router.handle(_controllers.UserProfileModify, bp + '/user/<nickname>/edit',
                  'auth_ui@user_profile_modify')

    # HTTP API routes
    http_api.handle('GET', 'auth_ui/widget/user_select',
                    _http_api_controllers.GetWidgetUserSelect,
                    'auth_ui@get_widget_user_select')

    # Events handlers
    auth.on_sign_up(_eh.on_auth_sign_up)
    auth.on_user_status_change(_eh.on_auth_user_status_change)
    auth.on_user_as_jsonable(_eh.on_auth_user_as_jsonable)

    # robots.txt rules
    robots_txt.disallow(bp + '/')
Example #9
0
def plugin_load_wsgi():
    from plugins import http_api
    from . import _http_api_controllers

    http_api.handle('POST', 'form/widgets/<__form_uid>/<__form_step>', _http_api_controllers.PostGetWidgets,
                    'form@post_get_widgets')
    http_api.handle('POST', 'form/validate/<__form_uid>/<__form_step>', _http_api_controllers.PostValidate,
                    'form@post_validate')
    http_api.handle('POST', 'form/submit/<__form_uid>', _http_api_controllers.PostSubmit,
                    'form@post_submit')
Example #10
0
def plugin_load_wsgi():
    from pytsite import router
    from plugins import admin, http_api, auth_ui
    from . import _controllers, _http_api_controllers

    abp = admin.base_path()

    # Browse route
    router.handle(_controllers.Browse,
                  abp + '/odm_ui/<model>',
                  'odm_ui@admin_browse',
                  filters=auth_ui.AuthFilter)
    router.handle(_controllers.Browse,
                  'odm_ui/<model>',
                  'odm_ui@browse',
                  filters=auth_ui.AuthFilter)

    # Create/modify form routes
    router.handle(_controllers.Form,
                  abp + '/odm_ui/<model>/modify/<eid>',
                  'odm_ui@admin_m_form',
                  filters=auth_ui.AuthFilter)
    router.handle(_controllers.Form,
                  'odm_ui/<model>/modify/<eid>',
                  'odm_ui@m_form',
                  filters=auth_ui.AuthFilter)

    # Delete form route
    router.handle(_controllers.Form,
                  abp + '/odm_ui/<model>/delete',
                  'odm_ui@admin_d_form',
                  methods=('GET', 'POST'),
                  filters=auth_ui.AuthFilter)
    router.handle(_controllers.Form,
                  'odm_ui/<model>/delete',
                  'odm_ui@d_form',
                  methods=('GET', 'POST'),
                  filters=auth_ui.AuthFilter)

    # HTTP API handlers
    http_api.handle('GET', 'odm_ui/browser/rows/<model>',
                    _http_api_controllers.GetBrowserRows,
                    'odm_ui@get_browser_rows')
    http_api.handle('PUT', 'odm_ui/browser/rows/<model>',
                    _http_api_controllers.PutBrowserRows,
                    'odm_ui@put_browser_rows')
    http_api.handle('GET', 'odm_ui/widget/entity_select',
                    _http_api_controllers.GetWidgetEntitySelect,
                    'odm_ui@widget_entity_select')
Example #11
0
def plugin_load_uwsgi():
    from pytsite import plugman
    from plugins import settings, http_api
    from . import _settings_form, _http_api_controllers

    # HTTP API
    http_api.handle('POST', 'plugman/install/<name>', _http_api_controllers.PostInstall,
                    'plugman_ui@post_install')
    http_api.handle('POST', 'plugman/uninstall/<name>', _http_api_controllers.PostUninstall,
                    'plugman_ui@post_uninstall')
    http_api.handle('POST', 'plugman/upgrade/<name>', _http_api_controllers.PostUpgrade,
                    'plugman_ui@post_upgrade')

    if not plugman.is_dev_mode():
        # Settings
        settings.define('plugman', _settings_form.Form, 'plugman_ui@plugins', 'fa fa-plug', 'dev')
Example #12
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')
Example #13
0
def plugin_load_wsgi():
    from plugins import http_api, settings
    from . import _http_api_controllers, _settings_form

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

    # HTTP API
    http_api.handle('GET', 'comments/settings',
                    _http_api_controllers.GetSettings, 'comments@get_settings')
    http_api.handle('GET', 'comments/comments/<thread_uid>',
                    _http_api_controllers.GetComments, 'comments@get_comments')
    http_api.handle('POST', 'comments/comment/<thread_uid>',
                    _http_api_controllers.PostComment, 'comments@post_comment')
    http_api.handle('GET', 'comments/comment/<uid>',
                    _http_api_controllers.GetComment, 'comments@get_comment')
    http_api.handle('DELETE', 'comments/comment/<uid>',
                    _http_api_controllers.DeleteComment,
                    'comments@delete_comment')
    http_api.handle('POST', 'comments/report/<uid>',
                    _http_api_controllers.PostReport,
                    'comments@report_comment')
Example #14
0
def plugin_load_wsgi():
    from plugins import http_api
    from . import _controllers, _eh

    # Sign-up, sign-in, sign-out
    http_api.handle('POST', 'auth/sign-in', _controllers.SignIn, 'auth_http_api@sign_in')
    http_api.handle('POST', 'auth/sign-up', _controllers.SignUp, 'auth_http_api@sign_up')
    http_api.handle('POST', 'auth/sign-out', _controllers.SignOut, 'auth_http_api@sign_out')

    # # User HTTP API
    http_api.handle('GET', 'auth/users', _controllers.GetUsers,
                    'auth_http_api@get_users')
    http_api.handle('GET', 'auth/users/<uid>', _controllers.GetUser,
                    'auth_http_api@get_user')
    http_api.handle('PATCH', 'auth/users/<uid>', _controllers.PatchUser,
                    'auth_http_api@patch_user')
    http_api.handle('GET', 'auth/users/<uid>/follows', _controllers.GetUserFollowsOrFollowers,
                    'auth_http_api@get_user_follows')
    http_api.handle('GET', 'auth/users/<uid>/followers', _controllers.GetUserFollowsOrFollowers,
                    'auth_http_api@get_user_followers')

    # Me HTTP API
    http_api.handle('GET', 'auth/me', _controllers.GetMe,
                    'auth_http_api@get_me')
    http_api.handle('PATCH', 'auth/me', _controllers.PatchMe,
                    'auth_http_api@patch_me')
    http_api.handle('GET', 'auth/me/follows>', _controllers.GetMeFollows,
                    'auth_http_api@get_me_follows')
    http_api.handle('POST', 'auth/me/follows/<uid>', _controllers.PostMeFollows,
                    'auth_http_api@post_me_follows')
    http_api.handle('DELETE', 'auth/me/follows/<uid>', _controllers.DeleteMeFollows,
                    'auth_http_api@delete_me_follows')
    http_api.handle('GET', 'auth/me/blocked_users', _controllers.GetMeBlockedUsers,
                    'auth_http_api@get_me_blocked_users')
    http_api.handle('POST', 'auth/me/blocked_users/<uid>', _controllers.PostMeBlockedUsers,
                    'auth_http_api@post_me_blocked_users')
    http_api.handle('DELETE', 'auth/me/blocked_users/<uid>', _controllers.DeleteMeBlockedUsers,
                    'auth_http_api@delete_me_blocked_users')

    http_api.on_pre_request(_eh.http_api_pre_request)