예제 #1
0
파일: gui.py 프로젝트: codeyash/juju-gui
def gui(config):
    options.update(config.registry.settings)
    # We use regex separators for the prefix and file sections of the
    # jujugui.ui route to make sure we capture *everything* before the
    # static/gui/build/app section and get the file path as one string
    # rather than several separated by "/".
    config.add_route("jujugui.ui", "/{prefix:.*}static/gui/build/app/{file:.*}")
    config.add_route("jujugui.config", "/config.js")
    config.add_route("jujugui.version", "/version")
    config.add_route("jujugui.convoy", "/{cachebuster}/combo")
    js_files = _APP_DIR + "/static/gui/build"
    headers = [("Cache-Control", "max-age=3600, public")]
    application = combo_app(js_files, additional_headers=headers)
    config.add_view(wsgiapp2(application), route_name="jujugui.convoy")
    config.add_route("jujugui.app", "/*state")
    config.include("pyramid_mako")
    config.add_renderer("prettyjson", JSON(indent=4))
    config.scan("jujugui.views")
예제 #2
0
파일: gui.py 프로젝트: rastabrane/juju-gui
def gui(config):
    options.update(config.registry.settings)
    # We use regex separators for the prefix and file sections of the
    # jujugui.ui route to make sure we capture *everything* before the
    # juju-ui section and get the file path as one string rather than
    # several separated by "/".
    config.add_route('jujugui.ui', '/{prefix:.*}juju-ui/{file:.*}')
    config.add_route('jujugui.config', '/config.js')
    config.add_route('jujugui.version', '/version')
    config.add_route('jujugui.convoy', '/{cachebuster}/combo')
    js_files = _APP_DIR + '/static/gui/build'
    headers = [('Cache-Control', 'max-age=3600, public')]
    application = combo_app(js_files, additional_headers=headers)
    config.add_view(wsgiapp2(application), route_name='jujugui.convoy')
    config.add_route('jujugui.app', '/*state')
    config.include('pyramid_mako')
    config.add_renderer('prettyjson', JSON(indent=4))
    config.scan('jujugui.views')
