|
@@
-1,126
+1,128
|
|
1
|
1
|
"""Routes configuration
|
|
2
|
2
|
|
|
3
|
3
|
The more specific and detailed routes should be defined first so they
|
|
4
|
4
|
may take precedent over the more generic routes. For more information
|
|
5
|
5
|
refer to the routes manual at http://routes.groovie.org/docs/
|
|
6
|
6
|
"""
|
|
7
|
7
|
from routes import Mapper
|
|
8
|
8
|
from pylons_app.lib.utils import check_repo_fast as cr
|
|
9
|
9
|
|
|
10
|
10
|
def make_map(config):
|
|
11
|
11
|
"""Create, configure and return the routes Mapper"""
|
|
12
|
12
|
map = Mapper(directory=config['pylons.paths']['controllers'],
|
|
13
|
13
|
always_scan=config['debug'])
|
|
14
|
14
|
map.minimization = False
|
|
15
|
15
|
map.explicit = False
|
|
16
|
16
|
|
|
17
|
17
|
# The ErrorController route (handles 404/500 error pages); it should
|
|
18
|
18
|
# likely stay at the top, ensuring it can always be resolved
|
|
19
|
19
|
map.connect('/error/{action}', controller='error')
|
|
20
|
20
|
map.connect('/error/{action}/{id}', controller='error')
|
|
21
|
21
|
|
|
22
|
22
|
# CUSTOM ROUTES HERE
|
|
23
|
23
|
map.connect('hg_home', '/', controller='hg', action='index')
|
|
24
|
24
|
|
|
25
|
25
|
def check_repo(environ, match_dict):
|
|
26
|
26
|
"""
|
|
27
|
27
|
check for valid repository for proper 404 handling
|
|
28
|
28
|
@param environ:
|
|
29
|
29
|
@param match_dict:
|
|
30
|
30
|
"""
|
|
31
|
31
|
repo_name = match_dict.get('repo_name')
|
|
32
|
32
|
return not cr(repo_name, config['base_path'])
|
|
33
|
33
|
|
|
34
|
34
|
#REST routes
|
|
35
|
|
with map.submapper(path_prefix='/_admin', controller='repos') as m:
|
|
|
35
|
with map.submapper(path_prefix='/_admin', controller='pylons_app.controllers.admin.repos:ReposController') as m:
|
|
36
|
36
|
m.connect("repos", "/repos",
|
|
37
|
37
|
action="create", conditions=dict(method=["POST"]))
|
|
38
|
38
|
m.connect("repos", "/repos",
|
|
39
|
39
|
action="index", conditions=dict(method=["GET"]))
|
|
40
|
40
|
m.connect("formatted_repos", "/repos.{format}",
|
|
41
|
41
|
action="index",
|
|
42
|
42
|
conditions=dict(method=["GET"]))
|
|
43
|
43
|
m.connect("new_repo", "/repos/new",
|
|
44
|
44
|
action="new", conditions=dict(method=["GET"]))
|
|
45
|
45
|
m.connect("formatted_new_repo", "/repos/new.{format}",
|
|
46
|
46
|
action="new", conditions=dict(method=["GET"]))
|
|
47
|
47
|
m.connect("/repos/{repo_name:.*}",
|
|
48
|
48
|
action="update", conditions=dict(method=["PUT"],
|
|
49
|
49
|
function=check_repo))
|
|
50
|
50
|
m.connect("/repos/{repo_name:.*}",
|
|
51
|
51
|
action="delete", conditions=dict(method=["DELETE"],
|
|
52
|
52
|
function=check_repo))
|
|
53
|
53
|
m.connect("edit_repo", "/repos/{repo_name:.*}/edit",
|
|
54
|
54
|
action="edit", conditions=dict(method=["GET"],
|
|
55
|
55
|
function=check_repo))
|
|
56
|
56
|
m.connect("formatted_edit_repo", "/repos/{repo_name:.*}.{format}/edit",
|
|
57
|
57
|
action="edit", conditions=dict(method=["GET"],
|
|
58
|
58
|
function=check_repo))
|
|
59
|
59
|
m.connect("repo", "/repos/{repo_name:.*}",
|
|
60
|
60
|
action="show", conditions=dict(method=["GET"],
|
|
61
|
61
|
function=check_repo))
|
|
62
|
62
|
m.connect("formatted_repo", "/repos/{repo_name:.*}.{format}",
|
|
63
|
63
|
action="show", conditions=dict(method=["GET"],
|
|
64
|
64
|
function=check_repo))
|
|
65
|
65
|
#ajax delete repo perm user
|
|
66
|
66
|
m.connect('delete_repo_user', "/repos_delete_user/{repo_name:.*}",
|
|
67
|
67
|
action="delete_perm_user", conditions=dict(method=["DELETE"],
|
|
68
|
68
|
function=check_repo))
|
|
69
|
69
|
|
|
70
|
|
map.resource('user', 'users', path_prefix='/_admin')
|
|
71
|
|
map.resource('permission', 'permissions', path_prefix='/_admin')
|
|
|
70
|
map.resource('user', 'users', controller='pylons_app.controllers.admin.users:UsersController', path_prefix='/_admin')
|
|
|
71
|
map.resource('permission', 'permissions', controller='pylons_app.controllers.admin.permissions:PermissionsController', path_prefix='/_admin')
|
|
72
|
72
|
|
|
73
|
73
|
#ADMIN
|
|
74
|
|
with map.submapper(path_prefix='/_admin', controller='admin') as m:
|
|
|
74
|
with map.submapper(path_prefix='/_admin', controller='pylons_app.controllers.admin.admin:AdminController') as m:
|
|
75
|
75
|
m.connect('admin_home', '', action='index')#main page
|
|
76
|
76
|
m.connect('admin_add_repo', '/add_repo/{new_repo:[a-z0-9\. _-]*}',
|
|
77
|
77
|
action='add_repo')
|
|
78
|
78
|
|
|
79
|
79
|
#FEEDS
|
|
80
|
80
|
map.connect('rss_feed_home', '/{repo_name:.*}/feed/rss',
|
|
81
|
81
|
controller='feed', action='rss',
|
|
82
|
82
|
conditions=dict(function=check_repo))
|
|
83
|
83
|
map.connect('atom_feed_home', '/{repo_name:.*}/feed/atom',
|
|
84
|
84
|
controller='feed', action='atom',
|
|
85
|
85
|
conditions=dict(function=check_repo))
|
|
86
|
86
|
|
|
|
87
|
#LOGIN/LOGOUT
|
|
87
|
88
|
map.connect('login_home', '/login', controller='login')
|
|
88
|
89
|
map.connect('logout_home', '/logout', controller='login', action='logout')
|
|
89
|
90
|
|
|
|
91
|
#OTHERS
|
|
90
|
92
|
map.connect('changeset_home', '/{repo_name:.*}/changeset/{revision}',
|
|
91
|
93
|
controller='changeset', revision='tip',
|
|
92
|
94
|
conditions=dict(function=check_repo))
|
|
93
|
95
|
map.connect('summary_home', '/{repo_name:.*}/summary',
|
|
94
|
96
|
controller='summary', conditions=dict(function=check_repo))
|
|
95
|
97
|
map.connect('shortlog_home', '/{repo_name:.*}/shortlog',
|
|
96
|
98
|
controller='shortlog', conditions=dict(function=check_repo))
|
|
97
|
99
|
map.connect('branches_home', '/{repo_name:.*}/branches',
|
|
98
|
100
|
controller='branches', conditions=dict(function=check_repo))
|
|
99
|
101
|
map.connect('tags_home', '/{repo_name:.*}/tags',
|
|
100
|
102
|
controller='tags', conditions=dict(function=check_repo))
|
|
101
|
103
|
map.connect('changelog_home', '/{repo_name:.*}/changelog',
|
|
102
|
104
|
controller='changelog', conditions=dict(function=check_repo))
|
|
103
|
105
|
map.connect('files_home', '/{repo_name:.*}/files/{revision}/{f_path:.*}',
|
|
104
|
106
|
controller='files', revision='tip', f_path='',
|
|
105
|
107
|
conditions=dict(function=check_repo))
|
|
106
|
108
|
map.connect('files_diff_home', '/{repo_name:.*}/diff/{f_path:.*}',
|
|
107
|
109
|
controller='files', action='diff', revision='tip', f_path='',
|
|
108
|
110
|
conditions=dict(function=check_repo))
|
|
109
|
111
|
map.connect('files_raw_home', '/{repo_name:.*}/rawfile/{revision}/{f_path:.*}',
|
|
110
|
112
|
controller='files', action='rawfile', revision='tip', f_path='',
|
|
111
|
113
|
conditions=dict(function=check_repo))
|
|
112
|
114
|
map.connect('files_annotate_home', '/{repo_name:.*}/annotate/{revision}/{f_path:.*}',
|
|
113
|
115
|
controller='files', action='annotate', revision='tip', f_path='',
|
|
114
|
116
|
conditions=dict(function=check_repo))
|
|
115
|
117
|
map.connect('files_archive_home', '/{repo_name:.*}/archive/{revision}/{fileformat}',
|
|
116
|
118
|
controller='files', action='archivefile', revision='tip',
|
|
117
|
119
|
conditions=dict(function=check_repo))
|
|
118
|
120
|
map.connect('repo_settings_update', '/{repo_name:.*}/settings',
|
|
119
|
121
|
controller='settings', action="update",
|
|
120
|
122
|
conditions=dict(method=["PUT"], function=check_repo))
|
|
121
|
123
|
map.connect('repo_settings_home', '/{repo_name:.*}/settings',
|
|
122
|
124
|
controller='settings', action='index',
|
|
123
|
125
|
conditions=dict(function=check_repo))
|
|
124
|
126
|
|
|
125
|
127
|
|
|
126
|
128
|
return map
|