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