Show More
@@ -1,661 +1,665 b'' | |||
|
1 | 1 | """ |
|
2 | 2 | Routes configuration |
|
3 | 3 | |
|
4 | 4 | The more specific and detailed routes should be defined first so they |
|
5 | 5 | may take precedent over the more generic routes. For more information |
|
6 | 6 | refer to the routes manual at http://routes.groovie.org/docs/ |
|
7 | 7 | """ |
|
8 | 8 | from __future__ import with_statement |
|
9 | 9 | from routes import Mapper |
|
10 | 10 | |
|
11 | 11 | # prefix for non repository related links needs to be prefixed with `/` |
|
12 | 12 | ADMIN_PREFIX = '/_admin' |
|
13 | 13 | |
|
14 | 14 | |
|
15 | 15 | def make_map(config): |
|
16 | 16 | """Create, configure and return the routes Mapper""" |
|
17 | 17 | rmap = Mapper(directory=config['pylons.paths']['controllers'], |
|
18 | 18 | always_scan=config['debug']) |
|
19 | 19 | rmap.minimization = False |
|
20 | 20 | rmap.explicit = False |
|
21 | 21 | |
|
22 | 22 | from rhodecode.lib.utils import is_valid_repo |
|
23 | 23 | from rhodecode.lib.utils import is_valid_repos_group |
|
24 | 24 | |
|
25 | 25 | def check_repo(environ, match_dict): |
|
26 | 26 | """ |
|
27 | 27 | check for valid repository for proper 404 handling |
|
28 | 28 | |
|
29 | 29 | :param environ: |
|
30 | 30 | :param match_dict: |
|
31 | 31 | """ |
|
32 | 32 | from rhodecode.model.db import Repository |
|
33 | 33 | repo_name = match_dict.get('repo_name') |
|
34 | 34 | |
|
35 | 35 | if match_dict.get('f_path'): |
|
36 | 36 | #fix for multiple initial slashes that causes errors |
|
37 | 37 | match_dict['f_path'] = match_dict['f_path'].lstrip('/') |
|
38 | 38 | |
|
39 | 39 | try: |
|
40 | 40 | by_id = repo_name.split('_') |
|
41 | 41 | if len(by_id) == 2 and by_id[1].isdigit() and by_id[0] == '': |
|
42 | 42 | repo_name = Repository.get(by_id[1]).repo_name |
|
43 | 43 | match_dict['repo_name'] = repo_name |
|
44 | 44 | except: |
|
45 | 45 | pass |
|
46 | 46 | |
|
47 | 47 | return is_valid_repo(repo_name, config['base_path']) |
|
48 | 48 | |
|
49 | 49 | def check_group(environ, match_dict): |
|
50 | 50 | """ |
|
51 | 51 | check for valid repository group for proper 404 handling |
|
52 | 52 | |
|
53 | 53 | :param environ: |
|
54 | 54 | :param match_dict: |
|
55 | 55 | """ |
|
56 | 56 | repos_group_name = match_dict.get('group_name') |
|
57 | 57 | return is_valid_repos_group(repos_group_name, config['base_path']) |
|
58 | 58 | |
|
59 | 59 | def check_group_skip_path(environ, match_dict): |
|
60 | 60 | """ |
|
61 | 61 | check for valid repository group for proper 404 handling, but skips |
|
62 | 62 | verification of existing path |
|
63 | 63 | |
|
64 | 64 | :param environ: |
|
65 | 65 | :param match_dict: |
|
66 | 66 | """ |
|
67 | 67 | repos_group_name = match_dict.get('group_name') |
|
68 | 68 | return is_valid_repos_group(repos_group_name, config['base_path'], |
|
69 | 69 | skip_path_check=True) |
|
70 | 70 | |
|
71 | 71 | def check_int(environ, match_dict): |
|
72 | 72 | return match_dict.get('id').isdigit() |
|
73 | 73 | |
|
74 | 74 | # The ErrorController route (handles 404/500 error pages); it should |
|
75 | 75 | # likely stay at the top, ensuring it can always be resolved |
|
76 | 76 | rmap.connect('/error/{action}', controller='error') |
|
77 | 77 | rmap.connect('/error/{action}/{id}', controller='error') |
|
78 | 78 | |
|
79 | 79 | #========================================================================== |
|
80 | 80 | # CUSTOM ROUTES HERE |
|
81 | 81 | #========================================================================== |
|
82 | 82 | |
|
83 | 83 | #MAIN PAGE |
|
84 | 84 | rmap.connect('home', '/', controller='home', action='index') |
|
85 | 85 | rmap.connect('repo_switcher', '/repos', controller='home', |
|
86 | 86 | action='repo_switcher') |
|
87 | 87 | rmap.connect('branch_tag_switcher', '/branches-tags/{repo_name:.*?}', |
|
88 | 88 | controller='home', action='branch_tag_switcher') |
|
89 | 89 | rmap.connect('bugtracker', |
|
90 | 90 | "http://bitbucket.org/marcinkuzminski/rhodecode/issues", |
|
91 | 91 | _static=True) |
|
92 | 92 | rmap.connect('rst_help', |
|
93 | 93 | "http://docutils.sourceforge.net/docs/user/rst/quickref.html", |
|
94 | 94 | _static=True) |
|
95 | 95 | rmap.connect('rhodecode_official', "http://rhodecode.org", _static=True) |
|
96 | 96 | |
|
97 | 97 | #ADMIN REPOSITORY REST ROUTES |
|
98 | 98 | with rmap.submapper(path_prefix=ADMIN_PREFIX, |
|
99 | 99 | controller='admin/repos') as m: |
|
100 | 100 | m.connect("repos", "/repos", |
|
101 | 101 | action="create", conditions=dict(method=["POST"])) |
|
102 | 102 | m.connect("repos", "/repos", |
|
103 | 103 | action="index", conditions=dict(method=["GET"])) |
|
104 | 104 | m.connect("formatted_repos", "/repos.{format}", |
|
105 | 105 | action="index", |
|
106 | 106 | conditions=dict(method=["GET"])) |
|
107 | 107 | m.connect("new_repo", "/repos/new", |
|
108 | 108 | action="new", conditions=dict(method=["GET"])) |
|
109 | 109 | m.connect("formatted_new_repo", "/repos/new.{format}", |
|
110 | 110 | action="new", conditions=dict(method=["GET"])) |
|
111 | 111 | m.connect("/repos/{repo_name:.*?}", |
|
112 | 112 | action="update", conditions=dict(method=["PUT"], |
|
113 | 113 | function=check_repo)) |
|
114 | 114 | m.connect("/repos/{repo_name:.*?}", |
|
115 | 115 | action="delete", conditions=dict(method=["DELETE"], |
|
116 | 116 | function=check_repo)) |
|
117 | 117 | # no longer used: |
|
118 | 118 | m.connect("edit_repo_admin", "/repos/{repo_name:.*?}/edit", |
|
119 | 119 | action="edit", conditions=dict(method=["GET"], |
|
120 | 120 | function=check_repo)) |
|
121 | 121 | m.connect("formatted_edit_repo", "/repos/{repo_name:.*?}.{format}/edit", |
|
122 | 122 | action="edit", conditions=dict(method=["GET"], |
|
123 | 123 | function=check_repo)) |
|
124 | 124 | m.connect("repo", "/repos/{repo_name:.*?}", |
|
125 | 125 | action="show", conditions=dict(method=["GET"], |
|
126 | 126 | function=check_repo)) |
|
127 | 127 | m.connect("formatted_repo", "/repos/{repo_name:.*?}.{format}", |
|
128 | 128 | action="show", conditions=dict(method=["GET"], |
|
129 | 129 | function=check_repo)) |
|
130 | 130 | #ajax delete repo perm user |
|
131 | 131 | m.connect('delete_repo_user', "/repos_delete_user/{repo_name:.*?}", |
|
132 | 132 | action="delete_perm_user", |
|
133 | 133 | conditions=dict(method=["DELETE"], function=check_repo)) |
|
134 | 134 | |
|
135 | 135 | #ajax delete repo perm users_group |
|
136 | 136 | m.connect('delete_repo_users_group', |
|
137 | 137 | "/repos_delete_users_group/{repo_name:.*?}", |
|
138 | 138 | action="delete_perm_users_group", |
|
139 | 139 | conditions=dict(method=["DELETE"], function=check_repo)) |
|
140 | 140 | |
|
141 | 141 | #settings actions |
|
142 | 142 | m.connect('repo_stats', "/repos_stats/{repo_name:.*?}", |
|
143 | 143 | action="repo_stats", conditions=dict(method=["DELETE"], |
|
144 | 144 | function=check_repo)) |
|
145 | 145 | m.connect('repo_cache', "/repos_cache/{repo_name:.*?}", |
|
146 | 146 | action="repo_cache", conditions=dict(method=["DELETE"], |
|
147 | 147 | function=check_repo)) |
|
148 | 148 | m.connect('repo_public_journal', "/repos_public_journal/{repo_name:.*?}", |
|
149 | 149 | action="repo_public_journal", conditions=dict(method=["PUT"], |
|
150 | 150 | function=check_repo)) |
|
151 | 151 | m.connect('repo_pull', "/repo_pull/{repo_name:.*?}", |
|
152 | 152 | action="repo_pull", conditions=dict(method=["PUT"], |
|
153 | 153 | function=check_repo)) |
|
154 | 154 | m.connect('repo_as_fork', "/repo_as_fork/{repo_name:.*?}", |
|
155 | 155 | action="repo_as_fork", conditions=dict(method=["PUT"], |
|
156 | 156 | function=check_repo)) |
|
157 | 157 | m.connect('repo_locking', "/repo_locking/{repo_name:.*?}", |
|
158 | 158 | action="repo_locking", conditions=dict(method=["PUT"], |
|
159 | 159 | function=check_repo)) |
|
160 | 160 | #repo fields |
|
161 | 161 | m.connect('create_repo_fields', "/repo_fields/{repo_name:.*?}/new", |
|
162 | 162 | action="create_repo_field", conditions=dict(method=["PUT"], |
|
163 | 163 | function=check_repo)) |
|
164 | 164 | |
|
165 | 165 | m.connect('delete_repo_fields', "/repo_fields/{repo_name:.*?}/{field_id}", |
|
166 | 166 | action="delete_repo_field", conditions=dict(method=["DELETE"], |
|
167 | 167 | function=check_repo)) |
|
168 | 168 | |
|
169 | 169 | with rmap.submapper(path_prefix=ADMIN_PREFIX, |
|
170 | 170 | controller='admin/repos_groups') as m: |
|
171 | 171 | m.connect("repos_groups", "/repos_groups", |
|
172 | 172 | action="create", conditions=dict(method=["POST"])) |
|
173 | 173 | m.connect("repos_groups", "/repos_groups", |
|
174 | 174 | action="index", conditions=dict(method=["GET"])) |
|
175 | 175 | m.connect("formatted_repos_groups", "/repos_groups.{format}", |
|
176 | 176 | action="index", conditions=dict(method=["GET"])) |
|
177 | 177 | m.connect("new_repos_group", "/repos_groups/new", |
|
178 | 178 | action="new", conditions=dict(method=["GET"])) |
|
179 | 179 | m.connect("formatted_new_repos_group", "/repos_groups/new.{format}", |
|
180 | 180 | action="new", conditions=dict(method=["GET"])) |
|
181 | 181 | m.connect("update_repos_group", "/repos_groups/{group_name:.*?}", |
|
182 | 182 | action="update", conditions=dict(method=["PUT"], |
|
183 | 183 | function=check_group)) |
|
184 | 184 | m.connect("delete_repos_group", "/repos_groups/{group_name:.*?}", |
|
185 | 185 | action="delete", conditions=dict(method=["DELETE"], |
|
186 | 186 | function=check_group_skip_path)) |
|
187 | 187 | m.connect("edit_repos_group", "/repos_groups/{group_name:.*?}/edit", |
|
188 | 188 | action="edit", conditions=dict(method=["GET"], |
|
189 | 189 | function=check_group)) |
|
190 | 190 | m.connect("formatted_edit_repos_group", |
|
191 | 191 | "/repos_groups/{group_name:.*?}.{format}/edit", |
|
192 | 192 | action="edit", conditions=dict(method=["GET"], |
|
193 | 193 | function=check_group)) |
|
194 | 194 | m.connect("repos_group", "/repos_groups/{group_name:.*?}", |
|
195 | 195 | action="show", conditions=dict(method=["GET"], |
|
196 | 196 | function=check_group)) |
|
197 | 197 | m.connect("formatted_repos_group", "/repos_groups/{group_name:.*?}.{format}", |
|
198 | 198 | action="show", conditions=dict(method=["GET"], |
|
199 | 199 | function=check_group)) |
|
200 | 200 | # ajax delete repos group perm user |
|
201 | 201 | m.connect('delete_repos_group_user_perm', |
|
202 | 202 | "/delete_repos_group_user_perm/{group_name:.*?}", |
|
203 | 203 | action="delete_repos_group_user_perm", |
|
204 | 204 | conditions=dict(method=["DELETE"], function=check_group)) |
|
205 | 205 | |
|
206 | 206 | # ajax delete repos group perm users_group |
|
207 | 207 | m.connect('delete_repos_group_users_group_perm', |
|
208 | 208 | "/delete_repos_group_users_group_perm/{group_name:.*?}", |
|
209 | 209 | action="delete_repos_group_users_group_perm", |
|
210 | 210 | conditions=dict(method=["DELETE"], function=check_group)) |
|
211 | 211 | |
|
212 | 212 | #ADMIN USER REST ROUTES |
|
213 | 213 | with rmap.submapper(path_prefix=ADMIN_PREFIX, |
|
214 | 214 | controller='admin/users') as m: |
|
215 | 215 | m.connect("users", "/users", |
|
216 | 216 | action="create", conditions=dict(method=["POST"])) |
|
217 | 217 | m.connect("users", "/users", |
|
218 | 218 | action="index", conditions=dict(method=["GET"])) |
|
219 | 219 | m.connect("formatted_users", "/users.{format}", |
|
220 | 220 | action="index", conditions=dict(method=["GET"])) |
|
221 | 221 | m.connect("new_user", "/users/new", |
|
222 | 222 | action="new", conditions=dict(method=["GET"])) |
|
223 | 223 | m.connect("formatted_new_user", "/users/new.{format}", |
|
224 | 224 | action="new", conditions=dict(method=["GET"])) |
|
225 | 225 | m.connect("update_user", "/users/{id}", |
|
226 | 226 | action="update", conditions=dict(method=["PUT"])) |
|
227 | 227 | m.connect("delete_user", "/users/{id}", |
|
228 | 228 | action="delete", conditions=dict(method=["DELETE"])) |
|
229 | 229 | m.connect("edit_user", "/users/{id}/edit", |
|
230 | 230 | action="edit", conditions=dict(method=["GET"])) |
|
231 | 231 | m.connect("formatted_edit_user", |
|
232 | 232 | "/users/{id}.{format}/edit", |
|
233 | 233 | action="edit", conditions=dict(method=["GET"])) |
|
234 | 234 | m.connect("user", "/users/{id}", |
|
235 | 235 | action="show", conditions=dict(method=["GET"])) |
|
236 | 236 | m.connect("formatted_user", "/users/{id}.{format}", |
|
237 | 237 | action="show", conditions=dict(method=["GET"])) |
|
238 | 238 | |
|
239 | 239 | #EXTRAS USER ROUTES |
|
240 | 240 | m.connect("user_perm", "/users_perm/{id}", |
|
241 | 241 | action="update_perm", conditions=dict(method=["PUT"])) |
|
242 | 242 | m.connect("user_emails", "/users_emails/{id}", |
|
243 | 243 | action="add_email", conditions=dict(method=["PUT"])) |
|
244 | 244 | m.connect("user_emails_delete", "/users_emails/{id}", |
|
245 | 245 | action="delete_email", conditions=dict(method=["DELETE"])) |
|
246 | 246 | m.connect("user_ips", "/users_ips/{id}", |
|
247 | 247 | action="add_ip", conditions=dict(method=["PUT"])) |
|
248 | 248 | m.connect("user_ips_delete", "/users_ips/{id}", |
|
249 | 249 | action="delete_ip", conditions=dict(method=["DELETE"])) |
|
250 | 250 | |
|
251 | 251 | #ADMIN USER GROUPS REST ROUTES |
|
252 | 252 | with rmap.submapper(path_prefix=ADMIN_PREFIX, |
|
253 | 253 | controller='admin/users_groups') as m: |
|
254 | 254 | m.connect("users_groups", "/users_groups", |
|
255 | 255 | action="create", conditions=dict(method=["POST"])) |
|
256 | 256 | m.connect("users_groups", "/users_groups", |
|
257 | 257 | action="index", conditions=dict(method=["GET"])) |
|
258 | 258 | m.connect("formatted_users_groups", "/users_groups.{format}", |
|
259 | 259 | action="index", conditions=dict(method=["GET"])) |
|
260 | 260 | m.connect("new_users_group", "/users_groups/new", |
|
261 | 261 | action="new", conditions=dict(method=["GET"])) |
|
262 | 262 | m.connect("formatted_new_users_group", "/users_groups/new.{format}", |
|
263 | 263 | action="new", conditions=dict(method=["GET"])) |
|
264 | 264 | m.connect("update_users_group", "/users_groups/{id}", |
|
265 | 265 | action="update", conditions=dict(method=["PUT"])) |
|
266 | 266 | m.connect("delete_users_group", "/users_groups/{id}", |
|
267 | 267 | action="delete", conditions=dict(method=["DELETE"])) |
|
268 | 268 | m.connect("edit_users_group", "/users_groups/{id}/edit", |
|
269 | 269 | action="edit", conditions=dict(method=["GET"])) |
|
270 | 270 | m.connect("formatted_edit_users_group", |
|
271 | 271 | "/users_groups/{id}.{format}/edit", |
|
272 | 272 | action="edit", conditions=dict(method=["GET"])) |
|
273 | 273 | m.connect("users_group", "/users_groups/{id}", |
|
274 | 274 | action="show", conditions=dict(method=["GET"])) |
|
275 | 275 | m.connect("formatted_users_group", "/users_groups/{id}.{format}", |
|
276 | 276 | action="show", conditions=dict(method=["GET"])) |
|
277 | 277 | |
|
278 | 278 | #EXTRAS USER ROUTES |
|
279 | 279 | m.connect("users_group_perm", "/users_groups_perm/{id}", |
|
280 | 280 | action="update_perm", conditions=dict(method=["PUT"])) |
|
281 | 281 | |
|
282 | 282 | #ADMIN GROUP REST ROUTES |
|
283 | 283 | rmap.resource('group', 'groups', |
|
284 | 284 | controller='admin/groups', path_prefix=ADMIN_PREFIX) |
|
285 | 285 | |
|
286 | 286 | #ADMIN PERMISSIONS REST ROUTES |
|
287 | 287 | rmap.resource('permission', 'permissions', |
|
288 | 288 | controller='admin/permissions', path_prefix=ADMIN_PREFIX) |
|
289 | 289 | |
|
290 | 290 | #ADMIN DEFAULTS REST ROUTES |
|
291 | 291 | rmap.resource('default', 'defaults', |
|
292 | 292 | controller='admin/defaults', path_prefix=ADMIN_PREFIX) |
|
293 | 293 | |
|
294 | 294 | ##ADMIN LDAP SETTINGS |
|
295 | 295 | rmap.connect('ldap_settings', '%s/ldap' % ADMIN_PREFIX, |
|
296 | 296 | controller='admin/ldap_settings', action='ldap_settings', |
|
297 | 297 | conditions=dict(method=["POST"])) |
|
298 | 298 | |
|
299 | 299 | rmap.connect('ldap_home', '%s/ldap' % ADMIN_PREFIX, |
|
300 | 300 | controller='admin/ldap_settings') |
|
301 | 301 | |
|
302 | 302 | #ADMIN SETTINGS REST ROUTES |
|
303 | 303 | with rmap.submapper(path_prefix=ADMIN_PREFIX, |
|
304 | 304 | controller='admin/settings') as m: |
|
305 | 305 | m.connect("admin_settings", "/settings", |
|
306 | 306 | action="create", conditions=dict(method=["POST"])) |
|
307 | 307 | m.connect("admin_settings", "/settings", |
|
308 | 308 | action="index", conditions=dict(method=["GET"])) |
|
309 | 309 | m.connect("formatted_admin_settings", "/settings.{format}", |
|
310 | 310 | action="index", conditions=dict(method=["GET"])) |
|
311 | 311 | m.connect("admin_new_setting", "/settings/new", |
|
312 | 312 | action="new", conditions=dict(method=["GET"])) |
|
313 | 313 | m.connect("formatted_admin_new_setting", "/settings/new.{format}", |
|
314 | 314 | action="new", conditions=dict(method=["GET"])) |
|
315 | 315 | m.connect("/settings/{setting_id}", |
|
316 | 316 | action="update", conditions=dict(method=["PUT"])) |
|
317 | 317 | m.connect("/settings/{setting_id}", |
|
318 | 318 | action="delete", conditions=dict(method=["DELETE"])) |
|
319 | 319 | m.connect("admin_edit_setting", "/settings/{setting_id}/edit", |
|
320 | 320 | action="edit", conditions=dict(method=["GET"])) |
|
321 | 321 | m.connect("formatted_admin_edit_setting", |
|
322 | 322 | "/settings/{setting_id}.{format}/edit", |
|
323 | 323 | action="edit", conditions=dict(method=["GET"])) |
|
324 | 324 | m.connect("admin_setting", "/settings/{setting_id}", |
|
325 | 325 | action="show", conditions=dict(method=["GET"])) |
|
326 | 326 | m.connect("formatted_admin_setting", "/settings/{setting_id}.{format}", |
|
327 | 327 | action="show", conditions=dict(method=["GET"])) |
|
328 | 328 | m.connect("admin_settings_my_account", "/my_account", |
|
329 | 329 | action="my_account", conditions=dict(method=["GET"])) |
|
330 | 330 | m.connect("admin_settings_my_account_update", "/my_account_update", |
|
331 | 331 | action="my_account_update", conditions=dict(method=["PUT"])) |
|
332 | 332 | m.connect("admin_settings_create_repository", "/create_repository", |
|
333 | 333 | action="create_repository", conditions=dict(method=["GET"])) |
|
334 | 334 | m.connect("admin_settings_my_repos", "/my_account/repos", |
|
335 | 335 | action="my_account_my_repos", conditions=dict(method=["GET"])) |
|
336 | 336 | m.connect("admin_settings_my_pullrequests", "/my_account/pull_requests", |
|
337 | 337 | action="my_account_my_pullrequests", conditions=dict(method=["GET"])) |
|
338 | 338 | |
|
339 | 339 | #NOTIFICATION REST ROUTES |
|
340 | 340 | with rmap.submapper(path_prefix=ADMIN_PREFIX, |
|
341 | 341 | controller='admin/notifications') as m: |
|
342 | 342 | m.connect("notifications", "/notifications", |
|
343 | 343 | action="create", conditions=dict(method=["POST"])) |
|
344 | 344 | m.connect("notifications", "/notifications", |
|
345 | 345 | action="index", conditions=dict(method=["GET"])) |
|
346 | 346 | m.connect("notifications_mark_all_read", "/notifications/mark_all_read", |
|
347 | 347 | action="mark_all_read", conditions=dict(method=["GET"])) |
|
348 | 348 | m.connect("formatted_notifications", "/notifications.{format}", |
|
349 | 349 | action="index", conditions=dict(method=["GET"])) |
|
350 | 350 | m.connect("new_notification", "/notifications/new", |
|
351 | 351 | action="new", conditions=dict(method=["GET"])) |
|
352 | 352 | m.connect("formatted_new_notification", "/notifications/new.{format}", |
|
353 | 353 | action="new", conditions=dict(method=["GET"])) |
|
354 | 354 | m.connect("/notification/{notification_id}", |
|
355 | 355 | action="update", conditions=dict(method=["PUT"])) |
|
356 | 356 | m.connect("/notification/{notification_id}", |
|
357 | 357 | action="delete", conditions=dict(method=["DELETE"])) |
|
358 | 358 | m.connect("edit_notification", "/notification/{notification_id}/edit", |
|
359 | 359 | action="edit", conditions=dict(method=["GET"])) |
|
360 | 360 | m.connect("formatted_edit_notification", |
|
361 | 361 | "/notification/{notification_id}.{format}/edit", |
|
362 | 362 | action="edit", conditions=dict(method=["GET"])) |
|
363 | 363 | m.connect("notification", "/notification/{notification_id}", |
|
364 | 364 | action="show", conditions=dict(method=["GET"])) |
|
365 | 365 | m.connect("formatted_notification", "/notifications/{notification_id}.{format}", |
|
366 | 366 | action="show", conditions=dict(method=["GET"])) |
|
367 | 367 | |
|
368 | 368 | #ADMIN MAIN PAGES |
|
369 | 369 | with rmap.submapper(path_prefix=ADMIN_PREFIX, |
|
370 | 370 | controller='admin/admin') as m: |
|
371 | 371 | m.connect('admin_home', '', action='index') |
|
372 | 372 | m.connect('admin_add_repo', '/add_repo/{new_repo:[a-z0-9\. _-]*}', |
|
373 | 373 | action='add_repo') |
|
374 | 374 | |
|
375 | 375 | #========================================================================== |
|
376 | 376 | # API V2 |
|
377 | 377 | #========================================================================== |
|
378 | 378 | with rmap.submapper(path_prefix=ADMIN_PREFIX, |
|
379 | 379 | controller='api/api') as m: |
|
380 | 380 | m.connect('api', '/api') |
|
381 | 381 | |
|
382 | 382 | #USER JOURNAL |
|
383 | 383 | rmap.connect('journal', '%s/journal' % ADMIN_PREFIX, |
|
384 | 384 | controller='journal', action='index') |
|
385 | 385 | rmap.connect('journal_rss', '%s/journal/rss' % ADMIN_PREFIX, |
|
386 | 386 | controller='journal', action='journal_rss') |
|
387 | 387 | rmap.connect('journal_atom', '%s/journal/atom' % ADMIN_PREFIX, |
|
388 | 388 | controller='journal', action='journal_atom') |
|
389 | 389 | |
|
390 | 390 | rmap.connect('public_journal', '%s/public_journal' % ADMIN_PREFIX, |
|
391 | 391 | controller='journal', action="public_journal") |
|
392 | 392 | |
|
393 | 393 | rmap.connect('public_journal_rss', '%s/public_journal/rss' % ADMIN_PREFIX, |
|
394 | 394 | controller='journal', action="public_journal_rss") |
|
395 | 395 | |
|
396 | 396 | rmap.connect('public_journal_rss_old', '%s/public_journal_rss' % ADMIN_PREFIX, |
|
397 | 397 | controller='journal', action="public_journal_rss") |
|
398 | 398 | |
|
399 | 399 | rmap.connect('public_journal_atom', |
|
400 | 400 | '%s/public_journal/atom' % ADMIN_PREFIX, controller='journal', |
|
401 | 401 | action="public_journal_atom") |
|
402 | 402 | |
|
403 | 403 | rmap.connect('public_journal_atom_old', |
|
404 | 404 | '%s/public_journal_atom' % ADMIN_PREFIX, controller='journal', |
|
405 | 405 | action="public_journal_atom") |
|
406 | 406 | |
|
407 | 407 | rmap.connect('toggle_following', '%s/toggle_following' % ADMIN_PREFIX, |
|
408 | 408 | controller='journal', action='toggle_following', |
|
409 | 409 | conditions=dict(method=["POST"])) |
|
410 | 410 | |
|
411 | 411 | #SEARCH |
|
412 | 412 | rmap.connect('search', '%s/search' % ADMIN_PREFIX, controller='search',) |
|
413 | 413 | rmap.connect('search_repo_admin', '%s/search/{repo_name:.*}' % ADMIN_PREFIX, |
|
414 | 414 | controller='search', |
|
415 | 415 | conditions=dict(function=check_repo)) |
|
416 | 416 | rmap.connect('search_repo', '/{repo_name:.*?}/search', |
|
417 | 417 | controller='search', |
|
418 | 418 | conditions=dict(function=check_repo), |
|
419 | 419 | ) |
|
420 | 420 | |
|
421 | 421 | #LOGIN/LOGOUT/REGISTER/SIGN IN |
|
422 | 422 | rmap.connect('login_home', '%s/login' % ADMIN_PREFIX, controller='login') |
|
423 | 423 | rmap.connect('logout_home', '%s/logout' % ADMIN_PREFIX, controller='login', |
|
424 | 424 | action='logout') |
|
425 | 425 | |
|
426 | 426 | rmap.connect('register', '%s/register' % ADMIN_PREFIX, controller='login', |
|
427 | 427 | action='register') |
|
428 | 428 | |
|
429 | 429 | rmap.connect('reset_password', '%s/password_reset' % ADMIN_PREFIX, |
|
430 | 430 | controller='login', action='password_reset') |
|
431 | 431 | |
|
432 | 432 | rmap.connect('reset_password_confirmation', |
|
433 | 433 | '%s/password_reset_confirmation' % ADMIN_PREFIX, |
|
434 | 434 | controller='login', action='password_reset_confirmation') |
|
435 | 435 | |
|
436 | 436 | #FEEDS |
|
437 | 437 | rmap.connect('rss_feed_home', '/{repo_name:.*?}/feed/rss', |
|
438 | 438 | controller='feed', action='rss', |
|
439 | 439 | conditions=dict(function=check_repo)) |
|
440 | 440 | |
|
441 | 441 | rmap.connect('atom_feed_home', '/{repo_name:.*?}/feed/atom', |
|
442 | 442 | controller='feed', action='atom', |
|
443 | 443 | conditions=dict(function=check_repo)) |
|
444 | 444 | |
|
445 | 445 | #========================================================================== |
|
446 | 446 | # REPOSITORY ROUTES |
|
447 | 447 | #========================================================================== |
|
448 | 448 | rmap.connect('summary_home', '/{repo_name:.*?}', |
|
449 | 449 | controller='summary', |
|
450 | 450 | conditions=dict(function=check_repo)) |
|
451 | 451 | |
|
452 | 452 | rmap.connect('repo_size', '/{repo_name:.*?}/repo_size', |
|
453 | 453 | controller='summary', action='repo_size', |
|
454 | 454 | conditions=dict(function=check_repo)) |
|
455 | 455 | |
|
456 | 456 | rmap.connect('repos_group_home', '/{group_name:.*}', |
|
457 | 457 | controller='admin/repos_groups', action="show_by_name", |
|
458 | 458 | conditions=dict(function=check_group)) |
|
459 | 459 | |
|
460 | 460 | rmap.connect('changeset_home', '/{repo_name:.*?}/changeset/{revision}', |
|
461 | 461 | controller='changeset', revision='tip', |
|
462 | 462 | conditions=dict(function=check_repo)) |
|
463 | 463 | |
|
464 | 464 | rmap.connect("edit_repo", "/{repo_name:.*?}/edit", |
|
465 | 465 | controller='admin/repos', action="edit", |
|
466 | 466 | conditions=dict(method=["GET"], function=check_repo) |
|
467 | 467 | ) |
|
468 | 468 | |
|
469 | 469 | #still working url for backward compat. |
|
470 | 470 | rmap.connect('raw_changeset_home_depraced', |
|
471 | 471 | '/{repo_name:.*?}/raw-changeset/{revision}', |
|
472 | 472 | controller='changeset', action='changeset_raw', |
|
473 | 473 | revision='tip', conditions=dict(function=check_repo)) |
|
474 | 474 | |
|
475 | 475 | ## new URLs |
|
476 | 476 | rmap.connect('changeset_raw_home', |
|
477 | 477 | '/{repo_name:.*?}/changeset-diff/{revision}', |
|
478 | 478 | controller='changeset', action='changeset_raw', |
|
479 | 479 | revision='tip', conditions=dict(function=check_repo)) |
|
480 | 480 | |
|
481 | 481 | rmap.connect('changeset_patch_home', |
|
482 | 482 | '/{repo_name:.*?}/changeset-patch/{revision}', |
|
483 | 483 | controller='changeset', action='changeset_patch', |
|
484 | 484 | revision='tip', conditions=dict(function=check_repo)) |
|
485 | 485 | |
|
486 | 486 | rmap.connect('changeset_download_home', |
|
487 | 487 | '/{repo_name:.*?}/changeset-download/{revision}', |
|
488 | 488 | controller='changeset', action='changeset_download', |
|
489 | 489 | revision='tip', conditions=dict(function=check_repo)) |
|
490 | 490 | |
|
491 | 491 | rmap.connect('changeset_comment', |
|
492 | 492 | '/{repo_name:.*?}/changeset/{revision}/comment', |
|
493 | 493 | controller='changeset', revision='tip', action='comment', |
|
494 | 494 | conditions=dict(function=check_repo)) |
|
495 | 495 | |
|
496 | 496 | rmap.connect('changeset_comment_delete', |
|
497 | 497 | '/{repo_name:.*?}/changeset/comment/{comment_id}/delete', |
|
498 | 498 | controller='changeset', action='delete_comment', |
|
499 | 499 | conditions=dict(function=check_repo, method=["DELETE"])) |
|
500 | 500 | |
|
501 | 501 | rmap.connect('changeset_info', '/changeset_info/{repo_name:.*?}/{revision}', |
|
502 | 502 | controller='changeset', action='changeset_info') |
|
503 | 503 | |
|
504 | 504 | rmap.connect('compare_url', |
|
505 | 505 | '/{repo_name:.*?}/compare/{org_ref_type}@{org_ref:.*?}...{other_ref_type}@{other_ref:.*?}', |
|
506 | 506 | controller='compare', action='index', |
|
507 | 507 | conditions=dict(function=check_repo), |
|
508 | 508 | requirements=dict( |
|
509 | 509 | org_ref_type='(branch|book|tag|rev|__other_ref_type__)', |
|
510 | 510 | other_ref_type='(branch|book|tag|rev|__org_ref_type__)') |
|
511 | 511 | ) |
|
512 | 512 | |
|
513 | 513 | rmap.connect('pullrequest_home', |
|
514 | 514 | '/{repo_name:.*?}/pull-request/new', controller='pullrequests', |
|
515 | 515 | action='index', conditions=dict(function=check_repo, |
|
516 | 516 | method=["GET"])) |
|
517 | 517 | |
|
518 | 518 | rmap.connect('pullrequest', |
|
519 | 519 | '/{repo_name:.*?}/pull-request/new', controller='pullrequests', |
|
520 | 520 | action='create', conditions=dict(function=check_repo, |
|
521 | 521 | method=["POST"])) |
|
522 | 522 | |
|
523 | 523 | rmap.connect('pullrequest_show', |
|
524 | 524 | '/{repo_name:.*?}/pull-request/{pull_request_id}', |
|
525 | 525 | controller='pullrequests', |
|
526 | 526 | action='show', conditions=dict(function=check_repo, |
|
527 | 527 | method=["GET"])) |
|
528 | 528 | rmap.connect('pullrequest_update', |
|
529 | 529 | '/{repo_name:.*?}/pull-request/{pull_request_id}', |
|
530 | 530 | controller='pullrequests', |
|
531 | 531 | action='update', conditions=dict(function=check_repo, |
|
532 | 532 | method=["PUT"])) |
|
533 | 533 | rmap.connect('pullrequest_delete', |
|
534 | 534 | '/{repo_name:.*?}/pull-request/{pull_request_id}', |
|
535 | 535 | controller='pullrequests', |
|
536 | 536 | action='delete', conditions=dict(function=check_repo, |
|
537 | 537 | method=["DELETE"])) |
|
538 | 538 | |
|
539 | 539 | rmap.connect('pullrequest_show_all', |
|
540 | 540 | '/{repo_name:.*?}/pull-request', |
|
541 | 541 | controller='pullrequests', |
|
542 | 542 | action='show_all', conditions=dict(function=check_repo, |
|
543 | 543 | method=["GET"])) |
|
544 | 544 | |
|
545 | 545 | rmap.connect('pullrequest_comment', |
|
546 | 546 | '/{repo_name:.*?}/pull-request-comment/{pull_request_id}', |
|
547 | 547 | controller='pullrequests', |
|
548 | 548 | action='comment', conditions=dict(function=check_repo, |
|
549 | 549 | method=["POST"])) |
|
550 | 550 | |
|
551 | 551 | rmap.connect('pullrequest_comment_delete', |
|
552 | 552 | '/{repo_name:.*?}/pull-request-comment/{comment_id}/delete', |
|
553 | 553 | controller='pullrequests', action='delete_comment', |
|
554 | 554 | conditions=dict(function=check_repo, method=["DELETE"])) |
|
555 | 555 | |
|
556 | 556 | rmap.connect('summary_home_summary', '/{repo_name:.*?}/summary', |
|
557 | 557 | controller='summary', conditions=dict(function=check_repo)) |
|
558 | 558 | |
|
559 | 559 | rmap.connect('shortlog_home', '/{repo_name:.*?}/shortlog', |
|
560 | 560 | controller='shortlog', conditions=dict(function=check_repo)) |
|
561 | 561 | |
|
562 | 562 | rmap.connect('shortlog_file_home', '/{repo_name:.*?}/shortlog/{revision}/{f_path:.*}', |
|
563 | 563 | controller='shortlog', f_path=None, |
|
564 | 564 | conditions=dict(function=check_repo)) |
|
565 | 565 | |
|
566 | 566 | rmap.connect('branches_home', '/{repo_name:.*?}/branches', |
|
567 | 567 | controller='branches', conditions=dict(function=check_repo)) |
|
568 | 568 | |
|
569 | 569 | rmap.connect('tags_home', '/{repo_name:.*?}/tags', |
|
570 | 570 | controller='tags', conditions=dict(function=check_repo)) |
|
571 | 571 | |
|
572 | 572 | rmap.connect('bookmarks_home', '/{repo_name:.*?}/bookmarks', |
|
573 | 573 | controller='bookmarks', conditions=dict(function=check_repo)) |
|
574 | 574 | |
|
575 | 575 | rmap.connect('changelog_home', '/{repo_name:.*?}/changelog', |
|
576 | 576 | controller='changelog', conditions=dict(function=check_repo)) |
|
577 | 577 | |
|
578 | 578 | rmap.connect('changelog_details', '/{repo_name:.*?}/changelog_details/{cs}', |
|
579 | 579 | controller='changelog', action='changelog_details', |
|
580 | 580 | conditions=dict(function=check_repo)) |
|
581 | 581 | |
|
582 | 582 | rmap.connect('files_home', '/{repo_name:.*?}/files/{revision}/{f_path:.*}', |
|
583 | 583 | controller='files', revision='tip', f_path='', |
|
584 | 584 | conditions=dict(function=check_repo)) |
|
585 | 585 | |
|
586 | rmap.connect('files_home_nopath', '/{repo_name:.*?}/files/{revision}', | |
|
587 | controller='files', revision='tip', f_path='', | |
|
588 | conditions=dict(function=check_repo)) | |
|
589 | ||
|
586 | 590 | rmap.connect('files_history_home', |
|
587 | 591 | '/{repo_name:.*?}/history/{revision}/{f_path:.*}', |
|
588 | 592 | controller='files', action='history', revision='tip', f_path='', |
|
589 | 593 | conditions=dict(function=check_repo)) |
|
590 | 594 | |
|
591 | 595 | rmap.connect('files_diff_home', '/{repo_name:.*?}/diff/{f_path:.*}', |
|
592 | 596 | controller='files', action='diff', revision='tip', f_path='', |
|
593 | 597 | conditions=dict(function=check_repo)) |
|
594 | 598 | |
|
595 | 599 | rmap.connect('files_rawfile_home', |
|
596 | 600 | '/{repo_name:.*?}/rawfile/{revision}/{f_path:.*}', |
|
597 | 601 | controller='files', action='rawfile', revision='tip', |
|
598 | 602 | f_path='', conditions=dict(function=check_repo)) |
|
599 | 603 | |
|
600 | 604 | rmap.connect('files_raw_home', |
|
601 | 605 | '/{repo_name:.*?}/raw/{revision}/{f_path:.*}', |
|
602 | 606 | controller='files', action='raw', revision='tip', f_path='', |
|
603 | 607 | conditions=dict(function=check_repo)) |
|
604 | 608 | |
|
605 | 609 | rmap.connect('files_annotate_home', |
|
606 | 610 | '/{repo_name:.*?}/annotate/{revision}/{f_path:.*}', |
|
607 | 611 | controller='files', action='index', revision='tip', |
|
608 | 612 | f_path='', annotate=True, conditions=dict(function=check_repo)) |
|
609 | 613 | |
|
610 | 614 | rmap.connect('files_edit_home', |
|
611 | 615 | '/{repo_name:.*?}/edit/{revision}/{f_path:.*}', |
|
612 | 616 | controller='files', action='edit', revision='tip', |
|
613 | 617 | f_path='', conditions=dict(function=check_repo)) |
|
614 | 618 | |
|
615 | 619 | rmap.connect('files_add_home', |
|
616 | 620 | '/{repo_name:.*?}/add/{revision}/{f_path:.*}', |
|
617 | 621 | controller='files', action='add', revision='tip', |
|
618 | 622 | f_path='', conditions=dict(function=check_repo)) |
|
619 | 623 | |
|
620 | 624 | rmap.connect('files_archive_home', '/{repo_name:.*?}/archive/{fname}', |
|
621 | 625 | controller='files', action='archivefile', |
|
622 | 626 | conditions=dict(function=check_repo)) |
|
623 | 627 | |
|
624 | 628 | rmap.connect('files_nodelist_home', |
|
625 | 629 | '/{repo_name:.*?}/nodelist/{revision}/{f_path:.*}', |
|
626 | 630 | controller='files', action='nodelist', |
|
627 | 631 | conditions=dict(function=check_repo)) |
|
628 | 632 | |
|
629 | 633 | rmap.connect('repo_settings_delete', '/{repo_name:.*?}/settings', |
|
630 | 634 | controller='settings', action="delete", |
|
631 | 635 | conditions=dict(method=["DELETE"], function=check_repo)) |
|
632 | 636 | |
|
633 | 637 | rmap.connect('repo_settings_update', '/{repo_name:.*?}/settings', |
|
634 | 638 | controller='settings', action="update", |
|
635 | 639 | conditions=dict(method=["PUT"], function=check_repo)) |
|
636 | 640 | |
|
637 | 641 | rmap.connect('repo_settings_home', '/{repo_name:.*?}/settings', |
|
638 | 642 | controller='settings', action='index', |
|
639 | 643 | conditions=dict(function=check_repo)) |
|
640 | 644 | |
|
641 | 645 | rmap.connect('toggle_locking', "/{repo_name:.*?}/locking_toggle", |
|
642 | 646 | controller='settings', action="toggle_locking", |
|
643 | 647 | conditions=dict(method=["GET"], function=check_repo)) |
|
644 | 648 | |
|
645 | 649 | rmap.connect('repo_fork_create_home', '/{repo_name:.*?}/fork', |
|
646 | 650 | controller='forks', action='fork_create', |
|
647 | 651 | conditions=dict(function=check_repo, method=["POST"])) |
|
648 | 652 | |
|
649 | 653 | rmap.connect('repo_fork_home', '/{repo_name:.*?}/fork', |
|
650 | 654 | controller='forks', action='fork', |
|
651 | 655 | conditions=dict(function=check_repo)) |
|
652 | 656 | |
|
653 | 657 | rmap.connect('repo_forks_home', '/{repo_name:.*?}/forks', |
|
654 | 658 | controller='forks', action='forks', |
|
655 | 659 | conditions=dict(function=check_repo)) |
|
656 | 660 | |
|
657 | 661 | rmap.connect('repo_followers_home', '/{repo_name:.*?}/followers', |
|
658 | 662 | controller='followers', action='followers', |
|
659 | 663 | conditions=dict(function=check_repo)) |
|
660 | 664 | |
|
661 | 665 | return rmap |
General Comments 0
You need to be logged in to leave comments.
Login now