routing.py
844 lines
| 41.1 KiB
| text/x-python
|
PythonLexer
Bradley M. Kuhn
|
r4116 | # -*- coding: utf-8 -*- | ||
# This program is free software: you can redistribute it and/or modify | ||||
# it under the terms of the GNU General Public License as published by | ||||
# the Free Software Foundation, either version 3 of the License, or | ||||
# (at your option) any later version. | ||||
# | ||||
# This program is distributed in the hope that it will be useful, | ||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
# GNU General Public License for more details. | ||||
# | ||||
# You should have received a copy of the GNU General Public License | ||||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||
r604 | """ | |||
Routes configuration | ||||
r547 | ||||
The more specific and detailed routes should be defined first so they | ||||
may take precedent over the more generic routes. For more information | ||||
refer to the routes manual at http://routes.groovie.org/docs/ | ||||
""" | ||||
Bradley M. Kuhn
|
r4116 | |||
r547 | from __future__ import with_statement | |||
from routes import Mapper | ||||
r1505 | ||||
r1333 | # prefix for non repository related links needs to be prefixed with `/` | |||
ADMIN_PREFIX = '/_admin' | ||||
r1205 | ||||
r547 | def make_map(config): | |||
"""Create, configure and return the routes Mapper""" | ||||
r1211 | rmap = Mapper(directory=config['pylons.paths']['controllers'], | |||
Bradley M. Kuhn
|
r4116 | always_scan=config['debug']) | ||
r1211 | rmap.minimization = False | |||
rmap.explicit = False | ||||
r1538 | ||||
Bradley M. Kuhn
|
r4116 | from rhodecode.lib.utils import (is_valid_repo, is_valid_repo_group, | ||
get_repo_by_id) | ||||
r1538 | ||||
r604 | def check_repo(environ, match_dict): | |||
""" | ||||
check for valid repository for proper 404 handling | ||||
r1791 | ||||
r604 | :param environ: | |||
:param match_dict: | ||||
""" | ||||
r1813 | repo_name = match_dict.get('repo_name') | |||
r1538 | ||||
r3040 | if match_dict.get('f_path'): | |||
#fix for multiple initial slashes that causes errors | ||||
match_dict['f_path'] = match_dict['f_path'].lstrip('/') | ||||
Bradley M. Kuhn
|
r4116 | by_id_match = get_repo_by_id(repo_name) | ||
if by_id_match: | ||||
repo_name = by_id_match | ||||
match_dict['repo_name'] = repo_name | ||||
r1813 | ||||
r1507 | return is_valid_repo(repo_name, config['base_path']) | |||
r1505 | ||||
def check_group(environ, match_dict): | ||||
""" | ||||
Mads Kiilerich
|
r3416 | check for valid repository group for proper 404 handling | ||
r1791 | ||||
r1505 | :param environ: | |||
:param match_dict: | ||||
""" | ||||
Bradley M. Kuhn
|
r4116 | repo_group_name = match_dict.get('group_name') | ||
return is_valid_repo_group(repo_group_name, config['base_path']) | ||||
r604 | ||||
r3458 | def check_group_skip_path(environ, match_dict): | |||
""" | ||||
check for valid repository group for proper 404 handling, but skips | ||||
verification of existing path | ||||
:param environ: | ||||
:param match_dict: | ||||
""" | ||||
Bradley M. Kuhn
|
r4116 | repo_group_name = match_dict.get('group_name') | ||
return is_valid_repo_group(repo_group_name, config['base_path'], | ||||
skip_path_check=True) | ||||
r3458 | ||||
r3734 | def check_user_group(environ, match_dict): | |||
""" | ||||
check for valid user group for proper 404 handling | ||||
:param environ: | ||||
:param match_dict: | ||||
""" | ||||
return True | ||||
r1348 | def check_int(environ, match_dict): | |||
return match_dict.get('id').isdigit() | ||||
r547 | # The ErrorController route (handles 404/500 error pages); it should | |||
# likely stay at the top, ensuring it can always be resolved | ||||
r1211 | rmap.connect('/error/{action}', controller='error') | |||
rmap.connect('/error/{action}/{id}', controller='error') | ||||
r547 | ||||
r604 | #========================================================================== | |||
r547 | # CUSTOM ROUTES HERE | |||
r604 | #========================================================================== | |||
#MAIN PAGE | ||||
r1211 | rmap.connect('home', '/', controller='home', action='index') | |||
Bradley M. Kuhn
|
r4116 | rmap.connect('repo_switcher_data', '/_repos', controller='home', | ||
action='repo_switcher_data') | ||||
r1680 | rmap.connect('rst_help', | |||
"http://docutils.sourceforge.net/docs/user/rst/quickref.html", | ||||
_static=True) | ||||
Bradley M. Kuhn
|
r4116 | rmap.connect('rhodecode_official', "https://rhodecode.com", _static=True) | ||
rmap.connect('rc_issue_tracker', 'https://rhodecode.com/help/', _static=True) | ||||
r1143 | ||||
Bradley M. Kuhn
|
r4116 | #ADMIN REPOSITORY ROUTES | ||
r1333 | with rmap.submapper(path_prefix=ADMIN_PREFIX, | |||
controller='admin/repos') as m: | ||||
r547 | m.connect("repos", "/repos", | |||
Bradley M. Kuhn
|
r4116 | action="create", conditions=dict(method=["POST"])) | ||
r547 | m.connect("repos", "/repos", | |||
Bradley M. Kuhn
|
r4116 | action="index", conditions=dict(method=["GET"])) | ||
r3659 | m.connect("new_repo", "/create_repository", | |||
r3629 | action="create_repository", conditions=dict(method=["GET"])) | |||
r2692 | m.connect("/repos/{repo_name:.*?}", | |||
Bradley M. Kuhn
|
r4116 | action="update", conditions=dict(method=["PUT"], | ||
function=check_repo)) | ||||
m.connect("delete_repo", "/repos/{repo_name:.*?}", | ||||
action="delete", conditions=dict(method=["DELETE"], | ||||
)) | ||||
r2692 | m.connect("repo", "/repos/{repo_name:.*?}", | |||
Bradley M. Kuhn
|
r4116 | action="show", conditions=dict(method=["GET"], | ||
function=check_repo)) | ||||
r1015 | ||||
Bradley M. Kuhn
|
r4116 | #ADMIN REPOSITORY GROUPS ROUTES | ||
r1348 | with rmap.submapper(path_prefix=ADMIN_PREFIX, | |||
Bradley M. Kuhn
|
r4116 | controller='admin/repo_groups') as m: | ||
m.connect("repos_groups", "/repo_groups", | ||||
r1348 | action="create", conditions=dict(method=["POST"])) | |||
Bradley M. Kuhn
|
r4116 | m.connect("repos_groups", "/repo_groups", | ||
r1348 | action="index", conditions=dict(method=["GET"])) | |||
Bradley M. Kuhn
|
r4116 | m.connect("new_repos_group", "/repo_groups/new", | ||
r1348 | action="new", conditions=dict(method=["GET"])) | |||
Bradley M. Kuhn
|
r4116 | m.connect("update_repos_group", "/repo_groups/{group_name:.*?}", | ||
r1348 | action="update", conditions=dict(method=["PUT"], | |||
r3222 | function=check_group)) | |||
r3715 | ||||
Bradley M. Kuhn
|
r4116 | m.connect("repos_group", "/repo_groups/{group_name:.*?}", | ||
r1348 | action="show", conditions=dict(method=["GET"], | |||
r3222 | function=check_group)) | |||
r3714 | ||||
Bradley M. Kuhn
|
r4116 | #EXTRAS REPO GROUP ROUTES | ||
m.connect("edit_repo_group", "/repo_groups/{group_name:.*?}/edit", | ||||
action="edit", | ||||
conditions=dict(method=["GET"], function=check_group)) | ||||
m.connect("edit_repo_group", "/repo_groups/{group_name:.*?}/edit", | ||||
action="edit", | ||||
conditions=dict(method=["PUT"], function=check_group)) | ||||
m.connect("edit_repo_group_advanced", "/repo_groups/{group_name:.*?}/edit/advanced", | ||||
action="edit_repo_group_advanced", | ||||
conditions=dict(method=["GET"], function=check_group)) | ||||
m.connect("edit_repo_group_advanced", "/repo_groups/{group_name:.*?}/edit/advanced", | ||||
action="edit_repo_group_advanced", | ||||
conditions=dict(method=["PUT"], function=check_group)) | ||||
m.connect("edit_repo_group_perms", "/repo_groups/{group_name:.*?}/edit/permissions", | ||||
action="edit_repo_group_perms", | ||||
conditions=dict(method=["GET"], function=check_group)) | ||||
m.connect("edit_repo_group_perms", "/repo_groups/{group_name:.*?}/edit/permissions", | ||||
action="update_perms", | ||||
conditions=dict(method=["PUT"], function=check_group)) | ||||
m.connect("edit_repo_group_perms", "/repo_groups/{group_name:.*?}/edit/permissions", | ||||
action="delete_perms", | ||||
conditions=dict(method=["DELETE"], function=check_group)) | ||||
m.connect("delete_repos_group", "/repo_groups/{group_name:.*?}", | ||||
action="delete", conditions=dict(method=["DELETE"], | ||||
function=check_group_skip_path)) | ||||
#ADMIN USER ROUTES | ||||
r1333 | with rmap.submapper(path_prefix=ADMIN_PREFIX, | |||
controller='admin/users') as m: | ||||
r1266 | m.connect("users", "/users", | |||
action="create", conditions=dict(method=["POST"])) | ||||
m.connect("users", "/users", | ||||
action="index", conditions=dict(method=["GET"])) | ||||
m.connect("formatted_users", "/users.{format}", | ||||
action="index", conditions=dict(method=["GET"])) | ||||
m.connect("new_user", "/users/new", | ||||
action="new", conditions=dict(method=["GET"])) | ||||
m.connect("update_user", "/users/{id}", | ||||
action="update", conditions=dict(method=["PUT"])) | ||||
m.connect("delete_user", "/users/{id}", | ||||
action="delete", conditions=dict(method=["DELETE"])) | ||||
m.connect("edit_user", "/users/{id}/edit", | ||||
action="edit", conditions=dict(method=["GET"])) | ||||
m.connect("user", "/users/{id}", | ||||
action="show", conditions=dict(method=["GET"])) | ||||
#EXTRAS USER ROUTES | ||||
Bradley M. Kuhn
|
r4116 | m.connect("edit_user_advanced", "/users/{id}/edit/advanced", | ||
action="edit_advanced", conditions=dict(method=["GET"])) | ||||
m.connect("edit_user_advanced", "/users/{id}/edit/advanced", | ||||
action="update_advanced", conditions=dict(method=["PUT"])) | ||||
m.connect("edit_user_api_keys", "/users/{id}/edit/api_keys", | ||||
action="edit_api_keys", conditions=dict(method=["GET"])) | ||||
m.connect("edit_user_api_keys", "/users/{id}/edit/api_keys", | ||||
action="add_api_key", conditions=dict(method=["PUT"])) | ||||
m.connect("edit_user_api_keys", "/users/{id}/edit/api_keys", | ||||
action="delete_api_key", conditions=dict(method=["DELETE"])) | ||||
m.connect("edit_user_perms", "/users/{id}/edit/permissions", | ||||
action="edit_perms", conditions=dict(method=["GET"])) | ||||
m.connect("edit_user_perms", "/users/{id}/edit/permissions", | ||||
action="update_perms", conditions=dict(method=["PUT"])) | ||||
m.connect("edit_user_emails", "/users/{id}/edit/emails", | ||||
action="edit_emails", conditions=dict(method=["GET"])) | ||||
m.connect("edit_user_emails", "/users/{id}/edit/emails", | ||||
r2330 | action="add_email", conditions=dict(method=["PUT"])) | |||
Bradley M. Kuhn
|
r4116 | m.connect("edit_user_emails", "/users/{id}/edit/emails", | ||
r2330 | action="delete_email", conditions=dict(method=["DELETE"])) | |||
Bradley M. Kuhn
|
r4116 | |||
m.connect("edit_user_ips", "/users/{id}/edit/ips", | ||||
action="edit_ips", conditions=dict(method=["GET"])) | ||||
m.connect("edit_user_ips", "/users/{id}/edit/ips", | ||||
r3125 | action="add_ip", conditions=dict(method=["PUT"])) | |||
Bradley M. Kuhn
|
r4116 | m.connect("edit_user_ips", "/users/{id}/edit/ips", | ||
r3125 | action="delete_ip", conditions=dict(method=["DELETE"])) | |||
r959 | ||||
Mads Kiilerich
|
r3410 | #ADMIN USER GROUPS REST ROUTES | ||
r1333 | with rmap.submapper(path_prefix=ADMIN_PREFIX, | |||
Bradley M. Kuhn
|
r4116 | controller='admin/user_groups') as m: | ||
m.connect("users_groups", "/user_groups", | ||||
r1271 | action="create", conditions=dict(method=["POST"])) | |||
Bradley M. Kuhn
|
r4116 | m.connect("users_groups", "/user_groups", | ||
r1271 | action="index", conditions=dict(method=["GET"])) | |||
Bradley M. Kuhn
|
r4116 | m.connect("new_users_group", "/user_groups/new", | ||
r1271 | action="new", conditions=dict(method=["GET"])) | |||
Bradley M. Kuhn
|
r4116 | m.connect("update_users_group", "/user_groups/{id}", | ||
r1271 | action="update", conditions=dict(method=["PUT"])) | |||
Bradley M. Kuhn
|
r4116 | m.connect("delete_users_group", "/user_groups/{id}", | ||
r1271 | action="delete", conditions=dict(method=["DELETE"])) | |||
Bradley M. Kuhn
|
r4116 | m.connect("edit_users_group", "/user_groups/{id}/edit", | ||
r3734 | action="edit", conditions=dict(method=["GET"]), | |||
function=check_user_group) | ||||
Bradley M. Kuhn
|
r4116 | m.connect("users_group", "/user_groups/{id}", | ||
r1271 | action="show", conditions=dict(method=["GET"])) | |||
Bradley M. Kuhn
|
r4116 | #EXTRAS USER GROUP ROUTES | ||
m.connect("edit_user_group_default_perms", "/user_groups/{id}/edit/default_perms", | ||||
action="edit_default_perms", conditions=dict(method=["GET"])) | ||||
m.connect("edit_user_group_default_perms", "/user_groups/{id}/edit/default_perms", | ||||
action="update_default_perms", conditions=dict(method=["PUT"])) | ||||
r956 | ||||
Bradley M. Kuhn
|
r4116 | m.connect("edit_user_group_perms", "/user_groups/{id}/edit/perms", | ||
action="edit_perms", conditions=dict(method=["GET"])) | ||||
m.connect("edit_user_group_perms", "/user_groups/{id}/edit/perms", | ||||
action="update_perms", conditions=dict(method=["PUT"])) | ||||
m.connect("edit_user_group_perms", "/user_groups/{id}/edit/perms", | ||||
action="delete_perms", conditions=dict(method=["DELETE"])) | ||||
m.connect("edit_user_group_advanced", "/user_groups/{id}/edit/advanced", | ||||
action="edit_advanced", conditions=dict(method=["GET"])) | ||||
m.connect("edit_user_group_members", "/user_groups/{id}/edit/members", | ||||
action="edit_members", conditions=dict(method=["GET"])) | ||||
r3714 | ||||
Bradley M. Kuhn
|
r4116 | |||
#ADMIN PERMISSIONS ROUTES | ||||
with rmap.submapper(path_prefix=ADMIN_PREFIX, | ||||
controller='admin/permissions') as m: | ||||
m.connect("admin_permissions", "/permissions", | ||||
action="permission_globals", conditions=dict(method=["POST"])) | ||||
m.connect("admin_permissions", "/permissions", | ||||
action="permission_globals", conditions=dict(method=["GET"])) | ||||
r3714 | ||||
Bradley M. Kuhn
|
r4116 | m.connect("admin_permissions_ips", "/permissions/ips", | ||
action="permission_ips", conditions=dict(method=["POST"])) | ||||
m.connect("admin_permissions_ips", "/permissions/ips", | ||||
action="permission_ips", conditions=dict(method=["GET"])) | ||||
r604 | ||||
Bradley M. Kuhn
|
r4116 | m.connect("admin_permissions_perms", "/permissions/perms", | ||
action="permission_perms", conditions=dict(method=["POST"])) | ||||
m.connect("admin_permissions_perms", "/permissions/perms", | ||||
action="permission_perms", conditions=dict(method=["GET"])) | ||||
r769 | ||||
r3056 | #ADMIN DEFAULTS REST ROUTES | |||
rmap.resource('default', 'defaults', | ||||
controller='admin/defaults', path_prefix=ADMIN_PREFIX) | ||||
Bradley M. Kuhn
|
r4116 | #ADMIN AUTH SETTINGS | ||
rmap.connect('auth_settings', '%s/auth' % ADMIN_PREFIX, | ||||
controller='admin/auth_settings', action='auth_settings', | ||||
r1211 | conditions=dict(method=["POST"])) | |||
Bradley M. Kuhn
|
r4116 | rmap.connect('auth_home', '%s/auth' % ADMIN_PREFIX, | ||
controller='admin/auth_settings') | ||||
r1266 | ||||
Bradley M. Kuhn
|
r4116 | #ADMIN SETTINGS ROUTES | ||
r1333 | with rmap.submapper(path_prefix=ADMIN_PREFIX, | |||
r1211 | controller='admin/settings') as m: | |||
r547 | m.connect("admin_settings", "/settings", | |||
Bradley M. Kuhn
|
r4116 | action="settings_vcs", conditions=dict(method=["POST"])) | ||
r547 | m.connect("admin_settings", "/settings", | |||
Bradley M. Kuhn
|
r4116 | action="settings_vcs", conditions=dict(method=["GET"])) | ||
m.connect("admin_settings_mapping", "/settings/mapping", | ||||
action="settings_mapping", conditions=dict(method=["POST"])) | ||||
m.connect("admin_settings_mapping", "/settings/mapping", | ||||
action="settings_mapping", conditions=dict(method=["GET"])) | ||||
m.connect("admin_settings_global", "/settings/global", | ||||
action="settings_global", conditions=dict(method=["POST"])) | ||||
m.connect("admin_settings_global", "/settings/global", | ||||
action="settings_global", conditions=dict(method=["GET"])) | ||||
m.connect("admin_settings_visual", "/settings/visual", | ||||
action="settings_visual", conditions=dict(method=["POST"])) | ||||
m.connect("admin_settings_visual", "/settings/visual", | ||||
action="settings_visual", conditions=dict(method=["GET"])) | ||||
m.connect("admin_settings_email", "/settings/email", | ||||
action="settings_email", conditions=dict(method=["POST"])) | ||||
m.connect("admin_settings_email", "/settings/email", | ||||
action="settings_email", conditions=dict(method=["GET"])) | ||||
m.connect("admin_settings_hooks", "/settings/hooks", | ||||
action="settings_hooks", conditions=dict(method=["POST"])) | ||||
m.connect("admin_settings_hooks", "/settings/hooks", | ||||
action="settings_hooks", conditions=dict(method=["DELETE"])) | ||||
m.connect("admin_settings_hooks", "/settings/hooks", | ||||
action="settings_hooks", conditions=dict(method=["GET"])) | ||||
m.connect("admin_settings_search", "/settings/search", | ||||
action="settings_search", conditions=dict(method=["POST"])) | ||||
m.connect("admin_settings_search", "/settings/search", | ||||
action="settings_search", conditions=dict(method=["GET"])) | ||||
m.connect("admin_settings_system", "/settings/system", | ||||
action="settings_system", conditions=dict(method=["POST"])) | ||||
m.connect("admin_settings_system", "/settings/system", | ||||
action="settings_system", conditions=dict(method=["GET"])) | ||||
m.connect("admin_settings_system_update", "/settings/system/updates", | ||||
action="settings_system_update", conditions=dict(method=["GET"])) | ||||
m.connect("admin_settings_license", "/settings/license", | ||||
action="settings_license", conditions=dict(method=["POST"])) | ||||
m.connect("admin_settings_license", "/settings/license", | ||||
action="settings_license", conditions=dict(method=["GET"])) | ||||
#ADMIN MY ACCOUNT | ||||
with rmap.submapper(path_prefix=ADMIN_PREFIX, | ||||
controller='admin/my_account') as m: | ||||
m.connect("my_account", "/my_account", | ||||
r1211 | action="my_account", conditions=dict(method=["GET"])) | |||
Bradley M. Kuhn
|
r4116 | m.connect("my_account", "/my_account", | ||
action="my_account", conditions=dict(method=["POST"])) | ||||
m.connect("my_account_password", "/my_account/password", | ||||
action="my_account_password", conditions=dict(method=["GET"])) | ||||
m.connect("my_account_password", "/my_account/password", | ||||
action="my_account_password", conditions=dict(method=["POST"])) | ||||
m.connect("my_account_repos", "/my_account/repos", | ||||
action="my_account_repos", conditions=dict(method=["GET"])) | ||||
m.connect("my_account_watched", "/my_account/watched", | ||||
action="my_account_watched", conditions=dict(method=["GET"])) | ||||
m.connect("my_account_pullrequests", "/my_account/pull_requests", | ||||
action="my_account_pullrequests", conditions=dict(method=["GET"])) | ||||
m.connect("my_account_perms", "/my_account/perms", | ||||
action="my_account_perms", conditions=dict(method=["GET"])) | ||||
m.connect("my_account_emails", "/my_account/emails", | ||||
action="my_account_emails", conditions=dict(method=["GET"])) | ||||
m.connect("my_account_emails", "/my_account/emails", | ||||
action="my_account_emails_add", conditions=dict(method=["POST"])) | ||||
m.connect("my_account_emails", "/my_account/emails", | ||||
action="my_account_emails_delete", conditions=dict(method=["DELETE"])) | ||||
m.connect("my_account_api_keys", "/my_account/api_keys", | ||||
action="my_account_api_keys", conditions=dict(method=["GET"])) | ||||
m.connect("my_account_api_keys", "/my_account/api_keys", | ||||
action="my_account_api_keys_add", conditions=dict(method=["POST"])) | ||||
m.connect("my_account_api_keys", "/my_account/api_keys", | ||||
action="my_account_api_keys_delete", conditions=dict(method=["DELETE"])) | ||||
r2624 | ||||
r1712 | #NOTIFICATION REST ROUTES | |||
with rmap.submapper(path_prefix=ADMIN_PREFIX, | ||||
controller='admin/notifications') as m: | ||||
m.connect("notifications", "/notifications", | ||||
action="create", conditions=dict(method=["POST"])) | ||||
m.connect("notifications", "/notifications", | ||||
action="index", conditions=dict(method=["GET"])) | ||||
r1791 | m.connect("notifications_mark_all_read", "/notifications/mark_all_read", | |||
action="mark_all_read", conditions=dict(method=["GET"])) | ||||
r1712 | m.connect("formatted_notifications", "/notifications.{format}", | |||
action="index", conditions=dict(method=["GET"])) | ||||
m.connect("new_notification", "/notifications/new", | ||||
action="new", conditions=dict(method=["GET"])) | ||||
m.connect("formatted_new_notification", "/notifications/new.{format}", | ||||
action="new", conditions=dict(method=["GET"])) | ||||
r3882 | m.connect("/notifications/{notification_id}", | |||
r1712 | action="update", conditions=dict(method=["PUT"])) | |||
r3882 | m.connect("/notifications/{notification_id}", | |||
r1712 | action="delete", conditions=dict(method=["DELETE"])) | |||
r3882 | m.connect("edit_notification", "/notifications/{notification_id}/edit", | |||
r1712 | action="edit", conditions=dict(method=["GET"])) | |||
m.connect("formatted_edit_notification", | ||||
r3882 | "/notifications/{notification_id}.{format}/edit", | |||
r1712 | action="edit", conditions=dict(method=["GET"])) | |||
r3882 | m.connect("notification", "/notifications/{notification_id}", | |||
r1712 | action="show", conditions=dict(method=["GET"])) | |||
r3882 | m.connect("formatted_notification", "/notifications/{notification_id}.{format}", | |||
r1712 | action="show", conditions=dict(method=["GET"])) | |||
r3866 | #ADMIN GIST | |||
with rmap.submapper(path_prefix=ADMIN_PREFIX, | ||||
controller='admin/gists') as m: | ||||
m.connect("gists", "/gists", | ||||
action="create", conditions=dict(method=["POST"])) | ||||
m.connect("gists", "/gists", | ||||
action="index", conditions=dict(method=["GET"])) | ||||
m.connect("new_gist", "/gists/new", | ||||
action="new", conditions=dict(method=["GET"])) | ||||
Bradley M. Kuhn
|
r4116 | |||
r3882 | m.connect("/gists/{gist_id}", | |||
r3866 | action="update", conditions=dict(method=["PUT"])) | |||
r3882 | m.connect("/gists/{gist_id}", | |||
r3866 | action="delete", conditions=dict(method=["DELETE"])) | |||
r3882 | m.connect("edit_gist", "/gists/{gist_id}/edit", | |||
Bradley M. Kuhn
|
r4116 | action="edit", conditions=dict(method=["GET", "POST"])) | ||
m.connect("edit_gist_check_revision", "/gists/{gist_id}/edit/check_revision", | ||||
action="check_revision", conditions=dict(method=["POST"])) | ||||
r3882 | m.connect("gist", "/gists/{gist_id}", | |||
r3866 | action="show", conditions=dict(method=["GET"])) | |||
Bradley M. Kuhn
|
r4116 | m.connect("gist_rev", "/gists/{gist_id}/{revision}", | ||
revision="tip", | ||||
r3867 | action="show", conditions=dict(method=["GET"])) | |||
Bradley M. Kuhn
|
r4116 | m.connect("formatted_gist", "/gists/{gist_id}/{revision}/{format}", | ||
revision="tip", | ||||
action="show", conditions=dict(method=["GET"])) | ||||
m.connect("formatted_gist_file", "/gists/{gist_id}/{revision}/{format}/{f_path:.*}", | ||||
revision='tip', | ||||
r3866 | action="show", conditions=dict(method=["GET"])) | |||
r604 | #ADMIN MAIN PAGES | |||
r1333 | with rmap.submapper(path_prefix=ADMIN_PREFIX, | |||
controller='admin/admin') as m: | ||||
r1211 | m.connect('admin_home', '', action='index') | |||
r547 | m.connect('admin_add_repo', '/add_repo/{new_repo:[a-z0-9\. _-]*}', | |||
action='add_repo') | ||||
r1445 | #========================================================================== | |||
r1982 | # API V2 | |||
r1445 | #========================================================================== | |||
with rmap.submapper(path_prefix=ADMIN_PREFIX, | ||||
controller='api/api') as m: | ||||
m.connect('api', '/api') | ||||
r1211 | #USER JOURNAL | |||
r2397 | rmap.connect('journal', '%s/journal' % ADMIN_PREFIX, | |||
controller='journal', action='index') | ||||
rmap.connect('journal_rss', '%s/journal/rss' % ADMIN_PREFIX, | ||||
controller='journal', action='journal_rss') | ||||
rmap.connect('journal_atom', '%s/journal/atom' % ADMIN_PREFIX, | ||||
controller='journal', action='journal_atom') | ||||
r734 | ||||
r1333 | rmap.connect('public_journal', '%s/public_journal' % ADMIN_PREFIX, | |||
r1211 | controller='journal', action="public_journal") | |||
r2390 | rmap.connect('public_journal_rss', '%s/public_journal/rss' % ADMIN_PREFIX, | |||
controller='journal', action="public_journal_rss") | ||||
rmap.connect('public_journal_rss_old', '%s/public_journal_rss' % ADMIN_PREFIX, | ||||
r1211 | controller='journal', action="public_journal_rss") | |||
r1088 | ||||
r1333 | rmap.connect('public_journal_atom', | |||
r2390 | '%s/public_journal/atom' % ADMIN_PREFIX, controller='journal', | |||
action="public_journal_atom") | ||||
rmap.connect('public_journal_atom_old', | ||||
r1333 | '%s/public_journal_atom' % ADMIN_PREFIX, controller='journal', | |||
action="public_journal_atom") | ||||
r734 | ||||
r1333 | rmap.connect('toggle_following', '%s/toggle_following' % ADMIN_PREFIX, | |||
r1211 | controller='journal', action='toggle_following', | |||
conditions=dict(method=["POST"])) | ||||
r734 | ||||
r547 | #SEARCH | |||
r1333 | rmap.connect('search', '%s/search' % ADMIN_PREFIX, controller='search',) | |||
Mads Kiilerich
|
r3289 | rmap.connect('search_repo_admin', '%s/search/{repo_name:.*}' % ADMIN_PREFIX, | ||
r3298 | controller='search', | |||
conditions=dict(function=check_repo)) | ||||
Mads Kiilerich
|
r3289 | rmap.connect('search_repo', '/{repo_name:.*?}/search', | ||
controller='search', | ||||
conditions=dict(function=check_repo), | ||||
) | ||||
r604 | ||||
r547 | #LOGIN/LOGOUT/REGISTER/SIGN IN | |||
r1333 | rmap.connect('login_home', '%s/login' % ADMIN_PREFIX, controller='login') | |||
rmap.connect('logout_home', '%s/logout' % ADMIN_PREFIX, controller='login', | ||||
r1211 | action='logout') | |||
r1333 | rmap.connect('register', '%s/register' % ADMIN_PREFIX, controller='login', | |||
r1211 | action='register') | |||
r1333 | rmap.connect('reset_password', '%s/password_reset' % ADMIN_PREFIX, | |||
r1211 | controller='login', action='password_reset') | |||
r604 | ||||
r1417 | rmap.connect('reset_password_confirmation', | |||
'%s/password_reset_confirmation' % ADMIN_PREFIX, | ||||
controller='login', action='password_reset_confirmation') | ||||
r547 | #FEEDS | |||
r2692 | rmap.connect('rss_feed_home', '/{repo_name:.*?}/feed/rss', | |||
r547 | controller='feed', action='rss', | |||
conditions=dict(function=check_repo)) | ||||
r1211 | ||||
r2692 | rmap.connect('atom_feed_home', '/{repo_name:.*?}/feed/atom', | |||
r547 | controller='feed', action='atom', | |||
conditions=dict(function=check_repo)) | ||||
r604 | ||||
r1279 | #========================================================================== | |||
# REPOSITORY ROUTES | ||||
#========================================================================== | ||||
Bradley M. Kuhn
|
r4116 | rmap.connect('repo_creating_home', '/{repo_name:.*?}/repo_creating', | ||
controller='admin/repos', action='repo_creating') | ||||
rmap.connect('repo_check_home', '/{repo_name:.*?}/crepo_check', | ||||
controller='admin/repos', action='repo_check') | ||||
r2692 | rmap.connect('summary_home', '/{repo_name:.*?}', | |||
r1538 | controller='summary', | |||
r1505 | conditions=dict(function=check_repo)) | |||
r1538 | ||||
Bradley M. Kuhn
|
r4116 | # must be here for proper group/repo catching | ||
rmap.connect('repos_group_home', '/{group_name:.*}', | ||||
controller='admin/repo_groups', action="show_by_name", | ||||
conditions=dict(function=check_group)) | ||||
rmap.connect('repo_stats_home', '/{repo_name:.*?}/statistics', | ||||
controller='summary', action='statistics', | ||||
conditions=dict(function=check_repo)) | ||||
r3246 | rmap.connect('repo_size', '/{repo_name:.*?}/repo_size', | |||
controller='summary', action='repo_size', | ||||
conditions=dict(function=check_repo)) | ||||
Bradley M. Kuhn
|
r4116 | rmap.connect('branch_tag_switcher', '/{repo_name:.*?}/branches-tags', | ||
controller='home', action='branch_tag_switcher') | ||||
rmap.connect('repo_refs_data', '/{repo_name:.*?}/refs-data', | ||||
controller='home', action='repo_refs_data') | ||||
r1538 | ||||
r2692 | rmap.connect('changeset_home', '/{repo_name:.*?}/changeset/{revision}', | |||
r547 | controller='changeset', revision='tip', | |||
conditions=dict(function=check_repo)) | ||||
Bradley M. Kuhn
|
r4116 | rmap.connect('changeset_children', '/{repo_name:.*?}/changeset_children/{revision}', | ||
controller='changeset', revision='tip', action="changeset_children", | ||||
conditions=dict(function=check_repo)) | ||||
rmap.connect('changeset_parents', '/{repo_name:.*?}/changeset_parents/{revision}', | ||||
controller='changeset', revision='tip', action="changeset_parents", | ||||
conditions=dict(function=check_repo)) | ||||
r1211 | ||||
Bradley M. Kuhn
|
r4116 | # repo edit options | ||
r3629 | rmap.connect("edit_repo", "/{repo_name:.*?}/settings", | |||
Mads Kiilerich
|
r3288 | controller='admin/repos', action="edit", | ||
Bradley M. Kuhn
|
r4116 | conditions=dict(method=["GET"], function=check_repo)) | ||
rmap.connect("edit_repo_perms", "/{repo_name:.*?}/settings/permissions", | ||||
controller='admin/repos', action="edit_permissions", | ||||
conditions=dict(method=["GET"], function=check_repo)) | ||||
rmap.connect("edit_repo_perms_update", "/{repo_name:.*?}/settings/permissions", | ||||
controller='admin/repos', action="edit_permissions_update", | ||||
conditions=dict(method=["PUT"], function=check_repo)) | ||||
rmap.connect("edit_repo_perms_revoke", "/{repo_name:.*?}/settings/permissions", | ||||
controller='admin/repos', action="edit_permissions_revoke", | ||||
conditions=dict(method=["DELETE"], function=check_repo)) | ||||
rmap.connect("edit_repo_fields", "/{repo_name:.*?}/settings/fields", | ||||
controller='admin/repos', action="edit_fields", | ||||
conditions=dict(method=["GET"], function=check_repo)) | ||||
rmap.connect('create_repo_fields', "/{repo_name:.*?}/settings/fields/new", | ||||
controller='admin/repos', action="create_repo_field", | ||||
conditions=dict(method=["PUT"], function=check_repo)) | ||||
rmap.connect('delete_repo_fields', "/{repo_name:.*?}/settings/fields/{field_id}", | ||||
controller='admin/repos', action="delete_repo_field", | ||||
conditions=dict(method=["DELETE"], function=check_repo)) | ||||
rmap.connect("edit_repo_advanced", "/{repo_name:.*?}/settings/advanced", | ||||
controller='admin/repos', action="edit_advanced", | ||||
conditions=dict(method=["GET"], function=check_repo)) | ||||
rmap.connect("edit_repo_advanced_locking", "/{repo_name:.*?}/settings/advanced/locking", | ||||
controller='admin/repos', action="edit_advanced_locking", | ||||
conditions=dict(method=["PUT"], function=check_repo)) | ||||
rmap.connect('toggle_locking', "/{repo_name:.*?}/settings/advanced/locking_toggle", | ||||
controller='admin/repos', action="toggle_locking", | ||||
conditions=dict(method=["GET"], function=check_repo)) | ||||
rmap.connect("edit_repo_advanced_journal", "/{repo_name:.*?}/settings/advanced/journal", | ||||
controller='admin/repos', action="edit_advanced_journal", | ||||
conditions=dict(method=["PUT"], function=check_repo)) | ||||
rmap.connect("edit_repo_advanced_fork", "/{repo_name:.*?}/settings/advanced/fork", | ||||
controller='admin/repos', action="edit_advanced_fork", | ||||
conditions=dict(method=["PUT"], function=check_repo)) | ||||
rmap.connect("edit_repo_caches", "/{repo_name:.*?}/settings/caches", | ||||
controller='admin/repos', action="edit_caches", | ||||
conditions=dict(method=["GET"], function=check_repo)) | ||||
rmap.connect("edit_repo_caches", "/{repo_name:.*?}/settings/caches", | ||||
controller='admin/repos', action="edit_caches", | ||||
conditions=dict(method=["PUT"], function=check_repo)) | ||||
rmap.connect("edit_repo_remote", "/{repo_name:.*?}/settings/remote", | ||||
controller='admin/repos', action="edit_remote", | ||||
conditions=dict(method=["GET"], function=check_repo)) | ||||
rmap.connect("edit_repo_remote", "/{repo_name:.*?}/settings/remote", | ||||
controller='admin/repos', action="edit_remote", | ||||
conditions=dict(method=["PUT"], function=check_repo)) | ||||
rmap.connect("edit_repo_statistics", "/{repo_name:.*?}/settings/statistics", | ||||
controller='admin/repos', action="edit_statistics", | ||||
conditions=dict(method=["GET"], function=check_repo)) | ||||
rmap.connect("edit_repo_statistics", "/{repo_name:.*?}/settings/statistics", | ||||
controller='admin/repos', action="edit_statistics", | ||||
conditions=dict(method=["PUT"], function=check_repo)) | ||||
Mads Kiilerich
|
r3288 | |||
r2996 | #still working url for backward compat. | |||
rmap.connect('raw_changeset_home_depraced', | ||||
'/{repo_name:.*?}/raw-changeset/{revision}', | ||||
controller='changeset', action='changeset_raw', | ||||
revision='tip', conditions=dict(function=check_repo)) | ||||
## new URLs | ||||
rmap.connect('changeset_raw_home', | ||||
'/{repo_name:.*?}/changeset-diff/{revision}', | ||||
controller='changeset', action='changeset_raw', | ||||
revision='tip', conditions=dict(function=check_repo)) | ||||
rmap.connect('changeset_patch_home', | ||||
'/{repo_name:.*?}/changeset-patch/{revision}', | ||||
controller='changeset', action='changeset_patch', | ||||
revision='tip', conditions=dict(function=check_repo)) | ||||
rmap.connect('changeset_download_home', | ||||
'/{repo_name:.*?}/changeset-download/{revision}', | ||||
controller='changeset', action='changeset_download', | ||||
revision='tip', conditions=dict(function=check_repo)) | ||||
r1982 | rmap.connect('changeset_comment', | |||
r2692 | '/{repo_name:.*?}/changeset/{revision}/comment', | |||
r1670 | controller='changeset', revision='tip', action='comment', | |||
conditions=dict(function=check_repo)) | ||||
r3695 | rmap.connect('changeset_comment_preview', | |||
'/{repo_name:.*?}/changeset/comment/preview', | ||||
controller='changeset', action='preview_comment', | ||||
conditions=dict(function=check_repo, method=["POST"])) | ||||
r1982 | rmap.connect('changeset_comment_delete', | |||
r2692 | '/{repo_name:.*?}/changeset/comment/{comment_id}/delete', | |||
r1670 | controller='changeset', action='delete_comment', | |||
r1712 | conditions=dict(function=check_repo, method=["DELETE"])) | |||
r1670 | ||||
r2971 | rmap.connect('changeset_info', '/changeset_info/{repo_name:.*?}/{revision}', | |||
controller='changeset', action='changeset_info') | ||||
Bradley M. Kuhn
|
r4116 | rmap.connect('compare_home', | ||
'/{repo_name:.*?}/compare', | ||||
controller='compare', action='index', | ||||
conditions=dict(function=check_repo)) | ||||
r2363 | rmap.connect('compare_url', | |||
r2928 | '/{repo_name:.*?}/compare/{org_ref_type}@{org_ref:.*?}...{other_ref_type}@{other_ref:.*?}', | |||
Bradley M. Kuhn
|
r4116 | controller='compare', action='compare', | ||
r2363 | conditions=dict(function=check_repo), | |||
r2710 | requirements=dict( | |||
Mads Kiilerich
|
r3322 | org_ref_type='(branch|book|tag|rev|__other_ref_type__)', | ||
other_ref_type='(branch|book|tag|rev|__org_ref_type__)') | ||||
r2710 | ) | |||
r2241 | ||||
r2244 | rmap.connect('pullrequest_home', | |||
r2692 | '/{repo_name:.*?}/pull-request/new', controller='pullrequests', | |||
r2434 | action='index', conditions=dict(function=check_repo, | |||
method=["GET"])) | ||||
rmap.connect('pullrequest', | ||||
r2692 | '/{repo_name:.*?}/pull-request/new', controller='pullrequests', | |||
r2434 | action='create', conditions=dict(function=check_repo, | |||
method=["POST"])) | ||||
rmap.connect('pullrequest_show', | ||||
r2692 | '/{repo_name:.*?}/pull-request/{pull_request_id}', | |||
r2434 | controller='pullrequests', | |||
action='show', conditions=dict(function=check_repo, | ||||
method=["GET"])) | ||||
r2614 | rmap.connect('pullrequest_update', | |||
r2692 | '/{repo_name:.*?}/pull-request/{pull_request_id}', | |||
r2614 | controller='pullrequests', | |||
action='update', conditions=dict(function=check_repo, | ||||
method=["PUT"])) | ||||
r2746 | rmap.connect('pullrequest_delete', | |||
'/{repo_name:.*?}/pull-request/{pull_request_id}', | ||||
controller='pullrequests', | ||||
action='delete', conditions=dict(function=check_repo, | ||||
method=["DELETE"])) | ||||
r2244 | ||||
r2440 | rmap.connect('pullrequest_show_all', | |||
r2692 | '/{repo_name:.*?}/pull-request', | |||
r2440 | controller='pullrequests', | |||
action='show_all', conditions=dict(function=check_repo, | ||||
method=["GET"])) | ||||
r2443 | rmap.connect('pullrequest_comment', | |||
r2692 | '/{repo_name:.*?}/pull-request-comment/{pull_request_id}', | |||
r2443 | controller='pullrequests', | |||
action='comment', conditions=dict(function=check_repo, | ||||
method=["POST"])) | ||||
r2489 | rmap.connect('pullrequest_comment_delete', | |||
r2692 | '/{repo_name:.*?}/pull-request-comment/{comment_id}/delete', | |||
r2489 | controller='pullrequests', action='delete_comment', | |||
conditions=dict(function=check_repo, method=["DELETE"])) | ||||
Mads Kiilerich
|
r3283 | rmap.connect('summary_home_summary', '/{repo_name:.*?}/summary', | ||
r547 | controller='summary', conditions=dict(function=check_repo)) | |||
r1211 | ||||
r2692 | rmap.connect('branches_home', '/{repo_name:.*?}/branches', | |||
r547 | controller='branches', conditions=dict(function=check_repo)) | |||
r1211 | ||||
r2692 | rmap.connect('tags_home', '/{repo_name:.*?}/tags', | |||
r547 | controller='tags', conditions=dict(function=check_repo)) | |||
r1211 | ||||
r2692 | rmap.connect('bookmarks_home', '/{repo_name:.*?}/bookmarks', | |||
r1748 | controller='bookmarks', conditions=dict(function=check_repo)) | |||
r2692 | rmap.connect('changelog_home', '/{repo_name:.*?}/changelog', | |||
r604 | controller='changelog', conditions=dict(function=check_repo)) | |||
r1211 | ||||
r3764 | rmap.connect('changelog_summary_home', '/{repo_name:.*?}/changelog_summary', | |||
controller='changelog', action='changelog_summary', | ||||
conditions=dict(function=check_repo)) | ||||
r3760 | rmap.connect('changelog_file_home', '/{repo_name:.*?}/changelog/{revision}/{f_path:.*}', | |||
controller='changelog', f_path=None, | ||||
conditions=dict(function=check_repo)) | ||||
r2692 | rmap.connect('changelog_details', '/{repo_name:.*?}/changelog_details/{cs}', | |||
r1431 | controller='changelog', action='changelog_details', | |||
conditions=dict(function=check_repo)) | ||||
r2692 | rmap.connect('files_home', '/{repo_name:.*?}/files/{revision}/{f_path:.*}', | |||
r547 | controller='files', revision='tip', f_path='', | |||
conditions=dict(function=check_repo)) | ||||
r1211 | ||||
Mads Kiilerich
|
r3576 | rmap.connect('files_home_nopath', '/{repo_name:.*?}/files/{revision}', | ||
controller='files', revision='tip', f_path='', | ||||
conditions=dict(function=check_repo)) | ||||
r3001 | rmap.connect('files_history_home', | |||
'/{repo_name:.*?}/history/{revision}/{f_path:.*}', | ||||
controller='files', action='history', revision='tip', f_path='', | ||||
conditions=dict(function=check_repo)) | ||||
Bradley M. Kuhn
|
r4116 | rmap.connect('files_authors_home', | ||
'/{repo_name:.*?}/authors/{revision}/{f_path:.*}', | ||||
controller='files', action='authors', revision='tip', f_path='', | ||||
conditions=dict(function=check_repo)) | ||||
r2692 | rmap.connect('files_diff_home', '/{repo_name:.*?}/diff/{f_path:.*}', | |||
r547 | controller='files', action='diff', revision='tip', f_path='', | |||
conditions=dict(function=check_repo)) | ||||
r1211 | ||||
r4043 | rmap.connect('files_diff_2way_home', '/{repo_name:.*?}/diff-2way/{f_path:.*}', | |||
controller='files', action='diff_2way', revision='tip', f_path='', | ||||
conditions=dict(function=check_repo)) | ||||
r1211 | rmap.connect('files_rawfile_home', | |||
r2692 | '/{repo_name:.*?}/rawfile/{revision}/{f_path:.*}', | |||
r1211 | controller='files', action='rawfile', revision='tip', | |||
f_path='', conditions=dict(function=check_repo)) | ||||
rmap.connect('files_raw_home', | ||||
r2692 | '/{repo_name:.*?}/raw/{revision}/{f_path:.*}', | |||
r1211 | controller='files', action='raw', revision='tip', f_path='', | |||
conditions=dict(function=check_repo)) | ||||
rmap.connect('files_annotate_home', | ||||
r2692 | '/{repo_name:.*?}/annotate/{revision}/{f_path:.*}', | |||
r2177 | controller='files', action='index', revision='tip', | |||
f_path='', annotate=True, conditions=dict(function=check_repo)) | ||||
r1211 | ||||
r1305 | rmap.connect('files_edit_home', | |||
r2692 | '/{repo_name:.*?}/edit/{revision}/{f_path:.*}', | |||
r1305 | controller='files', action='edit', revision='tip', | |||
f_path='', conditions=dict(function=check_repo)) | ||||
r1483 | rmap.connect('files_add_home', | |||
r2692 | '/{repo_name:.*?}/add/{revision}/{f_path:.*}', | |||
r1483 | controller='files', action='add', revision='tip', | |||
f_path='', conditions=dict(function=check_repo)) | ||||
Bradley M. Kuhn
|
r4116 | rmap.connect('files_delete_home', | ||
'/{repo_name:.*?}/delete/{revision}/{f_path:.*}', | ||||
controller='files', action='delete', revision='tip', | ||||
f_path='', conditions=dict(function=check_repo)) | ||||
r2692 | rmap.connect('files_archive_home', '/{repo_name:.*?}/archive/{fname}', | |||
r872 | controller='files', action='archivefile', | |||
r604 | conditions=dict(function=check_repo)) | |||
r1211 | ||||
r1452 | rmap.connect('files_nodelist_home', | |||
r2692 | '/{repo_name:.*?}/nodelist/{revision}/{f_path:.*}', | |||
r1452 | controller='files', action='nodelist', | |||
conditions=dict(function=check_repo)) | ||||
r2692 | rmap.connect('repo_fork_create_home', '/{repo_name:.*?}/fork', | |||
r1722 | controller='forks', action='fork_create', | |||
r547 | conditions=dict(function=check_repo, method=["POST"])) | |||
r1211 | ||||
r2692 | rmap.connect('repo_fork_home', '/{repo_name:.*?}/fork', | |||
r1722 | controller='forks', action='fork', | |||
r547 | conditions=dict(function=check_repo)) | |||
r604 | ||||
r2692 | rmap.connect('repo_forks_home', '/{repo_name:.*?}/forks', | |||
r1722 | controller='forks', action='forks', | |||
conditions=dict(function=check_repo)) | ||||
r2692 | rmap.connect('repo_followers_home', '/{repo_name:.*?}/followers', | |||
r1279 | controller='followers', action='followers', | |||
conditions=dict(function=check_repo)) | ||||
r1301 | ||||
r1211 | return rmap | |||