# Copyright (C) 2010-2024 RhodeCode GmbH # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License, version 3 # (only), as published by the Free Software Foundation. # # 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 Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # # This program is dual-licensed. If you wish to learn more about the # RhodeCode Enterprise Edition, including its added features, Support services, # and proprietary license terms, please see https://rhodecode.com/licenses/ def get_url_defs(): from rhodecode.apps._base import ADMIN_PREFIX return { "home": "/", "main_page_repos_data": "/_home_repos", "main_page_repo_groups_data": "/_home_repo_groups", "repo_group_home": "/{repo_group_name}", "user_autocomplete_data": "/_users", "user_group_autocomplete_data": "/_user_groups", "repo_list_data": "/_repos", "goto_switcher_data": "/_goto_data", "admin_home": ADMIN_PREFIX + "", "admin_audit_logs": ADMIN_PREFIX + "/audit_logs", "admin_defaults_repositories": ADMIN_PREFIX + "/defaults/repositories", "admin_defaults_repositories_update": ADMIN_PREFIX + "/defaults/repositories/update", "search": ADMIN_PREFIX + "/search", "search_repo": "/{repo_name}/search", "my_account_auth_tokens": ADMIN_PREFIX + "/my_account/auth_tokens", "my_account_auth_tokens_add": ADMIN_PREFIX + "/my_account/auth_tokens/new", "my_account_auth_tokens_delete": ADMIN_PREFIX + "/my_account/auth_tokens/delete", "repos": ADMIN_PREFIX + "/repos", "repos_data": ADMIN_PREFIX + "/repos_data", "repo_groups": ADMIN_PREFIX + "/repo_groups", "repo_groups_data": ADMIN_PREFIX + "/repo_groups_data", "user_groups": ADMIN_PREFIX + "/user_groups", "user_groups_data": ADMIN_PREFIX + "/user_groups_data", "user_profile": "/_profiles/{username}", "profile_user_group": "/_profile_user_group/{user_group_name}", "repo_summary": "/{repo_name}", "repo_creating_check": "/{repo_name}/repo_creating_check", "edit_repo": "/{repo_name}/settings", "edit_repo_vcs": "/{repo_name}/settings/vcs", "edit_repo_vcs_update": "/{repo_name}/settings/vcs/update", "edit_repo_vcs_svn_pattern_delete": "/{repo_name}/settings/vcs/svn_pattern/delete", "repo_archivefile": "/{repo_name}/archive/{fname}", "repo_files_diff": "/{repo_name}/diff/{f_path}", "repo_files_diff_2way_redirect": "/{repo_name}/diff-2way/{f_path}", "repo_files": "/{repo_name}/files/{commit_id}/{f_path}", "repo_files:default_path": "/{repo_name}/files/{commit_id}/", "repo_files:default_commit": "/{repo_name}/files", "repo_files:rendered": "/{repo_name}/render/{commit_id}/{f_path}", "repo_files:annotated": "/{repo_name}/annotate/{commit_id}/{f_path}", "repo_files:annotated_previous": "/{repo_name}/annotate-previous/{commit_id}/{f_path}", "repo_files_nodelist": "/{repo_name}/nodelist/{commit_id}/{f_path}", "repo_file_raw": "/{repo_name}/raw/{commit_id}/{f_path}", "repo_file_download": "/{repo_name}/download/{commit_id}/{f_path}", "repo_file_history": "/{repo_name}/history/{commit_id}/{f_path}", "repo_file_authors": "/{repo_name}/authors/{commit_id}/{f_path}", "repo_files_remove_file": "/{repo_name}/remove_file/{commit_id}/{f_path}", "repo_files_delete_file": "/{repo_name}/delete_file/{commit_id}/{f_path}", "repo_files_edit_file": "/{repo_name}/edit_file/{commit_id}/{f_path}", "repo_files_update_file": "/{repo_name}/update_file/{commit_id}/{f_path}", "repo_files_add_file": "/{repo_name}/add_file/{commit_id}/{f_path}", "repo_files_upload_file": "/{repo_name}/upload_file/{commit_id}/{f_path}", "repo_files_create_file": "/{repo_name}/create_file/{commit_id}/{f_path}", "repo_files_replace_binary": "/{repo_name}/replace_binary/{commit_id}/{f_path}", "repo_nodetree_full": "/{repo_name}/nodetree_full/{commit_id}/{f_path}", "repo_nodetree_full:default_path": "/{repo_name}/nodetree_full/{commit_id}/", "journal": ADMIN_PREFIX + "/journal", "journal_rss": ADMIN_PREFIX + "/journal/rss", "journal_atom": ADMIN_PREFIX + "/journal/atom", "journal_public": ADMIN_PREFIX + "/public_journal", "journal_public_atom": ADMIN_PREFIX + "/public_journal/atom", "journal_public_atom_old": ADMIN_PREFIX + "/public_journal_atom", "journal_public_rss": ADMIN_PREFIX + "/public_journal/rss", "journal_public_rss_old": ADMIN_PREFIX + "/public_journal_rss", "toggle_following": ADMIN_PREFIX + "/toggle_following", "upload_file": "/_file_store/upload", "download_file": "/_file_store/download/{fid}", "download_file_by_token": "/_file_store/token-download/{_auth_token}/{fid}", "gists_show": ADMIN_PREFIX + "/gists", "gists_new": ADMIN_PREFIX + "/gists/new", "gists_create": ADMIN_PREFIX + "/gists/create", "gist_show": ADMIN_PREFIX + "/gists/{gist_id}", "gist_delete": ADMIN_PREFIX + "/gists/{gist_id}/delete", "gist_edit": ADMIN_PREFIX + "/gists/{gist_id}/edit", "gist_edit_check_revision": ADMIN_PREFIX + "/gists/{gist_id}/edit/check_revision", "gist_update": ADMIN_PREFIX + "/gists/{gist_id}/update", "gist_show_rev": ADMIN_PREFIX + "/gists/{gist_id}/rev/{revision}", "gist_show_formatted": ADMIN_PREFIX + "/gists/{gist_id}/rev/{revision}/{format}", "gist_show_formatted_path": ADMIN_PREFIX + "/gists/{gist_id}/rev/{revision}/{format}/{f_path}", "login": ADMIN_PREFIX + "/login", "logout": ADMIN_PREFIX + "/logout", "setup_2fa": ADMIN_PREFIX + "/setup_2fa", "check_2fa": ADMIN_PREFIX + "/check_2fa", "register": ADMIN_PREFIX + "/register", "reset_password": ADMIN_PREFIX + "/password_reset", "reset_password_confirmation": ADMIN_PREFIX + "/password_reset_confirmation", "admin_permissions_application": ADMIN_PREFIX + "/permissions/application", "admin_permissions_application_update": ADMIN_PREFIX + "/permissions/application/update", "repo_commit_raw": "/{repo_name}/changeset-diff/{commit_id}", "user_group_members_data": ADMIN_PREFIX + "/user_groups/{user_group_id}/members", "user_groups_new": ADMIN_PREFIX + "/user_groups/new", "user_groups_create": ADMIN_PREFIX + "/user_groups/create", "edit_user_group": ADMIN_PREFIX + "/user_groups/{user_group_id}/edit", "edit_user_group_advanced_sync": ADMIN_PREFIX + "/user_groups/{user_group_id}/edit/advanced/sync", "edit_user_group_global_perms_update": ADMIN_PREFIX + "/user_groups/{user_group_id}/edit/global_permissions/update", "user_groups_update": ADMIN_PREFIX + "/user_groups/{user_group_id}/update", "user_groups_delete": ADMIN_PREFIX + "/user_groups/{user_group_id}/delete", "edit_user_group_perms": ADMIN_PREFIX + "/user_groups/{user_group_id}/edit/permissions", "edit_user_group_perms_update": ADMIN_PREFIX + "/user_groups/{user_group_id}/edit/permissions/update", "edit_repo_group": "/{repo_group_name}/_edit", "edit_repo_group_perms": "/{repo_group_name:}/_settings/permissions", "edit_repo_group_perms_update": "/{repo_group_name}/_settings/permissions/update", "edit_repo_group_advanced": "/{repo_group_name}/_settings/advanced", "edit_repo_group_advanced_delete": "/{repo_group_name}/_settings/advanced/delete", "edit_user_ssh_keys": ADMIN_PREFIX + "/users/{user_id}/edit/ssh_keys", "edit_user_ssh_keys_generate_keypair": ADMIN_PREFIX + "/users/{user_id}/edit/ssh_keys/generate", "edit_user_ssh_keys_add": ADMIN_PREFIX + "/users/{user_id}/edit/ssh_keys/new", "edit_user_ssh_keys_delete": ADMIN_PREFIX + "/users/{user_id}/edit/ssh_keys/delete", "users": ADMIN_PREFIX + "/users", "users_data": ADMIN_PREFIX + "/users_data", "users_create": ADMIN_PREFIX + "/users/create", "users_new": ADMIN_PREFIX + "/users/new", "user_edit": ADMIN_PREFIX + "/users/{user_id}/edit", "user_edit_advanced": ADMIN_PREFIX + "/users/{user_id}/edit/advanced", "user_edit_global_perms": ADMIN_PREFIX + "/users/{user_id}/edit/global_permissions", "user_edit_global_perms_update": ADMIN_PREFIX + "/users/{user_id}/edit/global_permissions/update", "user_update": ADMIN_PREFIX + "/users/{user_id}/update", "user_delete": ADMIN_PREFIX + "/users/{user_id}/delete", "user_create_personal_repo_group": ADMIN_PREFIX + "/users/{user_id}/create_repo_group", "edit_user_auth_tokens": ADMIN_PREFIX + "/users/{user_id}/edit/auth_tokens", "edit_user_auth_tokens_add": ADMIN_PREFIX + "/users/{user_id}/edit/auth_tokens/new", "edit_user_auth_tokens_delete": ADMIN_PREFIX + "/users/{user_id}/edit/auth_tokens/delete", "edit_user_emails": ADMIN_PREFIX + "/users/{user_id}/edit/emails", "edit_user_emails_add": ADMIN_PREFIX + "/users/{user_id}/edit/emails/new", "edit_user_emails_delete": ADMIN_PREFIX + "/users/{user_id}/edit/emails/delete", "edit_user_ips": ADMIN_PREFIX + "/users/{user_id}/edit/ips", "edit_user_ips_add": ADMIN_PREFIX + "/users/{user_id}/edit/ips/new", "edit_user_ips_delete": ADMIN_PREFIX + "/users/{user_id}/edit/ips/delete", "edit_user_perms_summary": ADMIN_PREFIX + "/users/{user_id}/edit/permissions_summary", "edit_user_perms_summary_json": ADMIN_PREFIX + "/users/{user_id}/edit/permissions_summary/json", "edit_user_audit_logs": ADMIN_PREFIX + "/users/{user_id}/edit/audit", "edit_user_audit_logs_download": ADMIN_PREFIX + "/users/{user_id}/edit/audit/download", "admin_settings": ADMIN_PREFIX + "/settings", "admin_settings_update": ADMIN_PREFIX + "/settings/update", "admin_settings_global": ADMIN_PREFIX + "/settings/global", "admin_settings_global_update": ADMIN_PREFIX + "/settings/global/update", "admin_settings_vcs": ADMIN_PREFIX + "/settings/vcs", "admin_settings_vcs_update": ADMIN_PREFIX + "/settings/vcs/update", "admin_settings_vcs_svn_pattern_delete": ADMIN_PREFIX + "/settings/vcs/svn_pattern_delete", "admin_settings_mapping": ADMIN_PREFIX + "/settings/mapping", "admin_settings_mapping_create": ADMIN_PREFIX + "/settings/mapping/create", "admin_settings_mapping_cleanup": ADMIN_PREFIX + "/settings/mapping/cleanup", "admin_settings_visual": ADMIN_PREFIX + "/settings/visual", "admin_settings_visual_update": ADMIN_PREFIX + "/settings/visual/update", "admin_settings_issuetracker": ADMIN_PREFIX + "/settings/issue-tracker", "admin_settings_issuetracker_update": ADMIN_PREFIX + "/settings/issue-tracker/update", "admin_settings_issuetracker_test": ADMIN_PREFIX + "/settings/issue-tracker/test", "admin_settings_issuetracker_delete": ADMIN_PREFIX + "/settings/issue-tracker/delete", "admin_settings_email": ADMIN_PREFIX + "/settings/email", "admin_settings_email_update": ADMIN_PREFIX + "/settings/email/update", "admin_settings_hooks": ADMIN_PREFIX + "/settings/hooks", "admin_settings_hooks_update": ADMIN_PREFIX + "/settings/hooks/update", "admin_settings_hooks_delete": ADMIN_PREFIX + "/settings/hooks/delete", "admin_settings_search": ADMIN_PREFIX + "/settings/search", "admin_settings_labs": ADMIN_PREFIX + "/settings/labs", "admin_settings_labs_update": ADMIN_PREFIX + "/settings/labs/update", "admin_settings_sessions": ADMIN_PREFIX + "/settings/sessions", "admin_settings_sessions_cleanup": ADMIN_PREFIX + "/settings/sessions/cleanup", "admin_settings_system": ADMIN_PREFIX + "/settings/system", "admin_settings_system_update": ADMIN_PREFIX + "/settings/system/updates", "admin_settings_open_source": ADMIN_PREFIX + "/settings/open_source", "repo_group_new": ADMIN_PREFIX + "/repo_group/new", "repo_group_create": ADMIN_PREFIX + "/repo_group/create", "repo_new": ADMIN_PREFIX + "/repos/new", "repo_create": ADMIN_PREFIX + "/repos/create", "admin_permissions_global": ADMIN_PREFIX + "/permissions/global", "admin_permissions_global_update": ADMIN_PREFIX + "/permissions/global/update", "admin_permissions_object": ADMIN_PREFIX + "/permissions/object", "admin_permissions_object_update": ADMIN_PREFIX + "/permissions/object/update", "admin_permissions_ips": ADMIN_PREFIX + "/permissions/ips", "admin_permissions_overview": ADMIN_PREFIX + "/permissions/overview", "admin_permissions_ssh_keys": ADMIN_PREFIX + "/permissions/ssh_keys", "admin_permissions_ssh_keys_data": ADMIN_PREFIX + "/permissions/ssh_keys/data", "admin_permissions_ssh_keys_update": ADMIN_PREFIX + "/permissions/ssh_keys/update", "pullrequest_show": "/{repo_name}/pull-request/{pull_request_id}", "pull_requests_global": ADMIN_PREFIX + "/pull-request/{pull_request_id}", "pull_requests_global_0": ADMIN_PREFIX + "/pull_requests/{pull_request_id}", "pull_requests_global_1": ADMIN_PREFIX + "/pull-requests/{pull_request_id}", "notifications_show_all": ADMIN_PREFIX + "/notifications", "notifications_mark_all_read": ADMIN_PREFIX + "/notifications_mark_all_read", "notifications_show": ADMIN_PREFIX + "/notifications/{notification_id}", "notifications_update": ADMIN_PREFIX + "/notifications/{notification_id}/update", "notifications_delete": ADMIN_PREFIX + "/notifications/{notification_id}/delete", "my_account": ADMIN_PREFIX + "/my_account/profile", "my_account_edit": ADMIN_PREFIX + "/my_account/edit", "my_account_update": ADMIN_PREFIX + "/my_account/update", "my_account_pullrequests": ADMIN_PREFIX + "/my_account/pull_requests", "my_account_pullrequests_data": ADMIN_PREFIX + "/my_account/pull_requests/data", "my_account_emails": ADMIN_PREFIX + "/my_account/emails", "my_account_emails_add": ADMIN_PREFIX + "/my_account/emails/new", "my_account_emails_delete": ADMIN_PREFIX + "/my_account/emails/delete", "my_account_password": ADMIN_PREFIX + "/my_account/password", "my_account_password_update": ADMIN_PREFIX + "/my_account/password/update", "my_account_repos": ADMIN_PREFIX + "/my_account/repos", "my_account_watched": ADMIN_PREFIX + "/my_account/watched", "my_account_perms": ADMIN_PREFIX + "/my_account/perms", "my_account_notifications": ADMIN_PREFIX + "/my_account/notifications", "my_account_ssh_keys": ADMIN_PREFIX + "/my_account/ssh_keys", "my_account_ssh_keys_generate": ADMIN_PREFIX + "/my_account/ssh_keys/generate", "my_account_ssh_keys_add": ADMIN_PREFIX + "/my_account/ssh_keys/new", "my_account_ssh_keys_delete": ADMIN_PREFIX + "/my_account/ssh_keys/delete", "pullrequest_show_all": "/{repo_name}/pull-request", "pullrequest_show_all_data": "/{repo_name}/pull-request-data", "bookmarks_home": "/{repo_name}/bookmarks", "branches_home": "/{repo_name}/branches", "branch_remove": "/{repo_name}/branches/{branch_name}/remove", "tags_home": "/{repo_name}/tags", "repo_changelog": "/{repo_name}/changelog", "repo_commits": "/{repo_name}/commits", "repo_commits_file": "/{repo_name}/commits/{commit_id}/{f_path}", "repo_commits_elements": "/{repo_name}/commits_elements", "repo_commit": "/{repo_name}/changeset/{commit_id}", "repo_commit_comment_create": "/{repo_name}/changeset/{commit_id}/comment/create", "repo_commit_comment_preview": "/{repo_name}/changeset/{commit_id}/comment/preview", "repo_commit_comment_delete": "/{repo_name}/changeset/{commit_id}/comment/{comment_id}/delete", "repo_commit_comment_edit": "/{repo_name}/changeset/{commit_id}/comment/{comment_id}/edit", "repo_commit_children": "/{repo_name}/changeset_children/{commit_id}", "repo_commit_parents": "/{repo_name}/changeset_parents/{commit_id}", "repo_commit_patch": "/{repo_name}/changeset-patch/{commit_id}", "repo_commit_download": "/{repo_name}/changeset-download/{commit_id}", "repo_commit_data": "/{repo_name}/changeset-data/{commit_id}", "repo_compare": "/{repo_name}/compare/{source_ref_type}@{source_ref}...{target_ref_type}@{target_ref}", "repo_compare_select": "/{repo_name}/compare", "rss_feed_home": "/{repo_name}/feed-rss", "atom_feed_home": "/{repo_name}/feed-atom", "rss_feed_home_old": "/{repo_name}/feed/rss", "atom_feed_home_old": "/{repo_name}/feed/atom", "repo_fork_new": "/{repo_name}/fork", "repo_fork_create": "/{repo_name}/fork/create", "repo_forks_show_all": "/{repo_name}/forks", "repo_forks_data": "/{repo_name}/forks/data", "edit_repo_issuetracker": "/{repo_name}/settings/issue_trackers", "edit_repo_issuetracker_test": "/{repo_name}/settings/issue_trackers/test", "edit_repo_issuetracker_delete": "/{repo_name}/settings/issue_trackers/delete", "edit_repo_issuetracker_update": "/{repo_name}/settings/issue_trackers/update", "edit_repo_maintenance": "/{repo_name}/settings/maintenance", "edit_repo_maintenance_execute": "/{repo_name}/settings/maintenance/execute", "repo_changelog_file": "/{repo_name}/changelog/{commit_id}/{f_path}", "pullrequest_repo_refs": "/{repo_name}/pull-request/refs/{target_repo_name:.*?[^/]}", "pullrequest_repo_targets": "/{repo_name}/pull-request/repo-destinations", "pullrequest_new": "/{repo_name}/pull-request/new", "pullrequest_create": "/{repo_name}/pull-request/create", "pullrequest_update": "/{repo_name}/pull-request/{pull_request_id}/update", "pullrequest_merge": "/{repo_name}/pull-request/{pull_request_id}/merge", "pullrequest_delete": "/{repo_name}/pull-request/{pull_request_id}/delete", "pullrequest_comment_create": "/{repo_name}/pull-request/{pull_request_id}/comment", "pullrequest_comment_delete": "/{repo_name}/pull-request/{pull_request_id}/comment/{comment_id}/delete", "pullrequest_comment_edit": "/{repo_name}/pull-request/{pull_request_id}/comment/{comment_id}/edit", "edit_repo_caches": "/{repo_name}/settings/caches", "edit_repo_perms": "/{repo_name}/settings/permissions", "edit_repo_fields": "/{repo_name}/settings/fields", "edit_repo_remote": "/{repo_name}/settings/remote", "edit_repo_statistics": "/{repo_name}/settings/statistics", "edit_repo_advanced": "/{repo_name}/settings/advanced", "edit_repo_advanced_delete": "/{repo_name}/settings/advanced/delete", "edit_repo_advanced_archive": "/{repo_name}/settings/advanced/archive", "edit_repo_advanced_fork": "/{repo_name}/settings/advanced/fork", "edit_repo_advanced_locking": "/{repo_name}/settings/advanced/locking", "edit_repo_advanced_journal": "/{repo_name}/settings/advanced/journal", "repo_stats": "/{repo_name}/repo_stats/{commit_id}", "repo_refs_data": "/{repo_name}/refs-data", "repo_refs_changelog_data": "/{repo_name}/refs-data-changelog", "repo_artifacts_stream_store": "/_file_store/stream-upload", } def route_path(name, params=None, **kwargs): import urllib.parse base_url = get_url_defs()[name].format(**kwargs) if params: base_url = f"{base_url}?{urllib.parse.urlencode(params)}" return base_url