##// END OF EJS Templates
pull-requests: also expose universal url as singular form.
marcink -
r1195:d9fbfd45 default
parent child Browse files
Show More
@@ -1,1167 +1,1169 b''
1 1 # -*- coding: utf-8 -*-
2 2
3 3 # Copyright (C) 2010-2016 RhodeCode GmbH
4 4 #
5 5 # This program is free software: you can redistribute it and/or modify
6 6 # it under the terms of the GNU Affero General Public License, version 3
7 7 # (only), as published by the Free Software Foundation.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU Affero General Public License
15 15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 16 #
17 17 # This program is dual-licensed. If you wish to learn more about the
18 18 # RhodeCode Enterprise Edition, including its added features, Support services,
19 19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20 20
21 21 """
22 22 Routes configuration
23 23
24 24 The more specific and detailed routes should be defined first so they
25 25 may take precedent over the more generic routes. For more information
26 26 refer to the routes manual at http://routes.groovie.org/docs/
27 27
28 28 IMPORTANT: if you change any routing here, make sure to take a look at lib/base.py
29 29 and _route_name variable which uses some of stored naming here to do redirects.
30 30 """
31 31 import os
32 32 import re
33 33 from routes import Mapper
34 34
35 35 from rhodecode.config import routing_links
36 36
37 37 # prefix for non repository related links needs to be prefixed with `/`
38 38 ADMIN_PREFIX = '/_admin'
39 39 STATIC_FILE_PREFIX = '/_static'
40 40
41 41 # Default requirements for URL parts
42 42 URL_NAME_REQUIREMENTS = {
43 43 # group name can have a slash in them, but they must not end with a slash
44 44 'group_name': r'.*?[^/]',
45 45 'repo_group_name': r'.*?[^/]',
46 46 # repo names can have a slash in them, but they must not end with a slash
47 47 'repo_name': r'.*?[^/]',
48 48 # file path eats up everything at the end
49 49 'f_path': r'.*',
50 50 # reference types
51 51 'source_ref_type': '(branch|book|tag|rev|\%\(source_ref_type\)s)',
52 52 'target_ref_type': '(branch|book|tag|rev|\%\(target_ref_type\)s)',
53 53 }
54 54
55 55
56 56 def add_route_requirements(route_path, requirements):
57 57 """
58 58 Adds regex requirements to pyramid routes using a mapping dict
59 59
60 60 >>> add_route_requirements('/{action}/{id}', {'id': r'\d+'})
61 61 '/{action}/{id:\d+}'
62 62
63 63 """
64 64 for key, regex in requirements.items():
65 65 route_path = route_path.replace('{%s}' % key, '{%s:%s}' % (key, regex))
66 66 return route_path
67 67
68 68
69 69 class JSRoutesMapper(Mapper):
70 70 """
71 71 Wrapper for routes.Mapper to make pyroutes compatible url definitions
72 72 """
73 73 _named_route_regex = re.compile(r'^[a-z-_0-9A-Z]+$')
74 74 _argument_prog = re.compile('\{(.*?)\}|:\((.*)\)')
75 75 def __init__(self, *args, **kw):
76 76 super(JSRoutesMapper, self).__init__(*args, **kw)
77 77 self._jsroutes = []
78 78
79 79 def connect(self, *args, **kw):
80 80 """
81 81 Wrapper for connect to take an extra argument jsroute=True
82 82
83 83 :param jsroute: boolean, if True will add the route to the pyroutes list
84 84 """
85 85 if kw.pop('jsroute', False):
86 86 if not self._named_route_regex.match(args[0]):
87 87 raise Exception('only named routes can be added to pyroutes')
88 88 self._jsroutes.append(args[0])
89 89
90 90 super(JSRoutesMapper, self).connect(*args, **kw)
91 91
92 92 def _extract_route_information(self, route):
93 93 """
94 94 Convert a route into tuple(name, path, args), eg:
95 95 ('user_profile', '/profile/%(username)s', ['username'])
96 96 """
97 97 routepath = route.routepath
98 98 def replace(matchobj):
99 99 if matchobj.group(1):
100 100 return "%%(%s)s" % matchobj.group(1).split(':')[0]
101 101 else:
102 102 return "%%(%s)s" % matchobj.group(2)
103 103
104 104 routepath = self._argument_prog.sub(replace, routepath)
105 105 return (
106 106 route.name,
107 107 routepath,
108 108 [(arg[0].split(':')[0] if arg[0] != '' else arg[1])
109 109 for arg in self._argument_prog.findall(route.routepath)]
110 110 )
111 111
112 112 def jsroutes(self):
113 113 """
114 114 Return a list of pyroutes.js compatible routes
115 115 """
116 116 for route_name in self._jsroutes:
117 117 yield self._extract_route_information(self._routenames[route_name])
118 118
119 119
120 120 def make_map(config):
121 121 """Create, configure and return the routes Mapper"""
122 122 rmap = JSRoutesMapper(directory=config['pylons.paths']['controllers'],
123 123 always_scan=config['debug'])
124 124 rmap.minimization = False
125 125 rmap.explicit = False
126 126
127 127 from rhodecode.lib.utils2 import str2bool
128 128 from rhodecode.model import repo, repo_group
129 129
130 130 def check_repo(environ, match_dict):
131 131 """
132 132 check for valid repository for proper 404 handling
133 133
134 134 :param environ:
135 135 :param match_dict:
136 136 """
137 137 repo_name = match_dict.get('repo_name')
138 138
139 139 if match_dict.get('f_path'):
140 140 # fix for multiple initial slashes that causes errors
141 141 match_dict['f_path'] = match_dict['f_path'].lstrip('/')
142 142 repo_model = repo.RepoModel()
143 143 by_name_match = repo_model.get_by_repo_name(repo_name)
144 144 # if we match quickly from database, short circuit the operation,
145 145 # and validate repo based on the type.
146 146 if by_name_match:
147 147 return True
148 148
149 149 by_id_match = repo_model.get_repo_by_id(repo_name)
150 150 if by_id_match:
151 151 repo_name = by_id_match.repo_name
152 152 match_dict['repo_name'] = repo_name
153 153 return True
154 154
155 155 return False
156 156
157 157 def check_group(environ, match_dict):
158 158 """
159 159 check for valid repository group path for proper 404 handling
160 160
161 161 :param environ:
162 162 :param match_dict:
163 163 """
164 164 repo_group_name = match_dict.get('group_name')
165 165 repo_group_model = repo_group.RepoGroupModel()
166 166 by_name_match = repo_group_model.get_by_group_name(repo_group_name)
167 167 if by_name_match:
168 168 return True
169 169
170 170 return False
171 171
172 172 def check_user_group(environ, match_dict):
173 173 """
174 174 check for valid user group for proper 404 handling
175 175
176 176 :param environ:
177 177 :param match_dict:
178 178 """
179 179 return True
180 180
181 181 def check_int(environ, match_dict):
182 182 return match_dict.get('id').isdigit()
183 183
184 184
185 185 #==========================================================================
186 186 # CUSTOM ROUTES HERE
187 187 #==========================================================================
188 188
189 189 # MAIN PAGE
190 190 rmap.connect('home', '/', controller='home', action='index', jsroute=True)
191 191 rmap.connect('goto_switcher_data', '/_goto_data', controller='home',
192 192 action='goto_switcher_data')
193 193 rmap.connect('repo_list_data', '/_repos', controller='home',
194 194 action='repo_list_data')
195 195
196 196 rmap.connect('user_autocomplete_data', '/_users', controller='home',
197 197 action='user_autocomplete_data', jsroute=True)
198 198 rmap.connect('user_group_autocomplete_data', '/_user_groups', controller='home',
199 199 action='user_group_autocomplete_data', jsroute=True)
200 200
201 201 rmap.connect(
202 202 'user_profile', '/_profiles/{username}', controller='users',
203 203 action='user_profile')
204 204
205 205 # TODO: johbo: Static links, to be replaced by our redirection mechanism
206 206 rmap.connect('rst_help',
207 207 'http://docutils.sourceforge.net/docs/user/rst/quickref.html',
208 208 _static=True)
209 209 rmap.connect('markdown_help',
210 210 'http://daringfireball.net/projects/markdown/syntax',
211 211 _static=True)
212 212 rmap.connect('rhodecode_official', 'https://rhodecode.com', _static=True)
213 213 rmap.connect('rhodecode_support', 'https://rhodecode.com/help/', _static=True)
214 214 rmap.connect('rhodecode_translations', 'https://rhodecode.com/translate/enterprise', _static=True)
215 215 # TODO: anderson - making this a static link since redirect won't play
216 216 # nice with POST requests
217 217 rmap.connect('enterprise_license_convert_from_old',
218 218 'https://rhodecode.com/u/license-upgrade',
219 219 _static=True)
220 220
221 221 routing_links.connect_redirection_links(rmap)
222 222
223 223 rmap.connect('ping', '%s/ping' % (ADMIN_PREFIX,), controller='home', action='ping')
224 224 rmap.connect('error_test', '%s/error_test' % (ADMIN_PREFIX,), controller='home', action='error_test')
225 225
226 226 # ADMIN REPOSITORY ROUTES
227 227 with rmap.submapper(path_prefix=ADMIN_PREFIX,
228 228 controller='admin/repos') as m:
229 229 m.connect('repos', '/repos',
230 230 action='create', conditions={'method': ['POST']})
231 231 m.connect('repos', '/repos',
232 232 action='index', conditions={'method': ['GET']})
233 233 m.connect('new_repo', '/create_repository', jsroute=True,
234 234 action='create_repository', conditions={'method': ['GET']})
235 235 m.connect('/repos/{repo_name}',
236 236 action='update', conditions={'method': ['PUT'],
237 237 'function': check_repo},
238 238 requirements=URL_NAME_REQUIREMENTS)
239 239 m.connect('delete_repo', '/repos/{repo_name}',
240 240 action='delete', conditions={'method': ['DELETE']},
241 241 requirements=URL_NAME_REQUIREMENTS)
242 242 m.connect('repo', '/repos/{repo_name}',
243 243 action='show', conditions={'method': ['GET'],
244 244 'function': check_repo},
245 245 requirements=URL_NAME_REQUIREMENTS)
246 246
247 247 # ADMIN REPOSITORY GROUPS ROUTES
248 248 with rmap.submapper(path_prefix=ADMIN_PREFIX,
249 249 controller='admin/repo_groups') as m:
250 250 m.connect('repo_groups', '/repo_groups',
251 251 action='create', conditions={'method': ['POST']})
252 252 m.connect('repo_groups', '/repo_groups',
253 253 action='index', conditions={'method': ['GET']})
254 254 m.connect('new_repo_group', '/repo_groups/new',
255 255 action='new', conditions={'method': ['GET']})
256 256 m.connect('update_repo_group', '/repo_groups/{group_name}',
257 257 action='update', conditions={'method': ['PUT'],
258 258 'function': check_group},
259 259 requirements=URL_NAME_REQUIREMENTS)
260 260
261 261 # EXTRAS REPO GROUP ROUTES
262 262 m.connect('edit_repo_group', '/repo_groups/{group_name}/edit',
263 263 action='edit',
264 264 conditions={'method': ['GET'], 'function': check_group},
265 265 requirements=URL_NAME_REQUIREMENTS)
266 266 m.connect('edit_repo_group', '/repo_groups/{group_name}/edit',
267 267 action='edit',
268 268 conditions={'method': ['PUT'], 'function': check_group},
269 269 requirements=URL_NAME_REQUIREMENTS)
270 270
271 271 m.connect('edit_repo_group_advanced', '/repo_groups/{group_name}/edit/advanced',
272 272 action='edit_repo_group_advanced',
273 273 conditions={'method': ['GET'], 'function': check_group},
274 274 requirements=URL_NAME_REQUIREMENTS)
275 275 m.connect('edit_repo_group_advanced', '/repo_groups/{group_name}/edit/advanced',
276 276 action='edit_repo_group_advanced',
277 277 conditions={'method': ['PUT'], 'function': check_group},
278 278 requirements=URL_NAME_REQUIREMENTS)
279 279
280 280 m.connect('edit_repo_group_perms', '/repo_groups/{group_name}/edit/permissions',
281 281 action='edit_repo_group_perms',
282 282 conditions={'method': ['GET'], 'function': check_group},
283 283 requirements=URL_NAME_REQUIREMENTS)
284 284 m.connect('edit_repo_group_perms', '/repo_groups/{group_name}/edit/permissions',
285 285 action='update_perms',
286 286 conditions={'method': ['PUT'], 'function': check_group},
287 287 requirements=URL_NAME_REQUIREMENTS)
288 288
289 289 m.connect('delete_repo_group', '/repo_groups/{group_name}',
290 290 action='delete', conditions={'method': ['DELETE'],
291 291 'function': check_group},
292 292 requirements=URL_NAME_REQUIREMENTS)
293 293
294 294 # ADMIN USER ROUTES
295 295 with rmap.submapper(path_prefix=ADMIN_PREFIX,
296 296 controller='admin/users') as m:
297 297 m.connect('users', '/users',
298 298 action='create', conditions={'method': ['POST']})
299 299 m.connect('users', '/users',
300 300 action='index', conditions={'method': ['GET']})
301 301 m.connect('new_user', '/users/new',
302 302 action='new', conditions={'method': ['GET']})
303 303 m.connect('update_user', '/users/{user_id}',
304 304 action='update', conditions={'method': ['PUT']})
305 305 m.connect('delete_user', '/users/{user_id}',
306 306 action='delete', conditions={'method': ['DELETE']})
307 307 m.connect('edit_user', '/users/{user_id}/edit',
308 308 action='edit', conditions={'method': ['GET']}, jsroute=True)
309 309 m.connect('user', '/users/{user_id}',
310 310 action='show', conditions={'method': ['GET']})
311 311 m.connect('force_password_reset_user', '/users/{user_id}/password_reset',
312 312 action='reset_password', conditions={'method': ['POST']})
313 313 m.connect('create_personal_repo_group', '/users/{user_id}/create_repo_group',
314 314 action='create_personal_repo_group', conditions={'method': ['POST']})
315 315
316 316 # EXTRAS USER ROUTES
317 317 m.connect('edit_user_advanced', '/users/{user_id}/edit/advanced',
318 318 action='edit_advanced', conditions={'method': ['GET']})
319 319 m.connect('edit_user_advanced', '/users/{user_id}/edit/advanced',
320 320 action='update_advanced', conditions={'method': ['PUT']})
321 321
322 322 m.connect('edit_user_auth_tokens', '/users/{user_id}/edit/auth_tokens',
323 323 action='edit_auth_tokens', conditions={'method': ['GET']})
324 324 m.connect('edit_user_auth_tokens', '/users/{user_id}/edit/auth_tokens',
325 325 action='add_auth_token', conditions={'method': ['PUT']})
326 326 m.connect('edit_user_auth_tokens', '/users/{user_id}/edit/auth_tokens',
327 327 action='delete_auth_token', conditions={'method': ['DELETE']})
328 328
329 329 m.connect('edit_user_global_perms', '/users/{user_id}/edit/global_permissions',
330 330 action='edit_global_perms', conditions={'method': ['GET']})
331 331 m.connect('edit_user_global_perms', '/users/{user_id}/edit/global_permissions',
332 332 action='update_global_perms', conditions={'method': ['PUT']})
333 333
334 334 m.connect('edit_user_perms_summary', '/users/{user_id}/edit/permissions_summary',
335 335 action='edit_perms_summary', conditions={'method': ['GET']})
336 336
337 337 m.connect('edit_user_emails', '/users/{user_id}/edit/emails',
338 338 action='edit_emails', conditions={'method': ['GET']})
339 339 m.connect('edit_user_emails', '/users/{user_id}/edit/emails',
340 340 action='add_email', conditions={'method': ['PUT']})
341 341 m.connect('edit_user_emails', '/users/{user_id}/edit/emails',
342 342 action='delete_email', conditions={'method': ['DELETE']})
343 343
344 344 m.connect('edit_user_ips', '/users/{user_id}/edit/ips',
345 345 action='edit_ips', conditions={'method': ['GET']})
346 346 m.connect('edit_user_ips', '/users/{user_id}/edit/ips',
347 347 action='add_ip', conditions={'method': ['PUT']})
348 348 m.connect('edit_user_ips', '/users/{user_id}/edit/ips',
349 349 action='delete_ip', conditions={'method': ['DELETE']})
350 350
351 351 # ADMIN USER GROUPS REST ROUTES
352 352 with rmap.submapper(path_prefix=ADMIN_PREFIX,
353 353 controller='admin/user_groups') as m:
354 354 m.connect('users_groups', '/user_groups',
355 355 action='create', conditions={'method': ['POST']})
356 356 m.connect('users_groups', '/user_groups',
357 357 action='index', conditions={'method': ['GET']})
358 358 m.connect('new_users_group', '/user_groups/new',
359 359 action='new', conditions={'method': ['GET']})
360 360 m.connect('update_users_group', '/user_groups/{user_group_id}',
361 361 action='update', conditions={'method': ['PUT']})
362 362 m.connect('delete_users_group', '/user_groups/{user_group_id}',
363 363 action='delete', conditions={'method': ['DELETE']})
364 364 m.connect('edit_users_group', '/user_groups/{user_group_id}/edit',
365 365 action='edit', conditions={'method': ['GET']},
366 366 function=check_user_group)
367 367
368 368 # EXTRAS USER GROUP ROUTES
369 369 m.connect('edit_user_group_global_perms',
370 370 '/user_groups/{user_group_id}/edit/global_permissions',
371 371 action='edit_global_perms', conditions={'method': ['GET']})
372 372 m.connect('edit_user_group_global_perms',
373 373 '/user_groups/{user_group_id}/edit/global_permissions',
374 374 action='update_global_perms', conditions={'method': ['PUT']})
375 375 m.connect('edit_user_group_perms_summary',
376 376 '/user_groups/{user_group_id}/edit/permissions_summary',
377 377 action='edit_perms_summary', conditions={'method': ['GET']})
378 378
379 379 m.connect('edit_user_group_perms',
380 380 '/user_groups/{user_group_id}/edit/permissions',
381 381 action='edit_perms', conditions={'method': ['GET']})
382 382 m.connect('edit_user_group_perms',
383 383 '/user_groups/{user_group_id}/edit/permissions',
384 384 action='update_perms', conditions={'method': ['PUT']})
385 385
386 386 m.connect('edit_user_group_advanced',
387 387 '/user_groups/{user_group_id}/edit/advanced',
388 388 action='edit_advanced', conditions={'method': ['GET']})
389 389
390 390 m.connect('edit_user_group_members',
391 391 '/user_groups/{user_group_id}/edit/members', jsroute=True,
392 392 action='user_group_members', conditions={'method': ['GET']})
393 393
394 394 # ADMIN PERMISSIONS ROUTES
395 395 with rmap.submapper(path_prefix=ADMIN_PREFIX,
396 396 controller='admin/permissions') as m:
397 397 m.connect('admin_permissions_application', '/permissions/application',
398 398 action='permission_application_update', conditions={'method': ['POST']})
399 399 m.connect('admin_permissions_application', '/permissions/application',
400 400 action='permission_application', conditions={'method': ['GET']})
401 401
402 402 m.connect('admin_permissions_global', '/permissions/global',
403 403 action='permission_global_update', conditions={'method': ['POST']})
404 404 m.connect('admin_permissions_global', '/permissions/global',
405 405 action='permission_global', conditions={'method': ['GET']})
406 406
407 407 m.connect('admin_permissions_object', '/permissions/object',
408 408 action='permission_objects_update', conditions={'method': ['POST']})
409 409 m.connect('admin_permissions_object', '/permissions/object',
410 410 action='permission_objects', conditions={'method': ['GET']})
411 411
412 412 m.connect('admin_permissions_ips', '/permissions/ips',
413 413 action='permission_ips', conditions={'method': ['POST']})
414 414 m.connect('admin_permissions_ips', '/permissions/ips',
415 415 action='permission_ips', conditions={'method': ['GET']})
416 416
417 417 m.connect('admin_permissions_overview', '/permissions/overview',
418 418 action='permission_perms', conditions={'method': ['GET']})
419 419
420 420 # ADMIN DEFAULTS REST ROUTES
421 421 with rmap.submapper(path_prefix=ADMIN_PREFIX,
422 422 controller='admin/defaults') as m:
423 423 m.connect('admin_defaults_repositories', '/defaults/repositories',
424 424 action='update_repository_defaults', conditions={'method': ['POST']})
425 425 m.connect('admin_defaults_repositories', '/defaults/repositories',
426 426 action='index', conditions={'method': ['GET']})
427 427
428 428 # ADMIN DEBUG STYLE ROUTES
429 429 if str2bool(config.get('debug_style')):
430 430 with rmap.submapper(path_prefix=ADMIN_PREFIX + '/debug_style',
431 431 controller='debug_style') as m:
432 432 m.connect('debug_style_home', '',
433 433 action='index', conditions={'method': ['GET']})
434 434 m.connect('debug_style_template', '/t/{t_path}',
435 435 action='template', conditions={'method': ['GET']})
436 436
437 437 # ADMIN SETTINGS ROUTES
438 438 with rmap.submapper(path_prefix=ADMIN_PREFIX,
439 439 controller='admin/settings') as m:
440 440
441 441 # default
442 442 m.connect('admin_settings', '/settings',
443 443 action='settings_global_update',
444 444 conditions={'method': ['POST']})
445 445 m.connect('admin_settings', '/settings',
446 446 action='settings_global', conditions={'method': ['GET']})
447 447
448 448 m.connect('admin_settings_vcs', '/settings/vcs',
449 449 action='settings_vcs_update',
450 450 conditions={'method': ['POST']})
451 451 m.connect('admin_settings_vcs', '/settings/vcs',
452 452 action='settings_vcs',
453 453 conditions={'method': ['GET']})
454 454 m.connect('admin_settings_vcs', '/settings/vcs',
455 455 action='delete_svn_pattern',
456 456 conditions={'method': ['DELETE']})
457 457
458 458 m.connect('admin_settings_mapping', '/settings/mapping',
459 459 action='settings_mapping_update',
460 460 conditions={'method': ['POST']})
461 461 m.connect('admin_settings_mapping', '/settings/mapping',
462 462 action='settings_mapping', conditions={'method': ['GET']})
463 463
464 464 m.connect('admin_settings_global', '/settings/global',
465 465 action='settings_global_update',
466 466 conditions={'method': ['POST']})
467 467 m.connect('admin_settings_global', '/settings/global',
468 468 action='settings_global', conditions={'method': ['GET']})
469 469
470 470 m.connect('admin_settings_visual', '/settings/visual',
471 471 action='settings_visual_update',
472 472 conditions={'method': ['POST']})
473 473 m.connect('admin_settings_visual', '/settings/visual',
474 474 action='settings_visual', conditions={'method': ['GET']})
475 475
476 476 m.connect('admin_settings_issuetracker',
477 477 '/settings/issue-tracker', action='settings_issuetracker',
478 478 conditions={'method': ['GET']})
479 479 m.connect('admin_settings_issuetracker_save',
480 480 '/settings/issue-tracker/save',
481 481 action='settings_issuetracker_save',
482 482 conditions={'method': ['POST']})
483 483 m.connect('admin_issuetracker_test', '/settings/issue-tracker/test',
484 484 action='settings_issuetracker_test',
485 485 conditions={'method': ['POST']})
486 486 m.connect('admin_issuetracker_delete',
487 487 '/settings/issue-tracker/delete',
488 488 action='settings_issuetracker_delete',
489 489 conditions={'method': ['DELETE']})
490 490
491 491 m.connect('admin_settings_email', '/settings/email',
492 492 action='settings_email_update',
493 493 conditions={'method': ['POST']})
494 494 m.connect('admin_settings_email', '/settings/email',
495 495 action='settings_email', conditions={'method': ['GET']})
496 496
497 497 m.connect('admin_settings_hooks', '/settings/hooks',
498 498 action='settings_hooks_update',
499 499 conditions={'method': ['POST', 'DELETE']})
500 500 m.connect('admin_settings_hooks', '/settings/hooks',
501 501 action='settings_hooks', conditions={'method': ['GET']})
502 502
503 503 m.connect('admin_settings_search', '/settings/search',
504 504 action='settings_search', conditions={'method': ['GET']})
505 505
506 506 m.connect('admin_settings_system', '/settings/system',
507 507 action='settings_system', conditions={'method': ['GET']})
508 508
509 509 m.connect('admin_settings_system_update', '/settings/system/updates',
510 510 action='settings_system_update', conditions={'method': ['GET']})
511 511
512 512 m.connect('admin_settings_supervisor', '/settings/supervisor',
513 513 action='settings_supervisor', conditions={'method': ['GET']})
514 514 m.connect('admin_settings_supervisor_log', '/settings/supervisor/{procid}/log',
515 515 action='settings_supervisor_log', conditions={'method': ['GET']})
516 516
517 517 m.connect('admin_settings_labs', '/settings/labs',
518 518 action='settings_labs_update',
519 519 conditions={'method': ['POST']})
520 520 m.connect('admin_settings_labs', '/settings/labs',
521 521 action='settings_labs', conditions={'method': ['GET']})
522 522
523 523 # ADMIN MY ACCOUNT
524 524 with rmap.submapper(path_prefix=ADMIN_PREFIX,
525 525 controller='admin/my_account') as m:
526 526
527 527 m.connect('my_account', '/my_account',
528 528 action='my_account', conditions={'method': ['GET']})
529 529 m.connect('my_account_edit', '/my_account/edit',
530 530 action='my_account_edit', conditions={'method': ['GET']})
531 531 m.connect('my_account', '/my_account',
532 532 action='my_account_update', conditions={'method': ['POST']})
533 533
534 534 m.connect('my_account_password', '/my_account/password',
535 535 action='my_account_password', conditions={'method': ['GET', 'POST']})
536 536
537 537 m.connect('my_account_repos', '/my_account/repos',
538 538 action='my_account_repos', conditions={'method': ['GET']})
539 539
540 540 m.connect('my_account_watched', '/my_account/watched',
541 541 action='my_account_watched', conditions={'method': ['GET']})
542 542
543 543 m.connect('my_account_pullrequests', '/my_account/pull_requests',
544 544 action='my_account_pullrequests', conditions={'method': ['GET']})
545 545
546 546 m.connect('my_account_perms', '/my_account/perms',
547 547 action='my_account_perms', conditions={'method': ['GET']})
548 548
549 549 m.connect('my_account_emails', '/my_account/emails',
550 550 action='my_account_emails', conditions={'method': ['GET']})
551 551 m.connect('my_account_emails', '/my_account/emails',
552 552 action='my_account_emails_add', conditions={'method': ['POST']})
553 553 m.connect('my_account_emails', '/my_account/emails',
554 554 action='my_account_emails_delete', conditions={'method': ['DELETE']})
555 555
556 556 m.connect('my_account_auth_tokens', '/my_account/auth_tokens',
557 557 action='my_account_auth_tokens', conditions={'method': ['GET']})
558 558 m.connect('my_account_auth_tokens', '/my_account/auth_tokens',
559 559 action='my_account_auth_tokens_add', conditions={'method': ['POST']})
560 560 m.connect('my_account_auth_tokens', '/my_account/auth_tokens',
561 561 action='my_account_auth_tokens_delete', conditions={'method': ['DELETE']})
562 562 m.connect('my_account_notifications', '/my_account/notifications',
563 563 action='my_notifications',
564 564 conditions={'method': ['GET']})
565 565 m.connect('my_account_notifications_toggle_visibility',
566 566 '/my_account/toggle_visibility',
567 567 action='my_notifications_toggle_visibility',
568 568 conditions={'method': ['POST']})
569 569
570 570 # NOTIFICATION REST ROUTES
571 571 with rmap.submapper(path_prefix=ADMIN_PREFIX,
572 572 controller='admin/notifications') as m:
573 573 m.connect('notifications', '/notifications',
574 574 action='index', conditions={'method': ['GET']})
575 575 m.connect('notifications_mark_all_read', '/notifications/mark_all_read',
576 576 action='mark_all_read', conditions={'method': ['POST']})
577 577 m.connect('/notifications/{notification_id}',
578 578 action='update', conditions={'method': ['PUT']})
579 579 m.connect('/notifications/{notification_id}',
580 580 action='delete', conditions={'method': ['DELETE']})
581 581 m.connect('notification', '/notifications/{notification_id}',
582 582 action='show', conditions={'method': ['GET']})
583 583
584 584 # ADMIN GIST
585 585 with rmap.submapper(path_prefix=ADMIN_PREFIX,
586 586 controller='admin/gists') as m:
587 587 m.connect('gists', '/gists',
588 588 action='create', conditions={'method': ['POST']})
589 589 m.connect('gists', '/gists', jsroute=True,
590 590 action='index', conditions={'method': ['GET']})
591 591 m.connect('new_gist', '/gists/new', jsroute=True,
592 592 action='new', conditions={'method': ['GET']})
593 593
594 594 m.connect('/gists/{gist_id}',
595 595 action='delete', conditions={'method': ['DELETE']})
596 596 m.connect('edit_gist', '/gists/{gist_id}/edit',
597 597 action='edit_form', conditions={'method': ['GET']})
598 598 m.connect('edit_gist', '/gists/{gist_id}/edit',
599 599 action='edit', conditions={'method': ['POST']})
600 600 m.connect(
601 601 'edit_gist_check_revision', '/gists/{gist_id}/edit/check_revision',
602 602 action='check_revision', conditions={'method': ['GET']})
603 603
604 604 m.connect('gist', '/gists/{gist_id}',
605 605 action='show', conditions={'method': ['GET']})
606 606 m.connect('gist_rev', '/gists/{gist_id}/{revision}',
607 607 revision='tip',
608 608 action='show', conditions={'method': ['GET']})
609 609 m.connect('formatted_gist', '/gists/{gist_id}/{revision}/{format}',
610 610 revision='tip',
611 611 action='show', conditions={'method': ['GET']})
612 612 m.connect('formatted_gist_file', '/gists/{gist_id}/{revision}/{format}/{f_path}',
613 613 revision='tip',
614 614 action='show', conditions={'method': ['GET']},
615 615 requirements=URL_NAME_REQUIREMENTS)
616 616
617 617 # ADMIN MAIN PAGES
618 618 with rmap.submapper(path_prefix=ADMIN_PREFIX,
619 619 controller='admin/admin') as m:
620 620 m.connect('admin_home', '', action='index')
621 621 m.connect('admin_add_repo', '/add_repo/{new_repo:[a-z0-9\. _-]*}',
622 622 action='add_repo')
623 623 m.connect(
624 624 'pull_requests_global_0', '/pull_requests/{pull_request_id:[0-9]+}',
625 625 action='pull_requests')
626 626 m.connect(
627 'pull_requests_global', '/pull-requests/{pull_request_id:[0-9]+}',
627 'pull_requests_global_1', '/pull-requests/{pull_request_id:[0-9]+}',
628 628 action='pull_requests')
629
629 m.connect(
630 'pull_requests_global', '/pull-request/{pull_request_id:[0-9]+}',
631 action='pull_requests')
630 632
631 633 # USER JOURNAL
632 634 rmap.connect('journal', '%s/journal' % (ADMIN_PREFIX,),
633 635 controller='journal', action='index')
634 636 rmap.connect('journal_rss', '%s/journal/rss' % (ADMIN_PREFIX,),
635 637 controller='journal', action='journal_rss')
636 638 rmap.connect('journal_atom', '%s/journal/atom' % (ADMIN_PREFIX,),
637 639 controller='journal', action='journal_atom')
638 640
639 641 rmap.connect('public_journal', '%s/public_journal' % (ADMIN_PREFIX,),
640 642 controller='journal', action='public_journal')
641 643
642 644 rmap.connect('public_journal_rss', '%s/public_journal/rss' % (ADMIN_PREFIX,),
643 645 controller='journal', action='public_journal_rss')
644 646
645 647 rmap.connect('public_journal_rss_old', '%s/public_journal_rss' % (ADMIN_PREFIX,),
646 648 controller='journal', action='public_journal_rss')
647 649
648 650 rmap.connect('public_journal_atom',
649 651 '%s/public_journal/atom' % (ADMIN_PREFIX,), controller='journal',
650 652 action='public_journal_atom')
651 653
652 654 rmap.connect('public_journal_atom_old',
653 655 '%s/public_journal_atom' % (ADMIN_PREFIX,), controller='journal',
654 656 action='public_journal_atom')
655 657
656 658 rmap.connect('toggle_following', '%s/toggle_following' % (ADMIN_PREFIX,),
657 659 controller='journal', action='toggle_following', jsroute=True,
658 660 conditions={'method': ['POST']})
659 661
660 662 # FULL TEXT SEARCH
661 663 rmap.connect('search', '%s/search' % (ADMIN_PREFIX,),
662 664 controller='search')
663 665 rmap.connect('search_repo_home', '/{repo_name}/search',
664 666 controller='search',
665 667 action='index',
666 668 conditions={'function': check_repo},
667 669 requirements=URL_NAME_REQUIREMENTS)
668 670
669 671 # FEEDS
670 672 rmap.connect('rss_feed_home', '/{repo_name}/feed/rss',
671 673 controller='feed', action='rss',
672 674 conditions={'function': check_repo},
673 675 requirements=URL_NAME_REQUIREMENTS)
674 676
675 677 rmap.connect('atom_feed_home', '/{repo_name}/feed/atom',
676 678 controller='feed', action='atom',
677 679 conditions={'function': check_repo},
678 680 requirements=URL_NAME_REQUIREMENTS)
679 681
680 682 #==========================================================================
681 683 # REPOSITORY ROUTES
682 684 #==========================================================================
683 685
684 686 rmap.connect('repo_creating_home', '/{repo_name}/repo_creating',
685 687 controller='admin/repos', action='repo_creating',
686 688 requirements=URL_NAME_REQUIREMENTS)
687 689 rmap.connect('repo_check_home', '/{repo_name}/crepo_check',
688 690 controller='admin/repos', action='repo_check',
689 691 requirements=URL_NAME_REQUIREMENTS)
690 692
691 693 rmap.connect('repo_stats', '/{repo_name}/repo_stats/{commit_id}',
692 694 controller='summary', action='repo_stats',
693 695 conditions={'function': check_repo},
694 696 requirements=URL_NAME_REQUIREMENTS, jsroute=True)
695 697
696 698 rmap.connect('repo_refs_data', '/{repo_name}/refs-data',
697 699 controller='summary', action='repo_refs_data', jsroute=True,
698 700 requirements=URL_NAME_REQUIREMENTS)
699 701 rmap.connect('repo_refs_changelog_data', '/{repo_name}/refs-data-changelog',
700 702 controller='summary', action='repo_refs_changelog_data',
701 703 requirements=URL_NAME_REQUIREMENTS, jsroute=True)
702 704 rmap.connect('repo_default_reviewers_data', '/{repo_name}/default-reviewers',
703 705 controller='summary', action='repo_default_reviewers_data',
704 706 jsroute=True, requirements=URL_NAME_REQUIREMENTS)
705 707
706 708 rmap.connect('changeset_home', '/{repo_name}/changeset/{revision}',
707 709 controller='changeset', revision='tip', jsroute=True,
708 710 conditions={'function': check_repo},
709 711 requirements=URL_NAME_REQUIREMENTS)
710 712 rmap.connect('changeset_children', '/{repo_name}/changeset_children/{revision}',
711 713 controller='changeset', revision='tip', action='changeset_children',
712 714 conditions={'function': check_repo},
713 715 requirements=URL_NAME_REQUIREMENTS)
714 716 rmap.connect('changeset_parents', '/{repo_name}/changeset_parents/{revision}',
715 717 controller='changeset', revision='tip', action='changeset_parents',
716 718 conditions={'function': check_repo},
717 719 requirements=URL_NAME_REQUIREMENTS)
718 720
719 721 # repo edit options
720 722 rmap.connect('edit_repo', '/{repo_name}/settings', jsroute=True,
721 723 controller='admin/repos', action='edit',
722 724 conditions={'method': ['GET'], 'function': check_repo},
723 725 requirements=URL_NAME_REQUIREMENTS)
724 726
725 727 rmap.connect('edit_repo_perms', '/{repo_name}/settings/permissions',
726 728 jsroute=True,
727 729 controller='admin/repos', action='edit_permissions',
728 730 conditions={'method': ['GET'], 'function': check_repo},
729 731 requirements=URL_NAME_REQUIREMENTS)
730 732 rmap.connect('edit_repo_perms_update', '/{repo_name}/settings/permissions',
731 733 controller='admin/repos', action='edit_permissions_update',
732 734 conditions={'method': ['PUT'], 'function': check_repo},
733 735 requirements=URL_NAME_REQUIREMENTS)
734 736
735 737 rmap.connect('edit_repo_fields', '/{repo_name}/settings/fields',
736 738 controller='admin/repos', action='edit_fields',
737 739 conditions={'method': ['GET'], 'function': check_repo},
738 740 requirements=URL_NAME_REQUIREMENTS)
739 741 rmap.connect('create_repo_fields', '/{repo_name}/settings/fields/new',
740 742 controller='admin/repos', action='create_repo_field',
741 743 conditions={'method': ['PUT'], 'function': check_repo},
742 744 requirements=URL_NAME_REQUIREMENTS)
743 745 rmap.connect('delete_repo_fields', '/{repo_name}/settings/fields/{field_id}',
744 746 controller='admin/repos', action='delete_repo_field',
745 747 conditions={'method': ['DELETE'], 'function': check_repo},
746 748 requirements=URL_NAME_REQUIREMENTS)
747 749
748 750 rmap.connect('edit_repo_advanced', '/{repo_name}/settings/advanced',
749 751 controller='admin/repos', action='edit_advanced',
750 752 conditions={'method': ['GET'], 'function': check_repo},
751 753 requirements=URL_NAME_REQUIREMENTS)
752 754
753 755 rmap.connect('edit_repo_advanced_locking', '/{repo_name}/settings/advanced/locking',
754 756 controller='admin/repos', action='edit_advanced_locking',
755 757 conditions={'method': ['PUT'], 'function': check_repo},
756 758 requirements=URL_NAME_REQUIREMENTS)
757 759 rmap.connect('toggle_locking', '/{repo_name}/settings/advanced/locking_toggle',
758 760 controller='admin/repos', action='toggle_locking',
759 761 conditions={'method': ['GET'], 'function': check_repo},
760 762 requirements=URL_NAME_REQUIREMENTS)
761 763
762 764 rmap.connect('edit_repo_advanced_journal', '/{repo_name}/settings/advanced/journal',
763 765 controller='admin/repos', action='edit_advanced_journal',
764 766 conditions={'method': ['PUT'], 'function': check_repo},
765 767 requirements=URL_NAME_REQUIREMENTS)
766 768
767 769 rmap.connect('edit_repo_advanced_fork', '/{repo_name}/settings/advanced/fork',
768 770 controller='admin/repos', action='edit_advanced_fork',
769 771 conditions={'method': ['PUT'], 'function': check_repo},
770 772 requirements=URL_NAME_REQUIREMENTS)
771 773
772 774 rmap.connect('edit_repo_caches', '/{repo_name}/settings/caches',
773 775 controller='admin/repos', action='edit_caches_form',
774 776 conditions={'method': ['GET'], 'function': check_repo},
775 777 requirements=URL_NAME_REQUIREMENTS)
776 778 rmap.connect('edit_repo_caches', '/{repo_name}/settings/caches',
777 779 controller='admin/repos', action='edit_caches',
778 780 conditions={'method': ['PUT'], 'function': check_repo},
779 781 requirements=URL_NAME_REQUIREMENTS)
780 782
781 783 rmap.connect('edit_repo_remote', '/{repo_name}/settings/remote',
782 784 controller='admin/repos', action='edit_remote_form',
783 785 conditions={'method': ['GET'], 'function': check_repo},
784 786 requirements=URL_NAME_REQUIREMENTS)
785 787 rmap.connect('edit_repo_remote', '/{repo_name}/settings/remote',
786 788 controller='admin/repos', action='edit_remote',
787 789 conditions={'method': ['PUT'], 'function': check_repo},
788 790 requirements=URL_NAME_REQUIREMENTS)
789 791
790 792 rmap.connect('edit_repo_statistics', '/{repo_name}/settings/statistics',
791 793 controller='admin/repos', action='edit_statistics_form',
792 794 conditions={'method': ['GET'], 'function': check_repo},
793 795 requirements=URL_NAME_REQUIREMENTS)
794 796 rmap.connect('edit_repo_statistics', '/{repo_name}/settings/statistics',
795 797 controller='admin/repos', action='edit_statistics',
796 798 conditions={'method': ['PUT'], 'function': check_repo},
797 799 requirements=URL_NAME_REQUIREMENTS)
798 800 rmap.connect('repo_settings_issuetracker',
799 801 '/{repo_name}/settings/issue-tracker',
800 802 controller='admin/repos', action='repo_issuetracker',
801 803 conditions={'method': ['GET'], 'function': check_repo},
802 804 requirements=URL_NAME_REQUIREMENTS)
803 805 rmap.connect('repo_issuetracker_test',
804 806 '/{repo_name}/settings/issue-tracker/test',
805 807 controller='admin/repos', action='repo_issuetracker_test',
806 808 conditions={'method': ['POST'], 'function': check_repo},
807 809 requirements=URL_NAME_REQUIREMENTS)
808 810 rmap.connect('repo_issuetracker_delete',
809 811 '/{repo_name}/settings/issue-tracker/delete',
810 812 controller='admin/repos', action='repo_issuetracker_delete',
811 813 conditions={'method': ['DELETE'], 'function': check_repo},
812 814 requirements=URL_NAME_REQUIREMENTS)
813 815 rmap.connect('repo_issuetracker_save',
814 816 '/{repo_name}/settings/issue-tracker/save',
815 817 controller='admin/repos', action='repo_issuetracker_save',
816 818 conditions={'method': ['POST'], 'function': check_repo},
817 819 requirements=URL_NAME_REQUIREMENTS)
818 820 rmap.connect('repo_vcs_settings', '/{repo_name}/settings/vcs',
819 821 controller='admin/repos', action='repo_settings_vcs_update',
820 822 conditions={'method': ['POST'], 'function': check_repo},
821 823 requirements=URL_NAME_REQUIREMENTS)
822 824 rmap.connect('repo_vcs_settings', '/{repo_name}/settings/vcs',
823 825 controller='admin/repos', action='repo_settings_vcs',
824 826 conditions={'method': ['GET'], 'function': check_repo},
825 827 requirements=URL_NAME_REQUIREMENTS)
826 828 rmap.connect('repo_vcs_settings', '/{repo_name}/settings/vcs',
827 829 controller='admin/repos', action='repo_delete_svn_pattern',
828 830 conditions={'method': ['DELETE'], 'function': check_repo},
829 831 requirements=URL_NAME_REQUIREMENTS)
830 832 rmap.connect('repo_pullrequest_settings', '/{repo_name}/settings/pullrequest',
831 833 controller='admin/repos', action='repo_settings_pullrequest',
832 834 conditions={'method': ['GET', 'POST'], 'function': check_repo},
833 835 requirements=URL_NAME_REQUIREMENTS)
834 836
835 837 # still working url for backward compat.
836 838 rmap.connect('raw_changeset_home_depraced',
837 839 '/{repo_name}/raw-changeset/{revision}',
838 840 controller='changeset', action='changeset_raw',
839 841 revision='tip', conditions={'function': check_repo},
840 842 requirements=URL_NAME_REQUIREMENTS)
841 843
842 844 # new URLs
843 845 rmap.connect('changeset_raw_home',
844 846 '/{repo_name}/changeset-diff/{revision}',
845 847 controller='changeset', action='changeset_raw',
846 848 revision='tip', conditions={'function': check_repo},
847 849 requirements=URL_NAME_REQUIREMENTS)
848 850
849 851 rmap.connect('changeset_patch_home',
850 852 '/{repo_name}/changeset-patch/{revision}',
851 853 controller='changeset', action='changeset_patch',
852 854 revision='tip', conditions={'function': check_repo},
853 855 requirements=URL_NAME_REQUIREMENTS)
854 856
855 857 rmap.connect('changeset_download_home',
856 858 '/{repo_name}/changeset-download/{revision}',
857 859 controller='changeset', action='changeset_download',
858 860 revision='tip', conditions={'function': check_repo},
859 861 requirements=URL_NAME_REQUIREMENTS)
860 862
861 863 rmap.connect('changeset_comment',
862 864 '/{repo_name}/changeset/{revision}/comment', jsroute=True,
863 865 controller='changeset', revision='tip', action='comment',
864 866 conditions={'function': check_repo},
865 867 requirements=URL_NAME_REQUIREMENTS)
866 868
867 869 rmap.connect('changeset_comment_preview',
868 870 '/{repo_name}/changeset/comment/preview', jsroute=True,
869 871 controller='changeset', action='preview_comment',
870 872 conditions={'function': check_repo, 'method': ['POST']},
871 873 requirements=URL_NAME_REQUIREMENTS)
872 874
873 875 rmap.connect('changeset_comment_delete',
874 876 '/{repo_name}/changeset/comment/{comment_id}/delete',
875 877 controller='changeset', action='delete_comment',
876 878 conditions={'function': check_repo, 'method': ['DELETE']},
877 879 requirements=URL_NAME_REQUIREMENTS, jsroute=True)
878 880
879 881 rmap.connect('changeset_info', '/{repo_name}/changeset_info/{revision}',
880 882 controller='changeset', action='changeset_info',
881 883 requirements=URL_NAME_REQUIREMENTS, jsroute=True)
882 884
883 885 rmap.connect('compare_home',
884 886 '/{repo_name}/compare',
885 887 controller='compare', action='index',
886 888 conditions={'function': check_repo},
887 889 requirements=URL_NAME_REQUIREMENTS)
888 890
889 891 rmap.connect('compare_url',
890 892 '/{repo_name}/compare/{source_ref_type}@{source_ref:.*?}...{target_ref_type}@{target_ref:.*?}',
891 893 controller='compare', action='compare',
892 894 conditions={'function': check_repo},
893 895 requirements=URL_NAME_REQUIREMENTS, jsroute=True)
894 896
895 897 rmap.connect('pullrequest_home',
896 898 '/{repo_name}/pull-request/new', controller='pullrequests',
897 899 action='index', conditions={'function': check_repo,
898 900 'method': ['GET']},
899 901 requirements=URL_NAME_REQUIREMENTS, jsroute=True)
900 902
901 903 rmap.connect('pullrequest',
902 904 '/{repo_name}/pull-request/new', controller='pullrequests',
903 905 action='create', conditions={'function': check_repo,
904 906 'method': ['POST']},
905 907 requirements=URL_NAME_REQUIREMENTS, jsroute=True)
906 908
907 909 rmap.connect('pullrequest_repo_refs',
908 910 '/{repo_name}/pull-request/refs/{target_repo_name:.*?[^/]}',
909 911 controller='pullrequests',
910 912 action='get_repo_refs',
911 913 conditions={'function': check_repo, 'method': ['GET']},
912 914 requirements=URL_NAME_REQUIREMENTS, jsroute=True)
913 915
914 916 rmap.connect('pullrequest_repo_destinations',
915 917 '/{repo_name}/pull-request/repo-destinations',
916 918 controller='pullrequests',
917 919 action='get_repo_destinations',
918 920 conditions={'function': check_repo, 'method': ['GET']},
919 921 requirements=URL_NAME_REQUIREMENTS, jsroute=True)
920 922
921 923 rmap.connect('pullrequest_show',
922 924 '/{repo_name}/pull-request/{pull_request_id}',
923 925 controller='pullrequests',
924 926 action='show', conditions={'function': check_repo,
925 927 'method': ['GET']},
926 928 requirements=URL_NAME_REQUIREMENTS)
927 929
928 930 rmap.connect('pullrequest_update',
929 931 '/{repo_name}/pull-request/{pull_request_id}',
930 932 controller='pullrequests',
931 933 action='update', conditions={'function': check_repo,
932 934 'method': ['PUT']},
933 935 requirements=URL_NAME_REQUIREMENTS, jsroute=True)
934 936
935 937 rmap.connect('pullrequest_merge',
936 938 '/{repo_name}/pull-request/{pull_request_id}',
937 939 controller='pullrequests',
938 940 action='merge', conditions={'function': check_repo,
939 941 'method': ['POST']},
940 942 requirements=URL_NAME_REQUIREMENTS)
941 943
942 944 rmap.connect('pullrequest_delete',
943 945 '/{repo_name}/pull-request/{pull_request_id}',
944 946 controller='pullrequests',
945 947 action='delete', conditions={'function': check_repo,
946 948 'method': ['DELETE']},
947 949 requirements=URL_NAME_REQUIREMENTS)
948 950
949 951 rmap.connect('pullrequest_show_all',
950 952 '/{repo_name}/pull-request',
951 953 controller='pullrequests',
952 954 action='show_all', conditions={'function': check_repo,
953 955 'method': ['GET']},
954 956 requirements=URL_NAME_REQUIREMENTS, jsroute=True)
955 957
956 958 rmap.connect('pullrequest_comment',
957 959 '/{repo_name}/pull-request-comment/{pull_request_id}',
958 960 controller='pullrequests',
959 961 action='comment', conditions={'function': check_repo,
960 962 'method': ['POST']},
961 963 requirements=URL_NAME_REQUIREMENTS, jsroute=True)
962 964
963 965 rmap.connect('pullrequest_comment_delete',
964 966 '/{repo_name}/pull-request-comment/{comment_id}/delete',
965 967 controller='pullrequests', action='delete_comment',
966 968 conditions={'function': check_repo, 'method': ['DELETE']},
967 969 requirements=URL_NAME_REQUIREMENTS, jsroute=True)
968 970
969 971 rmap.connect('summary_home_explicit', '/{repo_name}/summary',
970 972 controller='summary', conditions={'function': check_repo},
971 973 requirements=URL_NAME_REQUIREMENTS)
972 974
973 975 rmap.connect('branches_home', '/{repo_name}/branches',
974 976 controller='branches', conditions={'function': check_repo},
975 977 requirements=URL_NAME_REQUIREMENTS)
976 978
977 979 rmap.connect('tags_home', '/{repo_name}/tags',
978 980 controller='tags', conditions={'function': check_repo},
979 981 requirements=URL_NAME_REQUIREMENTS)
980 982
981 983 rmap.connect('bookmarks_home', '/{repo_name}/bookmarks',
982 984 controller='bookmarks', conditions={'function': check_repo},
983 985 requirements=URL_NAME_REQUIREMENTS)
984 986
985 987 rmap.connect('changelog_home', '/{repo_name}/changelog', jsroute=True,
986 988 controller='changelog', conditions={'function': check_repo},
987 989 requirements=URL_NAME_REQUIREMENTS)
988 990
989 991 rmap.connect('changelog_summary_home', '/{repo_name}/changelog_summary',
990 992 controller='changelog', action='changelog_summary',
991 993 conditions={'function': check_repo},
992 994 requirements=URL_NAME_REQUIREMENTS)
993 995
994 996 rmap.connect('changelog_file_home',
995 997 '/{repo_name}/changelog/{revision}/{f_path}',
996 998 controller='changelog', f_path=None,
997 999 conditions={'function': check_repo},
998 1000 requirements=URL_NAME_REQUIREMENTS, jsroute=True)
999 1001
1000 1002 rmap.connect('changelog_details', '/{repo_name}/changelog_details/{cs}',
1001 1003 controller='changelog', action='changelog_details',
1002 1004 conditions={'function': check_repo},
1003 1005 requirements=URL_NAME_REQUIREMENTS)
1004 1006
1005 1007 rmap.connect('files_home', '/{repo_name}/files/{revision}/{f_path}',
1006 1008 controller='files', revision='tip', f_path='',
1007 1009 conditions={'function': check_repo},
1008 1010 requirements=URL_NAME_REQUIREMENTS, jsroute=True)
1009 1011
1010 1012 rmap.connect('files_home_simple_catchrev',
1011 1013 '/{repo_name}/files/{revision}',
1012 1014 controller='files', revision='tip', f_path='',
1013 1015 conditions={'function': check_repo},
1014 1016 requirements=URL_NAME_REQUIREMENTS)
1015 1017
1016 1018 rmap.connect('files_home_simple_catchall',
1017 1019 '/{repo_name}/files',
1018 1020 controller='files', revision='tip', f_path='',
1019 1021 conditions={'function': check_repo},
1020 1022 requirements=URL_NAME_REQUIREMENTS)
1021 1023
1022 1024 rmap.connect('files_history_home',
1023 1025 '/{repo_name}/history/{revision}/{f_path}',
1024 1026 controller='files', action='history', revision='tip', f_path='',
1025 1027 conditions={'function': check_repo},
1026 1028 requirements=URL_NAME_REQUIREMENTS, jsroute=True)
1027 1029
1028 1030 rmap.connect('files_authors_home',
1029 1031 '/{repo_name}/authors/{revision}/{f_path}',
1030 1032 controller='files', action='authors', revision='tip', f_path='',
1031 1033 conditions={'function': check_repo},
1032 1034 requirements=URL_NAME_REQUIREMENTS, jsroute=True)
1033 1035
1034 1036 rmap.connect('files_diff_home', '/{repo_name}/diff/{f_path}',
1035 1037 controller='files', action='diff', f_path='',
1036 1038 conditions={'function': check_repo},
1037 1039 requirements=URL_NAME_REQUIREMENTS)
1038 1040
1039 1041 rmap.connect('files_diff_2way_home',
1040 1042 '/{repo_name}/diff-2way/{f_path}',
1041 1043 controller='files', action='diff_2way', f_path='',
1042 1044 conditions={'function': check_repo},
1043 1045 requirements=URL_NAME_REQUIREMENTS)
1044 1046
1045 1047 rmap.connect('files_rawfile_home',
1046 1048 '/{repo_name}/rawfile/{revision}/{f_path}',
1047 1049 controller='files', action='rawfile', revision='tip',
1048 1050 f_path='', conditions={'function': check_repo},
1049 1051 requirements=URL_NAME_REQUIREMENTS)
1050 1052
1051 1053 rmap.connect('files_raw_home',
1052 1054 '/{repo_name}/raw/{revision}/{f_path}',
1053 1055 controller='files', action='raw', revision='tip', f_path='',
1054 1056 conditions={'function': check_repo},
1055 1057 requirements=URL_NAME_REQUIREMENTS)
1056 1058
1057 1059 rmap.connect('files_render_home',
1058 1060 '/{repo_name}/render/{revision}/{f_path}',
1059 1061 controller='files', action='index', revision='tip', f_path='',
1060 1062 rendered=True, conditions={'function': check_repo},
1061 1063 requirements=URL_NAME_REQUIREMENTS)
1062 1064
1063 1065 rmap.connect('files_annotate_home',
1064 1066 '/{repo_name}/annotate/{revision}/{f_path}',
1065 1067 controller='files', action='index', revision='tip',
1066 1068 f_path='', annotate=True, conditions={'function': check_repo},
1067 1069 requirements=URL_NAME_REQUIREMENTS)
1068 1070
1069 1071 rmap.connect('files_edit',
1070 1072 '/{repo_name}/edit/{revision}/{f_path}',
1071 1073 controller='files', action='edit', revision='tip',
1072 1074 f_path='',
1073 1075 conditions={'function': check_repo, 'method': ['POST']},
1074 1076 requirements=URL_NAME_REQUIREMENTS)
1075 1077
1076 1078 rmap.connect('files_edit_home',
1077 1079 '/{repo_name}/edit/{revision}/{f_path}',
1078 1080 controller='files', action='edit_home', revision='tip',
1079 1081 f_path='', conditions={'function': check_repo},
1080 1082 requirements=URL_NAME_REQUIREMENTS)
1081 1083
1082 1084 rmap.connect('files_add',
1083 1085 '/{repo_name}/add/{revision}/{f_path}',
1084 1086 controller='files', action='add', revision='tip',
1085 1087 f_path='',
1086 1088 conditions={'function': check_repo, 'method': ['POST']},
1087 1089 requirements=URL_NAME_REQUIREMENTS)
1088 1090
1089 1091 rmap.connect('files_add_home',
1090 1092 '/{repo_name}/add/{revision}/{f_path}',
1091 1093 controller='files', action='add_home', revision='tip',
1092 1094 f_path='', conditions={'function': check_repo},
1093 1095 requirements=URL_NAME_REQUIREMENTS)
1094 1096
1095 1097 rmap.connect('files_delete',
1096 1098 '/{repo_name}/delete/{revision}/{f_path}',
1097 1099 controller='files', action='delete', revision='tip',
1098 1100 f_path='',
1099 1101 conditions={'function': check_repo, 'method': ['POST']},
1100 1102 requirements=URL_NAME_REQUIREMENTS)
1101 1103
1102 1104 rmap.connect('files_delete_home',
1103 1105 '/{repo_name}/delete/{revision}/{f_path}',
1104 1106 controller='files', action='delete_home', revision='tip',
1105 1107 f_path='', conditions={'function': check_repo},
1106 1108 requirements=URL_NAME_REQUIREMENTS)
1107 1109
1108 1110 rmap.connect('files_archive_home', '/{repo_name}/archive/{fname}',
1109 1111 controller='files', action='archivefile',
1110 1112 conditions={'function': check_repo},
1111 1113 requirements=URL_NAME_REQUIREMENTS, jsroute=True)
1112 1114
1113 1115 rmap.connect('files_nodelist_home',
1114 1116 '/{repo_name}/nodelist/{revision}/{f_path}',
1115 1117 controller='files', action='nodelist',
1116 1118 conditions={'function': check_repo},
1117 1119 requirements=URL_NAME_REQUIREMENTS, jsroute=True)
1118 1120
1119 1121 rmap.connect('files_nodetree_full',
1120 1122 '/{repo_name}/nodetree_full/{commit_id}/{f_path}',
1121 1123 controller='files', action='nodetree_full',
1122 1124 conditions={'function': check_repo},
1123 1125 requirements=URL_NAME_REQUIREMENTS, jsroute=True)
1124 1126
1125 1127 rmap.connect('repo_fork_create_home', '/{repo_name}/fork',
1126 1128 controller='forks', action='fork_create',
1127 1129 conditions={'function': check_repo, 'method': ['POST']},
1128 1130 requirements=URL_NAME_REQUIREMENTS)
1129 1131
1130 1132 rmap.connect('repo_fork_home', '/{repo_name}/fork',
1131 1133 controller='forks', action='fork',
1132 1134 conditions={'function': check_repo},
1133 1135 requirements=URL_NAME_REQUIREMENTS)
1134 1136
1135 1137 rmap.connect('repo_forks_home', '/{repo_name}/forks',
1136 1138 controller='forks', action='forks',
1137 1139 conditions={'function': check_repo},
1138 1140 requirements=URL_NAME_REQUIREMENTS)
1139 1141
1140 1142 rmap.connect('repo_followers_home', '/{repo_name}/followers',
1141 1143 controller='followers', action='followers',
1142 1144 conditions={'function': check_repo},
1143 1145 requirements=URL_NAME_REQUIREMENTS)
1144 1146
1145 1147 # must be here for proper group/repo catching pattern
1146 1148 _connect_with_slash(
1147 1149 rmap, 'repo_group_home', '/{group_name}',
1148 1150 controller='home', action='index_repo_group',
1149 1151 conditions={'function': check_group},
1150 1152 requirements=URL_NAME_REQUIREMENTS)
1151 1153
1152 1154 # catch all, at the end
1153 1155 _connect_with_slash(
1154 1156 rmap, 'summary_home', '/{repo_name}', jsroute=True,
1155 1157 controller='summary', action='index',
1156 1158 conditions={'function': check_repo},
1157 1159 requirements=URL_NAME_REQUIREMENTS)
1158 1160
1159 1161 return rmap
1160 1162
1161 1163
1162 1164 def _connect_with_slash(mapper, name, path, *args, **kwargs):
1163 1165 """
1164 1166 Connect a route with an optional trailing slash in `path`.
1165 1167 """
1166 1168 mapper.connect(name + '_slash', path + '/', *args, **kwargs)
1167 1169 mapper.connect(name, path, *args, **kwargs)
General Comments 0
You need to be logged in to leave comments. Login now