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