예제 #3
0
def build_routes(config):
    """Add any routes to the config"""

    config.add_route("home", "/")
    config.add_route("dashboard", "/dashboard")

    # Add routes for the combo loader to match up to static file requests.
    config.add_route('convoy', '/combo')

    JS_FILES = config.get_settings()['app_root'] + '/bookie/static/js/build'
    application = combo_app(JS_FILES)
    config.add_view(
        wsgiapp2(application),
        route_name='convoy')

    # auth routes
    config.add_route("login", "login")
    config.add_route("logout", "logout")
    config.add_route("reset", "{username}/reset/{reset_key}")
    config.add_route("signup", "signup")
    config.add_route("signup_process", "signup_process")

    # celery routes
    config.add_route("celery_hourly_stats", "jobhourly")

    # bmark routes
    config.add_route("bmark_recent", "recent")
    config.add_route("bmark_recent_tags", "recent/*tags")

    config.add_route("bmark_recent_rss", "rss")
    config.add_route("bmark_recent_rss_tags", "rss/*tags")

    config.add_route("bmark_readable", "bmark/readable/{hash_id}")

    # user based bmark routes
    config.add_route("user_bmark_recent", "{username}/recent")
    config.add_route("user_bmark_recent_tags", "{username}/recent/*tags")

    config.add_route("user_bmark_rss", "{username}/rss")
    config.add_route("user_bmark_rss_tags", "{username}/rss/*tags")

    config.add_route("user_bmark_edit", "{username}/edit/{hash_id}")
    config.add_route("user_bmark_edit_error",
                     "{username}/edit_error/{hash_id}")
    config.add_route("user_bmark_new", "{username}/new")
    config.add_route("user_bmark_new_error", "{username}/new_error")

    # config.add_route("bmark_delete", "/bmark/delete")
    # config.add_route("bmark_confirm_delete", "/bmark/confirm/delete/{bid}")

    # tag related routes
    config.add_route("tag_list", "tags")
    config.add_route("tag_bmarks", "tags/*tags")

    # user tag related
    config.add_route("user_tag_list", "{username}/tags")
    config.add_route("user_tag_bmarks", "{username}/tags/*tags")

    config.add_route("user_import", "{username}/import")
    config.add_route("search", "search")
    config.add_route("user_search", "{username}/search")

    config.add_route("search_results", "results")
    config.add_route("user_search_results", "{username}/results")

    # matches based on the header
    # HTTP_X_REQUESTED_WITH
    # ajax versions are used in the mobile search interface
    config.add_route("search_results_ajax", "results/*terms", xhr=True)
    config.add_route("search_results_rest", "results/*terms")
    config.add_route("user_search_results_ajax",
                     "{username}/results*terms",
                     xhr=True)
    config.add_route("user_search_results_rest", "{username}/results*terms")

    config.add_route("redirect", "redirect/{hash_id}")
    config.add_route("user_redirect", "{username}/redirect/{hash_id}")

    config.add_route("user_account", "{username}/account")
    config.add_route("user_export", "{username}/export")

    #
    # NEW API
    #

    # ping checks
    config.add_route('api_ping',
                     '/api/v1/{username}/ping',
                     request_method='GET')
    config.add_route('api_ping_missing_user',
                     '/api/v1/ping',
                     request_method='GET')
    config.add_route('api_ping_missing_api',
                     '/ping',
                     request_method='GET')

    # auth related
    config.add_route("api_user_account",
                     "/api/v1/{username}/account",
                     request_method="GET")
    config.add_route("api_user_account_update",
                     "/api/v1/{username}/account",
                     request_method="POST")
    config.add_route("api_user_api_key",
                     "/api/v1/{username}/api_key")
    config.add_route("api_user_reset_password",
                     "/api/v1/{username}/password",
                     request_method="POST")

    config.add_route("api_user_suspend_remove",
                     "api/v1/suspend",
                     request_method="DELETE")
    config.add_route("api_user_suspend",
                     "api/v1/suspend",
                     request_method="POST")
    config.add_route("api_user_invite",
                     "api/v1/{username}/invite",
                     request_method="POST")

    # many bookmark api calls
    config.add_route("api_bmarks_export", "api/v1/{username}/bmarks/export")

    # we have to search before we hit the bmarks keys so that it doesn't think
    # the tag is "search"
    config.add_route("api_bmark_search", "api/v1/bmarks/search/*terms")
    config.add_route("api_bmark_search_user",
                     "/api/v1/{username}/bmarks/search/*terms")

    config.add_route('api_bmarks', 'api/v1/bmarks')
    config.add_route('api_bmarks_tags', 'api/v1/bmarks/*tags')
    config.add_route('api_bmarks_user', 'api/v1/{username}/bmarks')
    config.add_route('api_bmarks_user_tags', 'api/v1/{username}/bmarks/*tags')

    config.add_route('api_bmarks_popular', 'api/v1/bmarks/popular')
    config.add_route('api_bmarks_popular_user',
                     'api/v1/{username}/bmarks/popular')

    # user bookmark api calls
    config.add_route("api_bmark_add",
                     "/api/v1/{username}/bmark",
                     request_method="POST")
    config.add_route("api_bmark_update",
                     "/api/v1/{username}/bmark/{hash_id}",
                     request_method="POST")
    config.add_route("api_extension_sync", "/api/v1/{username}/extension/sync")

    config.add_route("api_bmark_hash",
                     "/api/v1/{username}/bmark/{hash_id}",
                     request_method="GET")
    config.add_route("api_bmark_remove",
                     "/api/v1/{username}/bmark/{hash_id}",
                     request_method="DELETE")

    config.add_route("api_tag_complete_user",
                     "/api/v1/{username}/tags/complete")
    config.add_route("api_tag_complete",
                     "/api/v1/tags/complete")

    # admin api calls
    config.add_route("api_admin_readable_todo", "/api/v1/a/readable/todo")
    config.add_route(
        "api_admin_readable_reindex",
        "/api/v1/a/readable/reindex")
    config.add_route(
        "api_admin_accounts_inactive",
        "/api/v1/a/accounts/inactive")
    config.add_route(
        "api_admin_accounts_invites_add",
        "/api/v1/a/accounts/invites/{username}/{count}",
        request_method="POST")
    config.add_route(
        "api_admin_accounts_invites",
        "/api/v1/a/accounts/invites",
        request_method="GET")
    config.add_route(
        "api_admin_imports_list",
        "/api/v1/a/imports/list",
        request_method="GET")
    config.add_route(
        "api_admin_imports_reset",
        "/api/v1/a/imports/reset/{id}",
        request_method="POST")

    config.add_route(
        "api_admin_users_list",
        "/api/v1/a/users/list",
        request_method="GET")
    config.add_route(
        "api_admin_new_user",
        "/api/v1/a/users/add",
        request_method="POST")
    config.add_route(
        "api_admin_del_user",
        "/api/v1/a/users/delete/{username}",
        request_method="DELETE")
    config.add_route(
        "api_admin_bmark_remove",
        "/api/v1/a/bmark/{username}/{hash_id}",
        request_method="DELETE")

    config.add_route(
        "api_admin_applog",
        "/api/v1/a/applog/list",
        request_method="GET")

    # these are single word matching, they must be after /recent /popular etc
    config.add_route("user_home", "{username}")

    return config
예제 #4
0
파일: combo.py 프로젝트: xuanhan863/Bookie
"""WSGI file to serve the combo JS out of convoy"""
import os
from convoy.combo import combo_app

root_dir = os.path.dirname(__file__)
JS_FILES = root_dir + '/bookie/static/js/build'
application = combo_app(JS_FILES)