Show More
@@ -1,706 +1,708 b'' | |||||
1 | """ |
|
1 | """ | |
2 | Routes configuration |
|
2 | Routes configuration | |
3 |
|
3 | |||
4 | The more specific and detailed routes should be defined first so they |
|
4 | The more specific and detailed routes should be defined first so they | |
5 | may take precedent over the more generic routes. For more information |
|
5 | may take precedent over the more generic routes. For more information | |
6 | refer to the routes manual at http://routes.groovie.org/docs/ |
|
6 | refer to the routes manual at http://routes.groovie.org/docs/ | |
7 | """ |
|
7 | """ | |
8 | from __future__ import with_statement |
|
8 | from __future__ import with_statement | |
9 | from routes import Mapper |
|
9 | from routes import Mapper | |
10 |
|
10 | |||
11 | # prefix for non repository related links needs to be prefixed with `/` |
|
11 | # prefix for non repository related links needs to be prefixed with `/` | |
12 | ADMIN_PREFIX = '/_admin' |
|
12 | ADMIN_PREFIX = '/_admin' | |
13 |
|
13 | |||
14 |
|
14 | |||
15 | def make_map(config): |
|
15 | def make_map(config): | |
16 | """Create, configure and return the routes Mapper""" |
|
16 | """Create, configure and return the routes Mapper""" | |
17 | rmap = Mapper(directory=config['pylons.paths']['controllers'], |
|
17 | rmap = Mapper(directory=config['pylons.paths']['controllers'], | |
18 | always_scan=config['debug']) |
|
18 | always_scan=config['debug']) | |
19 | rmap.minimization = False |
|
19 | rmap.minimization = False | |
20 | rmap.explicit = False |
|
20 | rmap.explicit = False | |
21 |
|
21 | |||
22 | from rhodecode.lib.utils import is_valid_repo |
|
22 | from rhodecode.lib.utils import is_valid_repo | |
23 | from rhodecode.lib.utils import is_valid_repos_group |
|
23 | from rhodecode.lib.utils import is_valid_repos_group | |
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 |
|
28 | |||
29 | :param environ: |
|
29 | :param environ: | |
30 | :param match_dict: |
|
30 | :param match_dict: | |
31 | """ |
|
31 | """ | |
32 | from rhodecode.model.db import Repository |
|
32 | from rhodecode.model.db import Repository | |
33 | repo_name = match_dict.get('repo_name') |
|
33 | repo_name = match_dict.get('repo_name') | |
34 |
|
34 | |||
35 | if match_dict.get('f_path'): |
|
35 | if match_dict.get('f_path'): | |
36 | #fix for multiple initial slashes that causes errors |
|
36 | #fix for multiple initial slashes that causes errors | |
37 | match_dict['f_path'] = match_dict['f_path'].lstrip('/') |
|
37 | match_dict['f_path'] = match_dict['f_path'].lstrip('/') | |
38 |
|
38 | |||
39 | try: |
|
39 | try: | |
40 | by_id = repo_name.split('_') |
|
40 | by_id = repo_name.split('_') | |
41 | if len(by_id) == 2 and by_id[1].isdigit() and by_id[0] == '': |
|
41 | if len(by_id) == 2 and by_id[1].isdigit() and by_id[0] == '': | |
42 | repo_name = Repository.get(by_id[1]).repo_name |
|
42 | repo_name = Repository.get(by_id[1]).repo_name | |
43 | match_dict['repo_name'] = repo_name |
|
43 | match_dict['repo_name'] = repo_name | |
44 | except Exception: |
|
44 | except Exception: | |
45 | pass |
|
45 | pass | |
46 |
|
46 | |||
47 | return is_valid_repo(repo_name, config['base_path']) |
|
47 | return is_valid_repo(repo_name, config['base_path']) | |
48 |
|
48 | |||
49 | def check_group(environ, match_dict): |
|
49 | def check_group(environ, match_dict): | |
50 | """ |
|
50 | """ | |
51 | check for valid repository group for proper 404 handling |
|
51 | check for valid repository group for proper 404 handling | |
52 |
|
52 | |||
53 | :param environ: |
|
53 | :param environ: | |
54 | :param match_dict: |
|
54 | :param match_dict: | |
55 | """ |
|
55 | """ | |
56 | repos_group_name = match_dict.get('group_name') |
|
56 | repos_group_name = match_dict.get('group_name') | |
57 | return is_valid_repos_group(repos_group_name, config['base_path']) |
|
57 | return is_valid_repos_group(repos_group_name, config['base_path']) | |
58 |
|
58 | |||
59 | def check_group_skip_path(environ, match_dict): |
|
59 | def check_group_skip_path(environ, match_dict): | |
60 | """ |
|
60 | """ | |
61 | check for valid repository group for proper 404 handling, but skips |
|
61 | check for valid repository group for proper 404 handling, but skips | |
62 | verification of existing path |
|
62 | verification of existing path | |
63 |
|
63 | |||
64 | :param environ: |
|
64 | :param environ: | |
65 | :param match_dict: |
|
65 | :param match_dict: | |
66 | """ |
|
66 | """ | |
67 | repos_group_name = match_dict.get('group_name') |
|
67 | repos_group_name = match_dict.get('group_name') | |
68 | return is_valid_repos_group(repos_group_name, config['base_path'], |
|
68 | return is_valid_repos_group(repos_group_name, config['base_path'], | |
69 | skip_path_check=True) |
|
69 | skip_path_check=True) | |
70 |
|
70 | |||
71 | def check_user_group(environ, match_dict): |
|
71 | def check_user_group(environ, match_dict): | |
72 | """ |
|
72 | """ | |
73 | check for valid user group for proper 404 handling |
|
73 | check for valid user group for proper 404 handling | |
74 |
|
74 | |||
75 | :param environ: |
|
75 | :param environ: | |
76 | :param match_dict: |
|
76 | :param match_dict: | |
77 | """ |
|
77 | """ | |
78 | return True |
|
78 | return True | |
79 |
|
79 | |||
80 | def check_int(environ, match_dict): |
|
80 | def check_int(environ, match_dict): | |
81 | return match_dict.get('id').isdigit() |
|
81 | return match_dict.get('id').isdigit() | |
82 |
|
82 | |||
83 | # The ErrorController route (handles 404/500 error pages); it should |
|
83 | # The ErrorController route (handles 404/500 error pages); it should | |
84 | # likely stay at the top, ensuring it can always be resolved |
|
84 | # likely stay at the top, ensuring it can always be resolved | |
85 | rmap.connect('/error/{action}', controller='error') |
|
85 | rmap.connect('/error/{action}', controller='error') | |
86 | rmap.connect('/error/{action}/{id}', controller='error') |
|
86 | rmap.connect('/error/{action}/{id}', controller='error') | |
87 |
|
87 | |||
88 | #========================================================================== |
|
88 | #========================================================================== | |
89 | # CUSTOM ROUTES HERE |
|
89 | # CUSTOM ROUTES HERE | |
90 | #========================================================================== |
|
90 | #========================================================================== | |
91 |
|
91 | |||
92 | #MAIN PAGE |
|
92 | #MAIN PAGE | |
93 | rmap.connect('home', '/', controller='home', action='index') |
|
93 | rmap.connect('home', '/', controller='home', action='index') | |
94 | rmap.connect('repo_switcher', '/repos', controller='home', |
|
94 | rmap.connect('repo_switcher', '/repos', controller='home', | |
95 | action='repo_switcher') |
|
95 | action='repo_switcher') | |
96 | rmap.connect('branch_tag_switcher', '/branches-tags/{repo_name:.*?}', |
|
96 | rmap.connect('branch_tag_switcher', '/branches-tags/{repo_name:.*?}', | |
97 | controller='home', action='branch_tag_switcher') |
|
97 | controller='home', action='branch_tag_switcher') | |
98 | rmap.connect('bugtracker', |
|
98 | rmap.connect('bugtracker', | |
99 | "http://bitbucket.org/marcinkuzminski/rhodecode/issues", |
|
99 | "http://bitbucket.org/marcinkuzminski/rhodecode/issues", | |
100 | _static=True) |
|
100 | _static=True) | |
101 | rmap.connect('rst_help', |
|
101 | rmap.connect('rst_help', | |
102 | "http://docutils.sourceforge.net/docs/user/rst/quickref.html", |
|
102 | "http://docutils.sourceforge.net/docs/user/rst/quickref.html", | |
103 | _static=True) |
|
103 | _static=True) | |
104 | rmap.connect('rhodecode_official', "http://rhodecode.org", _static=True) |
|
104 | rmap.connect('rhodecode_official', "http://rhodecode.org", _static=True) | |
105 |
|
105 | |||
106 | #ADMIN REPOSITORY REST ROUTES |
|
106 | #ADMIN REPOSITORY REST ROUTES | |
107 | with rmap.submapper(path_prefix=ADMIN_PREFIX, |
|
107 | with rmap.submapper(path_prefix=ADMIN_PREFIX, | |
108 | controller='admin/repos') as m: |
|
108 | controller='admin/repos') as m: | |
109 | m.connect("repos", "/repos", |
|
109 | m.connect("repos", "/repos", | |
110 | action="create", conditions=dict(method=["POST"])) |
|
110 | action="create", conditions=dict(method=["POST"])) | |
111 | m.connect("repos", "/repos", |
|
111 | m.connect("repos", "/repos", | |
112 | action="index", conditions=dict(method=["GET"])) |
|
112 | action="index", conditions=dict(method=["GET"])) | |
113 | m.connect("formatted_repos", "/repos.{format}", |
|
113 | m.connect("formatted_repos", "/repos.{format}", | |
114 | action="index", |
|
114 | action="index", | |
115 | conditions=dict(method=["GET"])) |
|
115 | conditions=dict(method=["GET"])) | |
116 | m.connect("new_repo", "/create_repository", |
|
116 | m.connect("new_repo", "/create_repository", | |
117 | action="create_repository", conditions=dict(method=["GET"])) |
|
117 | action="create_repository", conditions=dict(method=["GET"])) | |
118 | m.connect("/repos/{repo_name:.*?}", |
|
118 | m.connect("/repos/{repo_name:.*?}", | |
119 | action="update", conditions=dict(method=["PUT"], |
|
119 | action="update", conditions=dict(method=["PUT"], | |
120 | function=check_repo)) |
|
120 | function=check_repo)) | |
121 | m.connect("/repos/{repo_name:.*?}", |
|
121 | m.connect("/repos/{repo_name:.*?}", | |
122 | action="delete", conditions=dict(method=["DELETE"], |
|
122 | action="delete", conditions=dict(method=["DELETE"], | |
123 | function=check_repo)) |
|
123 | function=check_repo)) | |
124 | m.connect("formatted_edit_repo", "/repos/{repo_name:.*?}.{format}/edit", |
|
124 | m.connect("formatted_edit_repo", "/repos/{repo_name:.*?}.{format}/edit", | |
125 | action="edit", conditions=dict(method=["GET"], |
|
125 | action="edit", conditions=dict(method=["GET"], | |
126 | function=check_repo)) |
|
126 | function=check_repo)) | |
127 | m.connect("repo", "/repos/{repo_name:.*?}", |
|
127 | m.connect("repo", "/repos/{repo_name:.*?}", | |
128 | action="show", conditions=dict(method=["GET"], |
|
128 | action="show", conditions=dict(method=["GET"], | |
129 | function=check_repo)) |
|
129 | function=check_repo)) | |
130 | m.connect("formatted_repo", "/repos/{repo_name:.*?}.{format}", |
|
130 | m.connect("formatted_repo", "/repos/{repo_name:.*?}.{format}", | |
131 | action="show", conditions=dict(method=["GET"], |
|
131 | action="show", conditions=dict(method=["GET"], | |
132 | function=check_repo)) |
|
132 | function=check_repo)) | |
133 | #add repo perm member |
|
133 | #add repo perm member | |
134 | m.connect('set_repo_perm_member', |
|
134 | m.connect('set_repo_perm_member', | |
135 | "/repos/{repo_name:.*?}/grant_perm", |
|
135 | "/repos/{repo_name:.*?}/grant_perm", | |
136 | action="set_repo_perm_member", |
|
136 | action="set_repo_perm_member", | |
137 | conditions=dict(method=["POST"], function=check_repo)) |
|
137 | conditions=dict(method=["POST"], function=check_repo)) | |
138 |
|
138 | |||
139 | #ajax delete repo perm user |
|
139 | #ajax delete repo perm user | |
140 | m.connect('delete_repo_perm_member', |
|
140 | m.connect('delete_repo_perm_member', | |
141 | "/repos/{repo_name:.*?}/revoke_perm", |
|
141 | "/repos/{repo_name:.*?}/revoke_perm", | |
142 | action="delete_repo_perm_member", |
|
142 | action="delete_repo_perm_member", | |
143 | conditions=dict(method=["DELETE"], function=check_repo)) |
|
143 | conditions=dict(method=["DELETE"], function=check_repo)) | |
144 |
|
144 | |||
145 | #settings actions |
|
145 | #settings actions | |
146 | m.connect('repo_stats', "/repos_stats/{repo_name:.*?}", |
|
146 | m.connect('repo_stats', "/repos_stats/{repo_name:.*?}", | |
147 | action="repo_stats", conditions=dict(method=["DELETE"], |
|
147 | action="repo_stats", conditions=dict(method=["DELETE"], | |
148 | function=check_repo)) |
|
148 | function=check_repo)) | |
149 | m.connect('repo_cache', "/repos_cache/{repo_name:.*?}", |
|
149 | m.connect('repo_cache', "/repos_cache/{repo_name:.*?}", | |
150 | action="repo_cache", conditions=dict(method=["DELETE"], |
|
150 | action="repo_cache", conditions=dict(method=["DELETE"], | |
151 | function=check_repo)) |
|
151 | function=check_repo)) | |
152 | m.connect('repo_public_journal', "/repos_public_journal/{repo_name:.*?}", |
|
152 | m.connect('repo_public_journal', "/repos_public_journal/{repo_name:.*?}", | |
153 | action="repo_public_journal", conditions=dict(method=["PUT"], |
|
153 | action="repo_public_journal", conditions=dict(method=["PUT"], | |
154 | function=check_repo)) |
|
154 | function=check_repo)) | |
155 | m.connect('repo_pull', "/repo_pull/{repo_name:.*?}", |
|
155 | m.connect('repo_pull', "/repo_pull/{repo_name:.*?}", | |
156 | action="repo_pull", conditions=dict(method=["PUT"], |
|
156 | action="repo_pull", conditions=dict(method=["PUT"], | |
157 | function=check_repo)) |
|
157 | function=check_repo)) | |
158 | m.connect('repo_as_fork', "/repo_as_fork/{repo_name:.*?}", |
|
158 | m.connect('repo_as_fork', "/repo_as_fork/{repo_name:.*?}", | |
159 | action="repo_as_fork", conditions=dict(method=["PUT"], |
|
159 | action="repo_as_fork", conditions=dict(method=["PUT"], | |
160 | function=check_repo)) |
|
160 | function=check_repo)) | |
161 | m.connect('repo_locking', "/repo_locking/{repo_name:.*?}", |
|
161 | m.connect('repo_locking', "/repo_locking/{repo_name:.*?}", | |
162 | action="repo_locking", conditions=dict(method=["PUT"], |
|
162 | action="repo_locking", conditions=dict(method=["PUT"], | |
163 | function=check_repo)) |
|
163 | function=check_repo)) | |
164 | m.connect('toggle_locking', "/locking_toggle/{repo_name:.*?}", |
|
164 | m.connect('toggle_locking', "/locking_toggle/{repo_name:.*?}", | |
165 | action="toggle_locking", conditions=dict(method=["GET"], |
|
165 | action="toggle_locking", conditions=dict(method=["GET"], | |
166 | function=check_repo)) |
|
166 | function=check_repo)) | |
167 |
|
167 | |||
168 | #repo fields |
|
168 | #repo fields | |
169 | m.connect('create_repo_fields', "/repo_fields/{repo_name:.*?}/new", |
|
169 | m.connect('create_repo_fields', "/repo_fields/{repo_name:.*?}/new", | |
170 | action="create_repo_field", conditions=dict(method=["PUT"], |
|
170 | action="create_repo_field", conditions=dict(method=["PUT"], | |
171 | function=check_repo)) |
|
171 | function=check_repo)) | |
172 |
|
172 | |||
173 | m.connect('delete_repo_fields', "/repo_fields/{repo_name:.*?}/{field_id}", |
|
173 | m.connect('delete_repo_fields', "/repo_fields/{repo_name:.*?}/{field_id}", | |
174 | action="delete_repo_field", conditions=dict(method=["DELETE"], |
|
174 | action="delete_repo_field", conditions=dict(method=["DELETE"], | |
175 | function=check_repo)) |
|
175 | function=check_repo)) | |
176 |
|
176 | |||
177 | with rmap.submapper(path_prefix=ADMIN_PREFIX, |
|
177 | with rmap.submapper(path_prefix=ADMIN_PREFIX, | |
178 | controller='admin/repos_groups') as m: |
|
178 | controller='admin/repos_groups') as m: | |
179 | m.connect("repos_groups", "/repos_groups", |
|
179 | m.connect("repos_groups", "/repos_groups", | |
180 | action="create", conditions=dict(method=["POST"])) |
|
180 | action="create", conditions=dict(method=["POST"])) | |
181 | m.connect("repos_groups", "/repos_groups", |
|
181 | m.connect("repos_groups", "/repos_groups", | |
182 | action="index", conditions=dict(method=["GET"])) |
|
182 | action="index", conditions=dict(method=["GET"])) | |
183 | m.connect("formatted_repos_groups", "/repos_groups.{format}", |
|
183 | m.connect("formatted_repos_groups", "/repos_groups.{format}", | |
184 | action="index", conditions=dict(method=["GET"])) |
|
184 | action="index", conditions=dict(method=["GET"])) | |
185 | m.connect("new_repos_group", "/repos_groups/new", |
|
185 | m.connect("new_repos_group", "/repos_groups/new", | |
186 | action="new", conditions=dict(method=["GET"])) |
|
186 | action="new", conditions=dict(method=["GET"])) | |
187 | m.connect("formatted_new_repos_group", "/repos_groups/new.{format}", |
|
187 | m.connect("formatted_new_repos_group", "/repos_groups/new.{format}", | |
188 | action="new", conditions=dict(method=["GET"])) |
|
188 | action="new", conditions=dict(method=["GET"])) | |
189 | m.connect("update_repos_group", "/repos_groups/{group_name:.*?}", |
|
189 | m.connect("update_repos_group", "/repos_groups/{group_name:.*?}", | |
190 | action="update", conditions=dict(method=["PUT"], |
|
190 | action="update", conditions=dict(method=["PUT"], | |
191 | function=check_group)) |
|
191 | function=check_group)) | |
192 | #add repo group perm member |
|
192 | #add repo group perm member | |
193 | m.connect('set_repo_group_perm_member', |
|
193 | m.connect('set_repo_group_perm_member', | |
194 | "/repos_groups/{group_name:.*?}/grant_perm", |
|
194 | "/repos_groups/{group_name:.*?}/grant_perm", | |
195 | action="set_repo_group_perm_member", |
|
195 | action="set_repo_group_perm_member", | |
196 | conditions=dict(method=["POST"], function=check_group)) |
|
196 | conditions=dict(method=["POST"], function=check_group)) | |
197 |
|
197 | |||
198 | #ajax delete repo group perm |
|
198 | #ajax delete repo group perm | |
199 | m.connect('delete_repo_group_perm_member', |
|
199 | m.connect('delete_repo_group_perm_member', | |
200 | "/repos_groups/{group_name:.*?}/revoke_perm", |
|
200 | "/repos_groups/{group_name:.*?}/revoke_perm", | |
201 | action="delete_repo_group_perm_member", |
|
201 | action="delete_repo_group_perm_member", | |
202 | conditions=dict(method=["DELETE"], function=check_group)) |
|
202 | conditions=dict(method=["DELETE"], function=check_group)) | |
203 |
|
203 | |||
204 | m.connect("delete_repos_group", "/repos_groups/{group_name:.*?}", |
|
204 | m.connect("delete_repos_group", "/repos_groups/{group_name:.*?}", | |
205 | action="delete", conditions=dict(method=["DELETE"], |
|
205 | action="delete", conditions=dict(method=["DELETE"], | |
206 | function=check_group_skip_path)) |
|
206 | function=check_group_skip_path)) | |
207 | m.connect("edit_repos_group", "/repos_groups/{group_name:.*?}/edit", |
|
207 | m.connect("edit_repos_group", "/repos_groups/{group_name:.*?}/edit", | |
208 | action="edit", conditions=dict(method=["GET"], |
|
208 | action="edit", conditions=dict(method=["GET"], | |
209 | function=check_group)) |
|
209 | function=check_group)) | |
210 | m.connect("formatted_edit_repos_group", |
|
210 | m.connect("formatted_edit_repos_group", | |
211 | "/repos_groups/{group_name:.*?}.{format}/edit", |
|
211 | "/repos_groups/{group_name:.*?}.{format}/edit", | |
212 | action="edit", conditions=dict(method=["GET"], |
|
212 | action="edit", conditions=dict(method=["GET"], | |
213 | function=check_group)) |
|
213 | function=check_group)) | |
214 | m.connect("repos_group", "/repos_groups/{group_name:.*?}", |
|
214 | m.connect("repos_group", "/repos_groups/{group_name:.*?}", | |
215 | action="show", conditions=dict(method=["GET"], |
|
215 | action="show", conditions=dict(method=["GET"], | |
216 | function=check_group)) |
|
216 | function=check_group)) | |
217 | m.connect("formatted_repos_group", "/repos_groups/{group_name:.*?}.{format}", |
|
217 | m.connect("formatted_repos_group", "/repos_groups/{group_name:.*?}.{format}", | |
218 | action="show", conditions=dict(method=["GET"], |
|
218 | action="show", conditions=dict(method=["GET"], | |
219 | function=check_group)) |
|
219 | function=check_group)) | |
220 |
|
220 | |||
221 | #ADMIN USER REST ROUTES |
|
221 | #ADMIN USER REST ROUTES | |
222 | with rmap.submapper(path_prefix=ADMIN_PREFIX, |
|
222 | with rmap.submapper(path_prefix=ADMIN_PREFIX, | |
223 | controller='admin/users') as m: |
|
223 | controller='admin/users') as m: | |
224 | m.connect("users", "/users", |
|
224 | m.connect("users", "/users", | |
225 | action="create", conditions=dict(method=["POST"])) |
|
225 | action="create", conditions=dict(method=["POST"])) | |
226 | m.connect("users", "/users", |
|
226 | m.connect("users", "/users", | |
227 | action="index", conditions=dict(method=["GET"])) |
|
227 | action="index", conditions=dict(method=["GET"])) | |
228 | m.connect("formatted_users", "/users.{format}", |
|
228 | m.connect("formatted_users", "/users.{format}", | |
229 | action="index", conditions=dict(method=["GET"])) |
|
229 | action="index", conditions=dict(method=["GET"])) | |
230 | m.connect("new_user", "/users/new", |
|
230 | m.connect("new_user", "/users/new", | |
231 | action="new", conditions=dict(method=["GET"])) |
|
231 | action="new", conditions=dict(method=["GET"])) | |
232 | m.connect("formatted_new_user", "/users/new.{format}", |
|
232 | m.connect("formatted_new_user", "/users/new.{format}", | |
233 | action="new", conditions=dict(method=["GET"])) |
|
233 | action="new", conditions=dict(method=["GET"])) | |
234 | m.connect("update_user", "/users/{id}", |
|
234 | m.connect("update_user", "/users/{id}", | |
235 | action="update", conditions=dict(method=["PUT"])) |
|
235 | action="update", conditions=dict(method=["PUT"])) | |
236 | m.connect("delete_user", "/users/{id}", |
|
236 | m.connect("delete_user", "/users/{id}", | |
237 | action="delete", conditions=dict(method=["DELETE"])) |
|
237 | action="delete", conditions=dict(method=["DELETE"])) | |
238 | m.connect("edit_user", "/users/{id}/edit", |
|
238 | m.connect("edit_user", "/users/{id}/edit", | |
239 | action="edit", conditions=dict(method=["GET"])) |
|
239 | action="edit", conditions=dict(method=["GET"])) | |
240 | m.connect("formatted_edit_user", |
|
240 | m.connect("formatted_edit_user", | |
241 | "/users/{id}.{format}/edit", |
|
241 | "/users/{id}.{format}/edit", | |
242 | action="edit", conditions=dict(method=["GET"])) |
|
242 | action="edit", conditions=dict(method=["GET"])) | |
243 | m.connect("user", "/users/{id}", |
|
243 | m.connect("user", "/users/{id}", | |
244 | action="show", conditions=dict(method=["GET"])) |
|
244 | action="show", conditions=dict(method=["GET"])) | |
245 | m.connect("formatted_user", "/users/{id}.{format}", |
|
245 | m.connect("formatted_user", "/users/{id}.{format}", | |
246 | action="show", conditions=dict(method=["GET"])) |
|
246 | action="show", conditions=dict(method=["GET"])) | |
247 |
|
247 | |||
248 | #EXTRAS USER ROUTES |
|
248 | #EXTRAS USER ROUTES | |
249 | m.connect("user_perm", "/users_perm/{id}", |
|
249 | m.connect("user_perm", "/users_perm/{id}", | |
250 | action="update_perm", conditions=dict(method=["PUT"])) |
|
250 | action="update_perm", conditions=dict(method=["PUT"])) | |
251 | m.connect("user_emails", "/users_emails/{id}", |
|
251 | m.connect("user_emails", "/users_emails/{id}", | |
252 | action="add_email", conditions=dict(method=["PUT"])) |
|
252 | action="add_email", conditions=dict(method=["PUT"])) | |
253 | m.connect("user_emails_delete", "/users_emails/{id}", |
|
253 | m.connect("user_emails_delete", "/users_emails/{id}", | |
254 | action="delete_email", conditions=dict(method=["DELETE"])) |
|
254 | action="delete_email", conditions=dict(method=["DELETE"])) | |
255 | m.connect("user_ips", "/users_ips/{id}", |
|
255 | m.connect("user_ips", "/users_ips/{id}", | |
256 | action="add_ip", conditions=dict(method=["PUT"])) |
|
256 | action="add_ip", conditions=dict(method=["PUT"])) | |
257 | m.connect("user_ips_delete", "/users_ips/{id}", |
|
257 | m.connect("user_ips_delete", "/users_ips/{id}", | |
258 | action="delete_ip", conditions=dict(method=["DELETE"])) |
|
258 | action="delete_ip", conditions=dict(method=["DELETE"])) | |
259 |
|
259 | |||
260 | #ADMIN USER GROUPS REST ROUTES |
|
260 | #ADMIN USER GROUPS REST ROUTES | |
261 | with rmap.submapper(path_prefix=ADMIN_PREFIX, |
|
261 | with rmap.submapper(path_prefix=ADMIN_PREFIX, | |
262 | controller='admin/users_groups') as m: |
|
262 | controller='admin/users_groups') as m: | |
263 | m.connect("users_groups", "/users_groups", |
|
263 | m.connect("users_groups", "/users_groups", | |
264 | action="create", conditions=dict(method=["POST"])) |
|
264 | action="create", conditions=dict(method=["POST"])) | |
265 | m.connect("users_groups", "/users_groups", |
|
265 | m.connect("users_groups", "/users_groups", | |
266 | action="index", conditions=dict(method=["GET"])) |
|
266 | action="index", conditions=dict(method=["GET"])) | |
267 | m.connect("formatted_users_groups", "/users_groups.{format}", |
|
267 | m.connect("formatted_users_groups", "/users_groups.{format}", | |
268 | action="index", conditions=dict(method=["GET"])) |
|
268 | action="index", conditions=dict(method=["GET"])) | |
269 | m.connect("new_users_group", "/users_groups/new", |
|
269 | m.connect("new_users_group", "/users_groups/new", | |
270 | action="new", conditions=dict(method=["GET"])) |
|
270 | action="new", conditions=dict(method=["GET"])) | |
271 | m.connect("formatted_new_users_group", "/users_groups/new.{format}", |
|
271 | m.connect("formatted_new_users_group", "/users_groups/new.{format}", | |
272 | action="new", conditions=dict(method=["GET"])) |
|
272 | action="new", conditions=dict(method=["GET"])) | |
273 | m.connect("update_users_group", "/users_groups/{id}", |
|
273 | m.connect("update_users_group", "/users_groups/{id}", | |
274 | action="update", conditions=dict(method=["PUT"])) |
|
274 | action="update", conditions=dict(method=["PUT"])) | |
275 | m.connect("delete_users_group", "/users_groups/{id}", |
|
275 | m.connect("delete_users_group", "/users_groups/{id}", | |
276 | action="delete", conditions=dict(method=["DELETE"])) |
|
276 | action="delete", conditions=dict(method=["DELETE"])) | |
277 | m.connect("edit_users_group", "/users_groups/{id}/edit", |
|
277 | m.connect("edit_users_group", "/users_groups/{id}/edit", | |
278 | action="edit", conditions=dict(method=["GET"]), |
|
278 | action="edit", conditions=dict(method=["GET"]), | |
279 | function=check_user_group) |
|
279 | function=check_user_group) | |
280 | m.connect("formatted_edit_users_group", |
|
280 | m.connect("formatted_edit_users_group", | |
281 | "/users_groups/{id}.{format}/edit", |
|
281 | "/users_groups/{id}.{format}/edit", | |
282 | action="edit", conditions=dict(method=["GET"])) |
|
282 | action="edit", conditions=dict(method=["GET"])) | |
283 | m.connect("users_group", "/users_groups/{id}", |
|
283 | m.connect("users_group", "/users_groups/{id}", | |
284 | action="show", conditions=dict(method=["GET"])) |
|
284 | action="show", conditions=dict(method=["GET"])) | |
285 | m.connect("formatted_users_group", "/users_groups/{id}.{format}", |
|
285 | m.connect("formatted_users_group", "/users_groups/{id}.{format}", | |
286 | action="show", conditions=dict(method=["GET"])) |
|
286 | action="show", conditions=dict(method=["GET"])) | |
287 |
|
287 | |||
288 | #EXTRAS USER ROUTES |
|
288 | #EXTRAS USER ROUTES | |
289 | # update |
|
289 | # update | |
290 | m.connect("users_group_perm", "/users_groups/{id}/update_global_perm", |
|
290 | m.connect("users_group_perm", "/users_groups/{id}/update_global_perm", | |
291 | action="update_perm", conditions=dict(method=["PUT"])) |
|
291 | action="update_perm", conditions=dict(method=["PUT"])) | |
292 |
|
292 | |||
293 | #add user group perm member |
|
293 | #add user group perm member | |
294 | m.connect('set_user_group_perm_member', "/users_groups/{id}/grant_perm", |
|
294 | m.connect('set_user_group_perm_member', "/users_groups/{id}/grant_perm", | |
295 | action="set_user_group_perm_member", |
|
295 | action="set_user_group_perm_member", | |
296 | conditions=dict(method=["POST"])) |
|
296 | conditions=dict(method=["POST"])) | |
297 |
|
297 | |||
298 | #ajax delete user group perm |
|
298 | #ajax delete user group perm | |
299 | m.connect('delete_user_group_perm_member', "/users_groups/{id}/revoke_perm", |
|
299 | m.connect('delete_user_group_perm_member', "/users_groups/{id}/revoke_perm", | |
300 | action="delete_user_group_perm_member", |
|
300 | action="delete_user_group_perm_member", | |
301 | conditions=dict(method=["DELETE"])) |
|
301 | conditions=dict(method=["DELETE"])) | |
302 |
|
302 | |||
303 | #ADMIN GROUP REST ROUTES |
|
303 | #ADMIN GROUP REST ROUTES | |
304 | rmap.resource('group', 'groups', |
|
304 | rmap.resource('group', 'groups', | |
305 | controller='admin/groups', path_prefix=ADMIN_PREFIX) |
|
305 | controller='admin/groups', path_prefix=ADMIN_PREFIX) | |
306 |
|
306 | |||
307 | #ADMIN PERMISSIONS REST ROUTES |
|
307 | #ADMIN PERMISSIONS REST ROUTES | |
308 | rmap.resource('permission', 'permissions', |
|
308 | rmap.resource('permission', 'permissions', | |
309 | controller='admin/permissions', path_prefix=ADMIN_PREFIX) |
|
309 | controller='admin/permissions', path_prefix=ADMIN_PREFIX) | |
310 |
|
310 | |||
311 | #ADMIN DEFAULTS REST ROUTES |
|
311 | #ADMIN DEFAULTS REST ROUTES | |
312 | rmap.resource('default', 'defaults', |
|
312 | rmap.resource('default', 'defaults', | |
313 | controller='admin/defaults', path_prefix=ADMIN_PREFIX) |
|
313 | controller='admin/defaults', path_prefix=ADMIN_PREFIX) | |
314 |
|
314 | |||
315 | ##ADMIN LDAP SETTINGS |
|
315 | ##ADMIN LDAP SETTINGS | |
316 | rmap.connect('ldap_settings', '%s/ldap' % ADMIN_PREFIX, |
|
316 | rmap.connect('ldap_settings', '%s/ldap' % ADMIN_PREFIX, | |
317 | controller='admin/ldap_settings', action='ldap_settings', |
|
317 | controller='admin/ldap_settings', action='ldap_settings', | |
318 | conditions=dict(method=["POST"])) |
|
318 | conditions=dict(method=["POST"])) | |
319 |
|
319 | |||
320 | rmap.connect('ldap_home', '%s/ldap' % ADMIN_PREFIX, |
|
320 | rmap.connect('ldap_home', '%s/ldap' % ADMIN_PREFIX, | |
321 | controller='admin/ldap_settings') |
|
321 | controller='admin/ldap_settings') | |
322 |
|
322 | |||
323 | #ADMIN SETTINGS REST ROUTES |
|
323 | #ADMIN SETTINGS REST ROUTES | |
324 | with rmap.submapper(path_prefix=ADMIN_PREFIX, |
|
324 | with rmap.submapper(path_prefix=ADMIN_PREFIX, | |
325 | controller='admin/settings') as m: |
|
325 | controller='admin/settings') as m: | |
326 | m.connect("admin_settings", "/settings", |
|
326 | m.connect("admin_settings", "/settings", | |
327 | action="create", conditions=dict(method=["POST"])) |
|
327 | action="create", conditions=dict(method=["POST"])) | |
328 | m.connect("admin_settings", "/settings", |
|
328 | m.connect("admin_settings", "/settings", | |
329 | action="index", conditions=dict(method=["GET"])) |
|
329 | action="index", conditions=dict(method=["GET"])) | |
330 | m.connect("formatted_admin_settings", "/settings.{format}", |
|
330 | m.connect("formatted_admin_settings", "/settings.{format}", | |
331 | action="index", conditions=dict(method=["GET"])) |
|
331 | action="index", conditions=dict(method=["GET"])) | |
332 | m.connect("admin_new_setting", "/settings/new", |
|
332 | m.connect("admin_new_setting", "/settings/new", | |
333 | action="new", conditions=dict(method=["GET"])) |
|
333 | action="new", conditions=dict(method=["GET"])) | |
334 | m.connect("formatted_admin_new_setting", "/settings/new.{format}", |
|
334 | m.connect("formatted_admin_new_setting", "/settings/new.{format}", | |
335 | action="new", conditions=dict(method=["GET"])) |
|
335 | action="new", conditions=dict(method=["GET"])) | |
336 | m.connect("/settings/{setting_id}", |
|
336 | m.connect("/settings/{setting_id}", | |
337 | action="update", conditions=dict(method=["PUT"])) |
|
337 | action="update", conditions=dict(method=["PUT"])) | |
338 | m.connect("/settings/{setting_id}", |
|
338 | m.connect("/settings/{setting_id}", | |
339 | action="delete", conditions=dict(method=["DELETE"])) |
|
339 | action="delete", conditions=dict(method=["DELETE"])) | |
340 | m.connect("admin_edit_setting", "/settings/{setting_id}/edit", |
|
340 | m.connect("admin_edit_setting", "/settings/{setting_id}/edit", | |
341 | action="edit", conditions=dict(method=["GET"])) |
|
341 | action="edit", conditions=dict(method=["GET"])) | |
342 | m.connect("formatted_admin_edit_setting", |
|
342 | m.connect("formatted_admin_edit_setting", | |
343 | "/settings/{setting_id}.{format}/edit", |
|
343 | "/settings/{setting_id}.{format}/edit", | |
344 | action="edit", conditions=dict(method=["GET"])) |
|
344 | action="edit", conditions=dict(method=["GET"])) | |
345 | m.connect("admin_setting", "/settings/{setting_id}", |
|
345 | m.connect("admin_setting", "/settings/{setting_id}", | |
346 | action="show", conditions=dict(method=["GET"])) |
|
346 | action="show", conditions=dict(method=["GET"])) | |
347 | m.connect("formatted_admin_setting", "/settings/{setting_id}.{format}", |
|
347 | m.connect("formatted_admin_setting", "/settings/{setting_id}.{format}", | |
348 | action="show", conditions=dict(method=["GET"])) |
|
348 | action="show", conditions=dict(method=["GET"])) | |
349 | m.connect("admin_settings_my_account", "/my_account", |
|
349 | m.connect("admin_settings_my_account", "/my_account", | |
350 | action="my_account", conditions=dict(method=["GET"])) |
|
350 | action="my_account", conditions=dict(method=["GET"])) | |
351 | m.connect("admin_settings_my_account_update", "/my_account_update", |
|
351 | m.connect("admin_settings_my_account_update", "/my_account_update", | |
352 | action="my_account_update", conditions=dict(method=["PUT"])) |
|
352 | action="my_account_update", conditions=dict(method=["PUT"])) | |
353 | m.connect("admin_settings_my_repos", "/my_account/repos", |
|
353 | m.connect("admin_settings_my_repos", "/my_account/repos", | |
354 | action="my_account_my_repos", conditions=dict(method=["GET"])) |
|
354 | action="my_account_my_repos", conditions=dict(method=["GET"])) | |
355 | m.connect("admin_settings_my_pullrequests", "/my_account/pull_requests", |
|
355 | m.connect("admin_settings_my_pullrequests", "/my_account/pull_requests", | |
356 | action="my_account_my_pullrequests", conditions=dict(method=["GET"])) |
|
356 | action="my_account_my_pullrequests", conditions=dict(method=["GET"])) | |
357 |
|
357 | |||
358 | #NOTIFICATION REST ROUTES |
|
358 | #NOTIFICATION REST ROUTES | |
359 | with rmap.submapper(path_prefix=ADMIN_PREFIX, |
|
359 | with rmap.submapper(path_prefix=ADMIN_PREFIX, | |
360 | controller='admin/notifications') as m: |
|
360 | controller='admin/notifications') as m: | |
361 | m.connect("notifications", "/notifications", |
|
361 | m.connect("notifications", "/notifications", | |
362 | action="create", conditions=dict(method=["POST"])) |
|
362 | action="create", conditions=dict(method=["POST"])) | |
363 | m.connect("notifications", "/notifications", |
|
363 | m.connect("notifications", "/notifications", | |
364 | action="index", conditions=dict(method=["GET"])) |
|
364 | action="index", conditions=dict(method=["GET"])) | |
365 | m.connect("notifications_mark_all_read", "/notifications/mark_all_read", |
|
365 | m.connect("notifications_mark_all_read", "/notifications/mark_all_read", | |
366 | action="mark_all_read", conditions=dict(method=["GET"])) |
|
366 | action="mark_all_read", conditions=dict(method=["GET"])) | |
367 | m.connect("formatted_notifications", "/notifications.{format}", |
|
367 | m.connect("formatted_notifications", "/notifications.{format}", | |
368 | action="index", conditions=dict(method=["GET"])) |
|
368 | action="index", conditions=dict(method=["GET"])) | |
369 | m.connect("new_notification", "/notifications/new", |
|
369 | m.connect("new_notification", "/notifications/new", | |
370 | action="new", conditions=dict(method=["GET"])) |
|
370 | action="new", conditions=dict(method=["GET"])) | |
371 | m.connect("formatted_new_notification", "/notifications/new.{format}", |
|
371 | m.connect("formatted_new_notification", "/notifications/new.{format}", | |
372 | action="new", conditions=dict(method=["GET"])) |
|
372 | action="new", conditions=dict(method=["GET"])) | |
373 | m.connect("/notification/{notification_id}", |
|
373 | m.connect("/notification/{notification_id}", | |
374 | action="update", conditions=dict(method=["PUT"])) |
|
374 | action="update", conditions=dict(method=["PUT"])) | |
375 | m.connect("/notification/{notification_id}", |
|
375 | m.connect("/notification/{notification_id}", | |
376 | action="delete", conditions=dict(method=["DELETE"])) |
|
376 | action="delete", conditions=dict(method=["DELETE"])) | |
377 | m.connect("edit_notification", "/notification/{notification_id}/edit", |
|
377 | m.connect("edit_notification", "/notification/{notification_id}/edit", | |
378 | action="edit", conditions=dict(method=["GET"])) |
|
378 | action="edit", conditions=dict(method=["GET"])) | |
379 | m.connect("formatted_edit_notification", |
|
379 | m.connect("formatted_edit_notification", | |
380 | "/notification/{notification_id}.{format}/edit", |
|
380 | "/notification/{notification_id}.{format}/edit", | |
381 | action="edit", conditions=dict(method=["GET"])) |
|
381 | action="edit", conditions=dict(method=["GET"])) | |
382 | m.connect("notification", "/notification/{notification_id}", |
|
382 | m.connect("notification", "/notification/{notification_id}", | |
383 | action="show", conditions=dict(method=["GET"])) |
|
383 | action="show", conditions=dict(method=["GET"])) | |
384 |
m.connect("formatted_notification", "/notification |
|
384 | m.connect("formatted_notification", "/notification/{notification_id}.{format}", | |
385 | action="show", conditions=dict(method=["GET"])) |
|
385 | action="show", conditions=dict(method=["GET"])) | |
386 |
|
386 | |||
387 | #ADMIN GIST |
|
387 | #ADMIN GIST | |
388 | with rmap.submapper(path_prefix=ADMIN_PREFIX, |
|
388 | with rmap.submapper(path_prefix=ADMIN_PREFIX, | |
389 | controller='admin/gists') as m: |
|
389 | controller='admin/gists') as m: | |
390 | m.connect("gists", "/gists", |
|
390 | m.connect("gists", "/gists", | |
391 | action="create", conditions=dict(method=["POST"])) |
|
391 | action="create", conditions=dict(method=["POST"])) | |
392 | m.connect("gists", "/gists", |
|
392 | m.connect("gists", "/gists", | |
393 | action="index", conditions=dict(method=["GET"])) |
|
393 | action="index", conditions=dict(method=["GET"])) | |
394 |
m.connect("formatted_gists", "/gists |
|
394 | m.connect("formatted_gists", "/gists/{format}", | |
395 | action="index", conditions=dict(method=["GET"])) |
|
395 | action="index", conditions=dict(method=["GET"])) | |
396 | m.connect("new_gist", "/gists/new", |
|
396 | m.connect("new_gist", "/gists/new", | |
397 | action="new", conditions=dict(method=["GET"])) |
|
397 | action="new", conditions=dict(method=["GET"])) | |
398 |
m.connect("formatted_new_gist", "/gists/new |
|
398 | m.connect("formatted_new_gist", "/gists/new/{format}", | |
399 | action="new", conditions=dict(method=["GET"])) |
|
399 | action="new", conditions=dict(method=["GET"])) | |
400 | m.connect("/gist/{gist_id}", |
|
400 | m.connect("/gist/{gist_id}", | |
401 | action="update", conditions=dict(method=["PUT"])) |
|
401 | action="update", conditions=dict(method=["PUT"])) | |
402 | m.connect("/gist/{gist_id}", |
|
402 | m.connect("/gist/{gist_id}", | |
403 | action="delete", conditions=dict(method=["DELETE"])) |
|
403 | action="delete", conditions=dict(method=["DELETE"])) | |
404 | m.connect("edit_gist", "/gist/{gist_id}/edit", |
|
404 | m.connect("edit_gist", "/gist/{gist_id}/edit", | |
405 | action="edit", conditions=dict(method=["GET"])) |
|
405 | action="edit", conditions=dict(method=["GET"])) | |
406 | m.connect("formatted_edit_gist", |
|
406 | m.connect("formatted_edit_gist", | |
407 |
"/gist/{gist_id} |
|
407 | "/gist/{gist_id}/{format}/edit", | |
408 | action="edit", conditions=dict(method=["GET"])) |
|
408 | action="edit", conditions=dict(method=["GET"])) | |
409 | m.connect("gist", "/gist/{gist_id}", |
|
409 | m.connect("gist", "/gist/{gist_id}", | |
410 | action="show", conditions=dict(method=["GET"])) |
|
410 | action="show", conditions=dict(method=["GET"])) | |
411 |
m.connect("formatted_gist", "/gist |
|
411 | m.connect("formatted_gist", "/gist/{gist_id}/{format}", | |
|
412 | action="show", conditions=dict(method=["GET"])) | |||
|
413 | m.connect("formatted_gist_file", "/gist/{gist_id}/{format}/{revision}/{f_path:.*}", | |||
412 | action="show", conditions=dict(method=["GET"])) |
|
414 | action="show", conditions=dict(method=["GET"])) | |
413 |
|
415 | |||
414 | #ADMIN MAIN PAGES |
|
416 | #ADMIN MAIN PAGES | |
415 | with rmap.submapper(path_prefix=ADMIN_PREFIX, |
|
417 | with rmap.submapper(path_prefix=ADMIN_PREFIX, | |
416 | controller='admin/admin') as m: |
|
418 | controller='admin/admin') as m: | |
417 | m.connect('admin_home', '', action='index') |
|
419 | m.connect('admin_home', '', action='index') | |
418 | m.connect('admin_add_repo', '/add_repo/{new_repo:[a-z0-9\. _-]*}', |
|
420 | m.connect('admin_add_repo', '/add_repo/{new_repo:[a-z0-9\. _-]*}', | |
419 | action='add_repo') |
|
421 | action='add_repo') | |
420 | #========================================================================== |
|
422 | #========================================================================== | |
421 | # API V2 |
|
423 | # API V2 | |
422 | #========================================================================== |
|
424 | #========================================================================== | |
423 | with rmap.submapper(path_prefix=ADMIN_PREFIX, |
|
425 | with rmap.submapper(path_prefix=ADMIN_PREFIX, | |
424 | controller='api/api') as m: |
|
426 | controller='api/api') as m: | |
425 | m.connect('api', '/api') |
|
427 | m.connect('api', '/api') | |
426 |
|
428 | |||
427 | #USER JOURNAL |
|
429 | #USER JOURNAL | |
428 | rmap.connect('journal', '%s/journal' % ADMIN_PREFIX, |
|
430 | rmap.connect('journal', '%s/journal' % ADMIN_PREFIX, | |
429 | controller='journal', action='index') |
|
431 | controller='journal', action='index') | |
430 | rmap.connect('journal_rss', '%s/journal/rss' % ADMIN_PREFIX, |
|
432 | rmap.connect('journal_rss', '%s/journal/rss' % ADMIN_PREFIX, | |
431 | controller='journal', action='journal_rss') |
|
433 | controller='journal', action='journal_rss') | |
432 | rmap.connect('journal_atom', '%s/journal/atom' % ADMIN_PREFIX, |
|
434 | rmap.connect('journal_atom', '%s/journal/atom' % ADMIN_PREFIX, | |
433 | controller='journal', action='journal_atom') |
|
435 | controller='journal', action='journal_atom') | |
434 |
|
436 | |||
435 | rmap.connect('public_journal', '%s/public_journal' % ADMIN_PREFIX, |
|
437 | rmap.connect('public_journal', '%s/public_journal' % ADMIN_PREFIX, | |
436 | controller='journal', action="public_journal") |
|
438 | controller='journal', action="public_journal") | |
437 |
|
439 | |||
438 | rmap.connect('public_journal_rss', '%s/public_journal/rss' % ADMIN_PREFIX, |
|
440 | rmap.connect('public_journal_rss', '%s/public_journal/rss' % ADMIN_PREFIX, | |
439 | controller='journal', action="public_journal_rss") |
|
441 | controller='journal', action="public_journal_rss") | |
440 |
|
442 | |||
441 | rmap.connect('public_journal_rss_old', '%s/public_journal_rss' % ADMIN_PREFIX, |
|
443 | rmap.connect('public_journal_rss_old', '%s/public_journal_rss' % ADMIN_PREFIX, | |
442 | controller='journal', action="public_journal_rss") |
|
444 | controller='journal', action="public_journal_rss") | |
443 |
|
445 | |||
444 | rmap.connect('public_journal_atom', |
|
446 | rmap.connect('public_journal_atom', | |
445 | '%s/public_journal/atom' % ADMIN_PREFIX, controller='journal', |
|
447 | '%s/public_journal/atom' % ADMIN_PREFIX, controller='journal', | |
446 | action="public_journal_atom") |
|
448 | action="public_journal_atom") | |
447 |
|
449 | |||
448 | rmap.connect('public_journal_atom_old', |
|
450 | rmap.connect('public_journal_atom_old', | |
449 | '%s/public_journal_atom' % ADMIN_PREFIX, controller='journal', |
|
451 | '%s/public_journal_atom' % ADMIN_PREFIX, controller='journal', | |
450 | action="public_journal_atom") |
|
452 | action="public_journal_atom") | |
451 |
|
453 | |||
452 | rmap.connect('toggle_following', '%s/toggle_following' % ADMIN_PREFIX, |
|
454 | rmap.connect('toggle_following', '%s/toggle_following' % ADMIN_PREFIX, | |
453 | controller='journal', action='toggle_following', |
|
455 | controller='journal', action='toggle_following', | |
454 | conditions=dict(method=["POST"])) |
|
456 | conditions=dict(method=["POST"])) | |
455 |
|
457 | |||
456 | #SEARCH |
|
458 | #SEARCH | |
457 | rmap.connect('search', '%s/search' % ADMIN_PREFIX, controller='search',) |
|
459 | rmap.connect('search', '%s/search' % ADMIN_PREFIX, controller='search',) | |
458 | rmap.connect('search_repo_admin', '%s/search/{repo_name:.*}' % ADMIN_PREFIX, |
|
460 | rmap.connect('search_repo_admin', '%s/search/{repo_name:.*}' % ADMIN_PREFIX, | |
459 | controller='search', |
|
461 | controller='search', | |
460 | conditions=dict(function=check_repo)) |
|
462 | conditions=dict(function=check_repo)) | |
461 | rmap.connect('search_repo', '/{repo_name:.*?}/search', |
|
463 | rmap.connect('search_repo', '/{repo_name:.*?}/search', | |
462 | controller='search', |
|
464 | controller='search', | |
463 | conditions=dict(function=check_repo), |
|
465 | conditions=dict(function=check_repo), | |
464 | ) |
|
466 | ) | |
465 |
|
467 | |||
466 | #LOGIN/LOGOUT/REGISTER/SIGN IN |
|
468 | #LOGIN/LOGOUT/REGISTER/SIGN IN | |
467 | rmap.connect('login_home', '%s/login' % ADMIN_PREFIX, controller='login') |
|
469 | rmap.connect('login_home', '%s/login' % ADMIN_PREFIX, controller='login') | |
468 | rmap.connect('logout_home', '%s/logout' % ADMIN_PREFIX, controller='login', |
|
470 | rmap.connect('logout_home', '%s/logout' % ADMIN_PREFIX, controller='login', | |
469 | action='logout') |
|
471 | action='logout') | |
470 |
|
472 | |||
471 | rmap.connect('register', '%s/register' % ADMIN_PREFIX, controller='login', |
|
473 | rmap.connect('register', '%s/register' % ADMIN_PREFIX, controller='login', | |
472 | action='register') |
|
474 | action='register') | |
473 |
|
475 | |||
474 | rmap.connect('reset_password', '%s/password_reset' % ADMIN_PREFIX, |
|
476 | rmap.connect('reset_password', '%s/password_reset' % ADMIN_PREFIX, | |
475 | controller='login', action='password_reset') |
|
477 | controller='login', action='password_reset') | |
476 |
|
478 | |||
477 | rmap.connect('reset_password_confirmation', |
|
479 | rmap.connect('reset_password_confirmation', | |
478 | '%s/password_reset_confirmation' % ADMIN_PREFIX, |
|
480 | '%s/password_reset_confirmation' % ADMIN_PREFIX, | |
479 | controller='login', action='password_reset_confirmation') |
|
481 | controller='login', action='password_reset_confirmation') | |
480 |
|
482 | |||
481 | #FEEDS |
|
483 | #FEEDS | |
482 | rmap.connect('rss_feed_home', '/{repo_name:.*?}/feed/rss', |
|
484 | rmap.connect('rss_feed_home', '/{repo_name:.*?}/feed/rss', | |
483 | controller='feed', action='rss', |
|
485 | controller='feed', action='rss', | |
484 | conditions=dict(function=check_repo)) |
|
486 | conditions=dict(function=check_repo)) | |
485 |
|
487 | |||
486 | rmap.connect('atom_feed_home', '/{repo_name:.*?}/feed/atom', |
|
488 | rmap.connect('atom_feed_home', '/{repo_name:.*?}/feed/atom', | |
487 | controller='feed', action='atom', |
|
489 | controller='feed', action='atom', | |
488 | conditions=dict(function=check_repo)) |
|
490 | conditions=dict(function=check_repo)) | |
489 |
|
491 | |||
490 | #========================================================================== |
|
492 | #========================================================================== | |
491 | # REPOSITORY ROUTES |
|
493 | # REPOSITORY ROUTES | |
492 | #========================================================================== |
|
494 | #========================================================================== | |
493 | rmap.connect('summary_home', '/{repo_name:.*?}', |
|
495 | rmap.connect('summary_home', '/{repo_name:.*?}', | |
494 | controller='summary', |
|
496 | controller='summary', | |
495 | conditions=dict(function=check_repo)) |
|
497 | conditions=dict(function=check_repo)) | |
496 |
|
498 | |||
497 | rmap.connect('repo_size', '/{repo_name:.*?}/repo_size', |
|
499 | rmap.connect('repo_size', '/{repo_name:.*?}/repo_size', | |
498 | controller='summary', action='repo_size', |
|
500 | controller='summary', action='repo_size', | |
499 | conditions=dict(function=check_repo)) |
|
501 | conditions=dict(function=check_repo)) | |
500 |
|
502 | |||
501 | rmap.connect('repos_group_home', '/{group_name:.*}', |
|
503 | rmap.connect('repos_group_home', '/{group_name:.*}', | |
502 | controller='admin/repos_groups', action="show_by_name", |
|
504 | controller='admin/repos_groups', action="show_by_name", | |
503 | conditions=dict(function=check_group)) |
|
505 | conditions=dict(function=check_group)) | |
504 |
|
506 | |||
505 | rmap.connect('changeset_home', '/{repo_name:.*?}/changeset/{revision}', |
|
507 | rmap.connect('changeset_home', '/{repo_name:.*?}/changeset/{revision}', | |
506 | controller='changeset', revision='tip', |
|
508 | controller='changeset', revision='tip', | |
507 | conditions=dict(function=check_repo)) |
|
509 | conditions=dict(function=check_repo)) | |
508 |
|
510 | |||
509 | # no longer user, but kept for routes to work |
|
511 | # no longer user, but kept for routes to work | |
510 | rmap.connect("_edit_repo", "/{repo_name:.*?}/edit", |
|
512 | rmap.connect("_edit_repo", "/{repo_name:.*?}/edit", | |
511 | controller='admin/repos', action="edit", |
|
513 | controller='admin/repos', action="edit", | |
512 | conditions=dict(method=["GET"], function=check_repo) |
|
514 | conditions=dict(method=["GET"], function=check_repo) | |
513 | ) |
|
515 | ) | |
514 |
|
516 | |||
515 | rmap.connect("edit_repo", "/{repo_name:.*?}/settings", |
|
517 | rmap.connect("edit_repo", "/{repo_name:.*?}/settings", | |
516 | controller='admin/repos', action="edit", |
|
518 | controller='admin/repos', action="edit", | |
517 | conditions=dict(method=["GET"], function=check_repo) |
|
519 | conditions=dict(method=["GET"], function=check_repo) | |
518 | ) |
|
520 | ) | |
519 |
|
521 | |||
520 | #still working url for backward compat. |
|
522 | #still working url for backward compat. | |
521 | rmap.connect('raw_changeset_home_depraced', |
|
523 | rmap.connect('raw_changeset_home_depraced', | |
522 | '/{repo_name:.*?}/raw-changeset/{revision}', |
|
524 | '/{repo_name:.*?}/raw-changeset/{revision}', | |
523 | controller='changeset', action='changeset_raw', |
|
525 | controller='changeset', action='changeset_raw', | |
524 | revision='tip', conditions=dict(function=check_repo)) |
|
526 | revision='tip', conditions=dict(function=check_repo)) | |
525 |
|
527 | |||
526 | ## new URLs |
|
528 | ## new URLs | |
527 | rmap.connect('changeset_raw_home', |
|
529 | rmap.connect('changeset_raw_home', | |
528 | '/{repo_name:.*?}/changeset-diff/{revision}', |
|
530 | '/{repo_name:.*?}/changeset-diff/{revision}', | |
529 | controller='changeset', action='changeset_raw', |
|
531 | controller='changeset', action='changeset_raw', | |
530 | revision='tip', conditions=dict(function=check_repo)) |
|
532 | revision='tip', conditions=dict(function=check_repo)) | |
531 |
|
533 | |||
532 | rmap.connect('changeset_patch_home', |
|
534 | rmap.connect('changeset_patch_home', | |
533 | '/{repo_name:.*?}/changeset-patch/{revision}', |
|
535 | '/{repo_name:.*?}/changeset-patch/{revision}', | |
534 | controller='changeset', action='changeset_patch', |
|
536 | controller='changeset', action='changeset_patch', | |
535 | revision='tip', conditions=dict(function=check_repo)) |
|
537 | revision='tip', conditions=dict(function=check_repo)) | |
536 |
|
538 | |||
537 | rmap.connect('changeset_download_home', |
|
539 | rmap.connect('changeset_download_home', | |
538 | '/{repo_name:.*?}/changeset-download/{revision}', |
|
540 | '/{repo_name:.*?}/changeset-download/{revision}', | |
539 | controller='changeset', action='changeset_download', |
|
541 | controller='changeset', action='changeset_download', | |
540 | revision='tip', conditions=dict(function=check_repo)) |
|
542 | revision='tip', conditions=dict(function=check_repo)) | |
541 |
|
543 | |||
542 | rmap.connect('changeset_comment', |
|
544 | rmap.connect('changeset_comment', | |
543 | '/{repo_name:.*?}/changeset/{revision}/comment', |
|
545 | '/{repo_name:.*?}/changeset/{revision}/comment', | |
544 | controller='changeset', revision='tip', action='comment', |
|
546 | controller='changeset', revision='tip', action='comment', | |
545 | conditions=dict(function=check_repo)) |
|
547 | conditions=dict(function=check_repo)) | |
546 |
|
548 | |||
547 | rmap.connect('changeset_comment_preview', |
|
549 | rmap.connect('changeset_comment_preview', | |
548 | '/{repo_name:.*?}/changeset/comment/preview', |
|
550 | '/{repo_name:.*?}/changeset/comment/preview', | |
549 | controller='changeset', action='preview_comment', |
|
551 | controller='changeset', action='preview_comment', | |
550 | conditions=dict(function=check_repo, method=["POST"])) |
|
552 | conditions=dict(function=check_repo, method=["POST"])) | |
551 |
|
553 | |||
552 | rmap.connect('changeset_comment_delete', |
|
554 | rmap.connect('changeset_comment_delete', | |
553 | '/{repo_name:.*?}/changeset/comment/{comment_id}/delete', |
|
555 | '/{repo_name:.*?}/changeset/comment/{comment_id}/delete', | |
554 | controller='changeset', action='delete_comment', |
|
556 | controller='changeset', action='delete_comment', | |
555 | conditions=dict(function=check_repo, method=["DELETE"])) |
|
557 | conditions=dict(function=check_repo, method=["DELETE"])) | |
556 |
|
558 | |||
557 | rmap.connect('changeset_info', '/changeset_info/{repo_name:.*?}/{revision}', |
|
559 | rmap.connect('changeset_info', '/changeset_info/{repo_name:.*?}/{revision}', | |
558 | controller='changeset', action='changeset_info') |
|
560 | controller='changeset', action='changeset_info') | |
559 |
|
561 | |||
560 | rmap.connect('compare_url', |
|
562 | rmap.connect('compare_url', | |
561 | '/{repo_name:.*?}/compare/{org_ref_type}@{org_ref:.*?}...{other_ref_type}@{other_ref:.*?}', |
|
563 | '/{repo_name:.*?}/compare/{org_ref_type}@{org_ref:.*?}...{other_ref_type}@{other_ref:.*?}', | |
562 | controller='compare', action='index', |
|
564 | controller='compare', action='index', | |
563 | conditions=dict(function=check_repo), |
|
565 | conditions=dict(function=check_repo), | |
564 | requirements=dict( |
|
566 | requirements=dict( | |
565 | org_ref_type='(branch|book|tag|rev|__other_ref_type__)', |
|
567 | org_ref_type='(branch|book|tag|rev|__other_ref_type__)', | |
566 | other_ref_type='(branch|book|tag|rev|__org_ref_type__)') |
|
568 | other_ref_type='(branch|book|tag|rev|__org_ref_type__)') | |
567 | ) |
|
569 | ) | |
568 |
|
570 | |||
569 | rmap.connect('pullrequest_home', |
|
571 | rmap.connect('pullrequest_home', | |
570 | '/{repo_name:.*?}/pull-request/new', controller='pullrequests', |
|
572 | '/{repo_name:.*?}/pull-request/new', controller='pullrequests', | |
571 | action='index', conditions=dict(function=check_repo, |
|
573 | action='index', conditions=dict(function=check_repo, | |
572 | method=["GET"])) |
|
574 | method=["GET"])) | |
573 |
|
575 | |||
574 | rmap.connect('pullrequest', |
|
576 | rmap.connect('pullrequest', | |
575 | '/{repo_name:.*?}/pull-request/new', controller='pullrequests', |
|
577 | '/{repo_name:.*?}/pull-request/new', controller='pullrequests', | |
576 | action='create', conditions=dict(function=check_repo, |
|
578 | action='create', conditions=dict(function=check_repo, | |
577 | method=["POST"])) |
|
579 | method=["POST"])) | |
578 |
|
580 | |||
579 | rmap.connect('pullrequest_show', |
|
581 | rmap.connect('pullrequest_show', | |
580 | '/{repo_name:.*?}/pull-request/{pull_request_id}', |
|
582 | '/{repo_name:.*?}/pull-request/{pull_request_id}', | |
581 | controller='pullrequests', |
|
583 | controller='pullrequests', | |
582 | action='show', conditions=dict(function=check_repo, |
|
584 | action='show', conditions=dict(function=check_repo, | |
583 | method=["GET"])) |
|
585 | method=["GET"])) | |
584 | rmap.connect('pullrequest_update', |
|
586 | rmap.connect('pullrequest_update', | |
585 | '/{repo_name:.*?}/pull-request/{pull_request_id}', |
|
587 | '/{repo_name:.*?}/pull-request/{pull_request_id}', | |
586 | controller='pullrequests', |
|
588 | controller='pullrequests', | |
587 | action='update', conditions=dict(function=check_repo, |
|
589 | action='update', conditions=dict(function=check_repo, | |
588 | method=["PUT"])) |
|
590 | method=["PUT"])) | |
589 | rmap.connect('pullrequest_delete', |
|
591 | rmap.connect('pullrequest_delete', | |
590 | '/{repo_name:.*?}/pull-request/{pull_request_id}', |
|
592 | '/{repo_name:.*?}/pull-request/{pull_request_id}', | |
591 | controller='pullrequests', |
|
593 | controller='pullrequests', | |
592 | action='delete', conditions=dict(function=check_repo, |
|
594 | action='delete', conditions=dict(function=check_repo, | |
593 | method=["DELETE"])) |
|
595 | method=["DELETE"])) | |
594 |
|
596 | |||
595 | rmap.connect('pullrequest_show_all', |
|
597 | rmap.connect('pullrequest_show_all', | |
596 | '/{repo_name:.*?}/pull-request', |
|
598 | '/{repo_name:.*?}/pull-request', | |
597 | controller='pullrequests', |
|
599 | controller='pullrequests', | |
598 | action='show_all', conditions=dict(function=check_repo, |
|
600 | action='show_all', conditions=dict(function=check_repo, | |
599 | method=["GET"])) |
|
601 | method=["GET"])) | |
600 |
|
602 | |||
601 | rmap.connect('pullrequest_comment', |
|
603 | rmap.connect('pullrequest_comment', | |
602 | '/{repo_name:.*?}/pull-request-comment/{pull_request_id}', |
|
604 | '/{repo_name:.*?}/pull-request-comment/{pull_request_id}', | |
603 | controller='pullrequests', |
|
605 | controller='pullrequests', | |
604 | action='comment', conditions=dict(function=check_repo, |
|
606 | action='comment', conditions=dict(function=check_repo, | |
605 | method=["POST"])) |
|
607 | method=["POST"])) | |
606 |
|
608 | |||
607 | rmap.connect('pullrequest_comment_delete', |
|
609 | rmap.connect('pullrequest_comment_delete', | |
608 | '/{repo_name:.*?}/pull-request-comment/{comment_id}/delete', |
|
610 | '/{repo_name:.*?}/pull-request-comment/{comment_id}/delete', | |
609 | controller='pullrequests', action='delete_comment', |
|
611 | controller='pullrequests', action='delete_comment', | |
610 | conditions=dict(function=check_repo, method=["DELETE"])) |
|
612 | conditions=dict(function=check_repo, method=["DELETE"])) | |
611 |
|
613 | |||
612 | rmap.connect('summary_home_summary', '/{repo_name:.*?}/summary', |
|
614 | rmap.connect('summary_home_summary', '/{repo_name:.*?}/summary', | |
613 | controller='summary', conditions=dict(function=check_repo)) |
|
615 | controller='summary', conditions=dict(function=check_repo)) | |
614 |
|
616 | |||
615 | rmap.connect('branches_home', '/{repo_name:.*?}/branches', |
|
617 | rmap.connect('branches_home', '/{repo_name:.*?}/branches', | |
616 | controller='branches', conditions=dict(function=check_repo)) |
|
618 | controller='branches', conditions=dict(function=check_repo)) | |
617 |
|
619 | |||
618 | rmap.connect('tags_home', '/{repo_name:.*?}/tags', |
|
620 | rmap.connect('tags_home', '/{repo_name:.*?}/tags', | |
619 | controller='tags', conditions=dict(function=check_repo)) |
|
621 | controller='tags', conditions=dict(function=check_repo)) | |
620 |
|
622 | |||
621 | rmap.connect('bookmarks_home', '/{repo_name:.*?}/bookmarks', |
|
623 | rmap.connect('bookmarks_home', '/{repo_name:.*?}/bookmarks', | |
622 | controller='bookmarks', conditions=dict(function=check_repo)) |
|
624 | controller='bookmarks', conditions=dict(function=check_repo)) | |
623 |
|
625 | |||
624 | rmap.connect('changelog_home', '/{repo_name:.*?}/changelog', |
|
626 | rmap.connect('changelog_home', '/{repo_name:.*?}/changelog', | |
625 | controller='changelog', conditions=dict(function=check_repo)) |
|
627 | controller='changelog', conditions=dict(function=check_repo)) | |
626 |
|
628 | |||
627 | rmap.connect('changelog_summary_home', '/{repo_name:.*?}/changelog_summary', |
|
629 | rmap.connect('changelog_summary_home', '/{repo_name:.*?}/changelog_summary', | |
628 | controller='changelog', action='changelog_summary', |
|
630 | controller='changelog', action='changelog_summary', | |
629 | conditions=dict(function=check_repo)) |
|
631 | conditions=dict(function=check_repo)) | |
630 |
|
632 | |||
631 | rmap.connect('changelog_file_home', '/{repo_name:.*?}/changelog/{revision}/{f_path:.*}', |
|
633 | rmap.connect('changelog_file_home', '/{repo_name:.*?}/changelog/{revision}/{f_path:.*}', | |
632 | controller='changelog', f_path=None, |
|
634 | controller='changelog', f_path=None, | |
633 | conditions=dict(function=check_repo)) |
|
635 | conditions=dict(function=check_repo)) | |
634 |
|
636 | |||
635 | rmap.connect('changelog_details', '/{repo_name:.*?}/changelog_details/{cs}', |
|
637 | rmap.connect('changelog_details', '/{repo_name:.*?}/changelog_details/{cs}', | |
636 | controller='changelog', action='changelog_details', |
|
638 | controller='changelog', action='changelog_details', | |
637 | conditions=dict(function=check_repo)) |
|
639 | conditions=dict(function=check_repo)) | |
638 |
|
640 | |||
639 | rmap.connect('files_home', '/{repo_name:.*?}/files/{revision}/{f_path:.*}', |
|
641 | rmap.connect('files_home', '/{repo_name:.*?}/files/{revision}/{f_path:.*}', | |
640 | controller='files', revision='tip', f_path='', |
|
642 | controller='files', revision='tip', f_path='', | |
641 | conditions=dict(function=check_repo)) |
|
643 | conditions=dict(function=check_repo)) | |
642 |
|
644 | |||
643 | rmap.connect('files_home_nopath', '/{repo_name:.*?}/files/{revision}', |
|
645 | rmap.connect('files_home_nopath', '/{repo_name:.*?}/files/{revision}', | |
644 | controller='files', revision='tip', f_path='', |
|
646 | controller='files', revision='tip', f_path='', | |
645 | conditions=dict(function=check_repo)) |
|
647 | conditions=dict(function=check_repo)) | |
646 |
|
648 | |||
647 | rmap.connect('files_history_home', |
|
649 | rmap.connect('files_history_home', | |
648 | '/{repo_name:.*?}/history/{revision}/{f_path:.*}', |
|
650 | '/{repo_name:.*?}/history/{revision}/{f_path:.*}', | |
649 | controller='files', action='history', revision='tip', f_path='', |
|
651 | controller='files', action='history', revision='tip', f_path='', | |
650 | conditions=dict(function=check_repo)) |
|
652 | conditions=dict(function=check_repo)) | |
651 |
|
653 | |||
652 | rmap.connect('files_diff_home', '/{repo_name:.*?}/diff/{f_path:.*}', |
|
654 | rmap.connect('files_diff_home', '/{repo_name:.*?}/diff/{f_path:.*}', | |
653 | controller='files', action='diff', revision='tip', f_path='', |
|
655 | controller='files', action='diff', revision='tip', f_path='', | |
654 | conditions=dict(function=check_repo)) |
|
656 | conditions=dict(function=check_repo)) | |
655 |
|
657 | |||
656 | rmap.connect('files_rawfile_home', |
|
658 | rmap.connect('files_rawfile_home', | |
657 | '/{repo_name:.*?}/rawfile/{revision}/{f_path:.*}', |
|
659 | '/{repo_name:.*?}/rawfile/{revision}/{f_path:.*}', | |
658 | controller='files', action='rawfile', revision='tip', |
|
660 | controller='files', action='rawfile', revision='tip', | |
659 | f_path='', conditions=dict(function=check_repo)) |
|
661 | f_path='', conditions=dict(function=check_repo)) | |
660 |
|
662 | |||
661 | rmap.connect('files_raw_home', |
|
663 | rmap.connect('files_raw_home', | |
662 | '/{repo_name:.*?}/raw/{revision}/{f_path:.*}', |
|
664 | '/{repo_name:.*?}/raw/{revision}/{f_path:.*}', | |
663 | controller='files', action='raw', revision='tip', f_path='', |
|
665 | controller='files', action='raw', revision='tip', f_path='', | |
664 | conditions=dict(function=check_repo)) |
|
666 | conditions=dict(function=check_repo)) | |
665 |
|
667 | |||
666 | rmap.connect('files_annotate_home', |
|
668 | rmap.connect('files_annotate_home', | |
667 | '/{repo_name:.*?}/annotate/{revision}/{f_path:.*}', |
|
669 | '/{repo_name:.*?}/annotate/{revision}/{f_path:.*}', | |
668 | controller='files', action='index', revision='tip', |
|
670 | controller='files', action='index', revision='tip', | |
669 | f_path='', annotate=True, conditions=dict(function=check_repo)) |
|
671 | f_path='', annotate=True, conditions=dict(function=check_repo)) | |
670 |
|
672 | |||
671 | rmap.connect('files_edit_home', |
|
673 | rmap.connect('files_edit_home', | |
672 | '/{repo_name:.*?}/edit/{revision}/{f_path:.*}', |
|
674 | '/{repo_name:.*?}/edit/{revision}/{f_path:.*}', | |
673 | controller='files', action='edit', revision='tip', |
|
675 | controller='files', action='edit', revision='tip', | |
674 | f_path='', conditions=dict(function=check_repo)) |
|
676 | f_path='', conditions=dict(function=check_repo)) | |
675 |
|
677 | |||
676 | rmap.connect('files_add_home', |
|
678 | rmap.connect('files_add_home', | |
677 | '/{repo_name:.*?}/add/{revision}/{f_path:.*}', |
|
679 | '/{repo_name:.*?}/add/{revision}/{f_path:.*}', | |
678 | controller='files', action='add', revision='tip', |
|
680 | controller='files', action='add', revision='tip', | |
679 | f_path='', conditions=dict(function=check_repo)) |
|
681 | f_path='', conditions=dict(function=check_repo)) | |
680 |
|
682 | |||
681 | rmap.connect('files_archive_home', '/{repo_name:.*?}/archive/{fname}', |
|
683 | rmap.connect('files_archive_home', '/{repo_name:.*?}/archive/{fname}', | |
682 | controller='files', action='archivefile', |
|
684 | controller='files', action='archivefile', | |
683 | conditions=dict(function=check_repo)) |
|
685 | conditions=dict(function=check_repo)) | |
684 |
|
686 | |||
685 | rmap.connect('files_nodelist_home', |
|
687 | rmap.connect('files_nodelist_home', | |
686 | '/{repo_name:.*?}/nodelist/{revision}/{f_path:.*}', |
|
688 | '/{repo_name:.*?}/nodelist/{revision}/{f_path:.*}', | |
687 | controller='files', action='nodelist', |
|
689 | controller='files', action='nodelist', | |
688 | conditions=dict(function=check_repo)) |
|
690 | conditions=dict(function=check_repo)) | |
689 |
|
691 | |||
690 | rmap.connect('repo_fork_create_home', '/{repo_name:.*?}/fork', |
|
692 | rmap.connect('repo_fork_create_home', '/{repo_name:.*?}/fork', | |
691 | controller='forks', action='fork_create', |
|
693 | controller='forks', action='fork_create', | |
692 | conditions=dict(function=check_repo, method=["POST"])) |
|
694 | conditions=dict(function=check_repo, method=["POST"])) | |
693 |
|
695 | |||
694 | rmap.connect('repo_fork_home', '/{repo_name:.*?}/fork', |
|
696 | rmap.connect('repo_fork_home', '/{repo_name:.*?}/fork', | |
695 | controller='forks', action='fork', |
|
697 | controller='forks', action='fork', | |
696 | conditions=dict(function=check_repo)) |
|
698 | conditions=dict(function=check_repo)) | |
697 |
|
699 | |||
698 | rmap.connect('repo_forks_home', '/{repo_name:.*?}/forks', |
|
700 | rmap.connect('repo_forks_home', '/{repo_name:.*?}/forks', | |
699 | controller='forks', action='forks', |
|
701 | controller='forks', action='forks', | |
700 | conditions=dict(function=check_repo)) |
|
702 | conditions=dict(function=check_repo)) | |
701 |
|
703 | |||
702 | rmap.connect('repo_followers_home', '/{repo_name:.*?}/followers', |
|
704 | rmap.connect('repo_followers_home', '/{repo_name:.*?}/followers', | |
703 | controller='followers', action='followers', |
|
705 | controller='followers', action='followers', | |
704 | conditions=dict(function=check_repo)) |
|
706 | conditions=dict(function=check_repo)) | |
705 |
|
707 | |||
706 | return rmap |
|
708 | return rmap |
@@ -1,195 +1,198 b'' | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 | """ |
|
2 | """ | |
3 | rhodecode.controllers.admin.gist |
|
3 | rhodecode.controllers.admin.gist | |
4 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
4 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
5 |
|
5 | |||
6 | gist controller for RhodeCode |
|
6 | gist controller for RhodeCode | |
7 |
|
7 | |||
8 | :created_on: May 9, 2013 |
|
8 | :created_on: May 9, 2013 | |
9 | :author: marcink |
|
9 | :author: marcink | |
10 | :copyright: (C) 2010-2013 Marcin Kuzminski <marcin@python-works.com> |
|
10 | :copyright: (C) 2010-2013 Marcin Kuzminski <marcin@python-works.com> | |
11 | :license: GPLv3, see COPYING for more details. |
|
11 | :license: GPLv3, see COPYING for more details. | |
12 | """ |
|
12 | """ | |
13 | # This program is free software: you can redistribute it and/or modify |
|
13 | # This program is free software: you can redistribute it and/or modify | |
14 | # it under the terms of the GNU General Public License as published by |
|
14 | # it under the terms of the GNU General Public License as published by | |
15 | # the Free Software Foundation, either version 3 of the License, or |
|
15 | # the Free Software Foundation, either version 3 of the License, or | |
16 | # (at your option) any later version. |
|
16 | # (at your option) any later version. | |
17 | # |
|
17 | # | |
18 | # This program is distributed in the hope that it will be useful, |
|
18 | # This program is distributed in the hope that it will be useful, | |
19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
21 | # GNU General Public License for more details. |
|
21 | # GNU General Public License for more details. | |
22 | # |
|
22 | # | |
23 | # You should have received a copy of the GNU General Public License |
|
23 | # You should have received a copy of the GNU General Public License | |
24 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
24 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
25 | import time |
|
25 | import time | |
26 | import logging |
|
26 | import logging | |
27 | import traceback |
|
27 | import traceback | |
28 | import formencode |
|
28 | import formencode | |
29 | from formencode import htmlfill |
|
29 | from formencode import htmlfill | |
30 |
|
30 | |||
31 | from pylons import request, tmpl_context as c, url |
|
31 | from pylons import request, response, tmpl_context as c, url | |
32 | from pylons.controllers.util import abort, redirect |
|
32 | from pylons.controllers.util import abort, redirect | |
33 | from pylons.i18n.translation import _ |
|
33 | from pylons.i18n.translation import _ | |
34 |
|
34 | |||
35 | from rhodecode.model.forms import GistForm |
|
35 | from rhodecode.model.forms import GistForm | |
36 | from rhodecode.model.gist import GistModel |
|
36 | from rhodecode.model.gist import GistModel | |
37 | from rhodecode.model.meta import Session |
|
37 | from rhodecode.model.meta import Session | |
38 | from rhodecode.model.db import Gist |
|
38 | from rhodecode.model.db import Gist | |
39 | from rhodecode.lib import helpers as h |
|
39 | from rhodecode.lib import helpers as h | |
40 | from rhodecode.lib.base import BaseController, render |
|
40 | from rhodecode.lib.base import BaseController, render | |
41 | from rhodecode.lib.auth import LoginRequired, NotAnonymous |
|
41 | from rhodecode.lib.auth import LoginRequired, NotAnonymous | |
42 | from rhodecode.lib.utils2 import safe_str, safe_int, time_to_datetime |
|
42 | from rhodecode.lib.utils2 import safe_str, safe_int, time_to_datetime | |
43 | from rhodecode.lib.helpers import Page |
|
43 | from rhodecode.lib.helpers import Page | |
44 | from webob.exc import HTTPNotFound, HTTPForbidden |
|
44 | from webob.exc import HTTPNotFound, HTTPForbidden | |
45 | from sqlalchemy.sql.expression import or_ |
|
45 | from sqlalchemy.sql.expression import or_ | |
46 | from rhodecode.lib.vcs.exceptions import VCSError |
|
46 | from rhodecode.lib.vcs.exceptions import VCSError | |
47 |
|
47 | |||
48 | log = logging.getLogger(__name__) |
|
48 | log = logging.getLogger(__name__) | |
49 |
|
49 | |||
50 |
|
50 | |||
51 | class GistsController(BaseController): |
|
51 | class GistsController(BaseController): | |
52 | """REST Controller styled on the Atom Publishing Protocol""" |
|
52 | """REST Controller styled on the Atom Publishing Protocol""" | |
53 |
|
53 | |||
54 | def __load_defaults(self): |
|
54 | def __load_defaults(self): | |
55 | c.lifetime_values = [ |
|
55 | c.lifetime_values = [ | |
56 | (str(-1), _('forever')), |
|
56 | (str(-1), _('forever')), | |
57 | (str(5), _('5 minutes')), |
|
57 | (str(5), _('5 minutes')), | |
58 | (str(60), _('1 hour')), |
|
58 | (str(60), _('1 hour')), | |
59 | (str(60 * 24), _('1 day')), |
|
59 | (str(60 * 24), _('1 day')), | |
60 | (str(60 * 24 * 30), _('1 month')), |
|
60 | (str(60 * 24 * 30), _('1 month')), | |
61 | ] |
|
61 | ] | |
62 | c.lifetime_options = [(c.lifetime_values, _("Lifetime"))] |
|
62 | c.lifetime_options = [(c.lifetime_values, _("Lifetime"))] | |
63 |
|
63 | |||
64 | @LoginRequired() |
|
64 | @LoginRequired() | |
65 | def index(self, format='html'): |
|
65 | def index(self, format='html'): | |
66 | """GET /admin/gists: All items in the collection""" |
|
66 | """GET /admin/gists: All items in the collection""" | |
67 | # url('gists') |
|
67 | # url('gists') | |
68 | c.show_private = request.GET.get('private') and c.rhodecode_user.username != 'default' |
|
68 | c.show_private = request.GET.get('private') and c.rhodecode_user.username != 'default' | |
69 | c.show_public = request.GET.get('public') and c.rhodecode_user.username != 'default' |
|
69 | c.show_public = request.GET.get('public') and c.rhodecode_user.username != 'default' | |
70 |
|
70 | |||
71 | gists = Gist().query()\ |
|
71 | gists = Gist().query()\ | |
72 | .filter(or_(Gist.gist_expires == -1, Gist.gist_expires >= time.time()))\ |
|
72 | .filter(or_(Gist.gist_expires == -1, Gist.gist_expires >= time.time()))\ | |
73 | .order_by(Gist.created_on.desc()) |
|
73 | .order_by(Gist.created_on.desc()) | |
74 | if c.show_private: |
|
74 | if c.show_private: | |
75 | c.gists = gists.filter(Gist.gist_type == Gist.GIST_PRIVATE)\ |
|
75 | c.gists = gists.filter(Gist.gist_type == Gist.GIST_PRIVATE)\ | |
76 | .filter(Gist.gist_owner == c.rhodecode_user.user_id) |
|
76 | .filter(Gist.gist_owner == c.rhodecode_user.user_id) | |
77 | elif c.show_public: |
|
77 | elif c.show_public: | |
78 | c.gists = gists.filter(Gist.gist_type == Gist.GIST_PUBLIC)\ |
|
78 | c.gists = gists.filter(Gist.gist_type == Gist.GIST_PUBLIC)\ | |
79 | .filter(Gist.gist_owner == c.rhodecode_user.user_id) |
|
79 | .filter(Gist.gist_owner == c.rhodecode_user.user_id) | |
80 |
|
80 | |||
81 | else: |
|
81 | else: | |
82 | c.gists = gists.filter(Gist.gist_type == Gist.GIST_PUBLIC) |
|
82 | c.gists = gists.filter(Gist.gist_type == Gist.GIST_PUBLIC) | |
83 | p = safe_int(request.GET.get('page', 1), 1) |
|
83 | p = safe_int(request.GET.get('page', 1), 1) | |
84 | c.gists_pager = Page(c.gists, page=p, items_per_page=10) |
|
84 | c.gists_pager = Page(c.gists, page=p, items_per_page=10) | |
85 | return render('admin/gists/index.html') |
|
85 | return render('admin/gists/index.html') | |
86 |
|
86 | |||
87 | @LoginRequired() |
|
87 | @LoginRequired() | |
88 | @NotAnonymous() |
|
88 | @NotAnonymous() | |
89 | def create(self): |
|
89 | def create(self): | |
90 | """POST /admin/gists: Create a new item""" |
|
90 | """POST /admin/gists: Create a new item""" | |
91 | # url('gists') |
|
91 | # url('gists') | |
92 | self.__load_defaults() |
|
92 | self.__load_defaults() | |
93 | gist_form = GistForm([x[0] for x in c.lifetime_values])() |
|
93 | gist_form = GistForm([x[0] for x in c.lifetime_values])() | |
94 | try: |
|
94 | try: | |
95 | form_result = gist_form.to_python(dict(request.POST)) |
|
95 | form_result = gist_form.to_python(dict(request.POST)) | |
96 | #TODO: multiple files support, from the form |
|
96 | #TODO: multiple files support, from the form | |
97 | nodes = { |
|
97 | nodes = { | |
98 | form_result['filename'] or 'gistfile1.txt': { |
|
98 | form_result['filename'] or 'gistfile1.txt': { | |
99 | 'content': form_result['content'], |
|
99 | 'content': form_result['content'], | |
100 | 'lexer': None # autodetect |
|
100 | 'lexer': None # autodetect | |
101 | } |
|
101 | } | |
102 | } |
|
102 | } | |
103 | _public = form_result['public'] |
|
103 | _public = form_result['public'] | |
104 | gist_type = Gist.GIST_PUBLIC if _public else Gist.GIST_PRIVATE |
|
104 | gist_type = Gist.GIST_PUBLIC if _public else Gist.GIST_PRIVATE | |
105 | gist = GistModel().create( |
|
105 | gist = GistModel().create( | |
106 | description=form_result['description'], |
|
106 | description=form_result['description'], | |
107 | owner=c.rhodecode_user, |
|
107 | owner=c.rhodecode_user, | |
108 | gist_mapping=nodes, |
|
108 | gist_mapping=nodes, | |
109 | gist_type=gist_type, |
|
109 | gist_type=gist_type, | |
110 | lifetime=form_result['lifetime'] |
|
110 | lifetime=form_result['lifetime'] | |
111 | ) |
|
111 | ) | |
112 | Session().commit() |
|
112 | Session().commit() | |
113 | new_gist_id = gist.gist_access_id |
|
113 | new_gist_id = gist.gist_access_id | |
114 | except formencode.Invalid, errors: |
|
114 | except formencode.Invalid, errors: | |
115 | defaults = errors.value |
|
115 | defaults = errors.value | |
116 |
|
116 | |||
117 | return formencode.htmlfill.render( |
|
117 | return formencode.htmlfill.render( | |
118 | render('admin/gists/new.html'), |
|
118 | render('admin/gists/new.html'), | |
119 | defaults=defaults, |
|
119 | defaults=defaults, | |
120 | errors=errors.error_dict or {}, |
|
120 | errors=errors.error_dict or {}, | |
121 | prefix_error=False, |
|
121 | prefix_error=False, | |
122 | encoding="UTF-8" |
|
122 | encoding="UTF-8" | |
123 | ) |
|
123 | ) | |
124 |
|
124 | |||
125 | except Exception, e: |
|
125 | except Exception, e: | |
126 | log.error(traceback.format_exc()) |
|
126 | log.error(traceback.format_exc()) | |
127 | h.flash(_('Error occurred during gist creation'), category='error') |
|
127 | h.flash(_('Error occurred during gist creation'), category='error') | |
128 | return redirect(url('new_gist')) |
|
128 | return redirect(url('new_gist')) | |
129 | return redirect(url('gist', gist_id=new_gist_id)) |
|
129 | return redirect(url('gist', gist_id=new_gist_id)) | |
130 |
|
130 | |||
131 | @LoginRequired() |
|
131 | @LoginRequired() | |
132 | @NotAnonymous() |
|
132 | @NotAnonymous() | |
133 | def new(self, format='html'): |
|
133 | def new(self, format='html'): | |
134 | """GET /admin/gists/new: Form to create a new item""" |
|
134 | """GET /admin/gists/new: Form to create a new item""" | |
135 | # url('new_gist') |
|
135 | # url('new_gist') | |
136 | self.__load_defaults() |
|
136 | self.__load_defaults() | |
137 | return render('admin/gists/new.html') |
|
137 | return render('admin/gists/new.html') | |
138 |
|
138 | |||
139 | @LoginRequired() |
|
139 | @LoginRequired() | |
140 | @NotAnonymous() |
|
140 | @NotAnonymous() | |
141 | def update(self, gist_id): |
|
141 | def update(self, gist_id): | |
142 | """PUT /admin/gists/gist_id: Update an existing item""" |
|
142 | """PUT /admin/gists/gist_id: Update an existing item""" | |
143 | # Forms posted to this method should contain a hidden field: |
|
143 | # Forms posted to this method should contain a hidden field: | |
144 | # <input type="hidden" name="_method" value="PUT" /> |
|
144 | # <input type="hidden" name="_method" value="PUT" /> | |
145 | # Or using helpers: |
|
145 | # Or using helpers: | |
146 | # h.form(url('gist', gist_id=ID), |
|
146 | # h.form(url('gist', gist_id=ID), | |
147 | # method='put') |
|
147 | # method='put') | |
148 | # url('gist', gist_id=ID) |
|
148 | # url('gist', gist_id=ID) | |
149 |
|
149 | |||
150 | @LoginRequired() |
|
150 | @LoginRequired() | |
151 | @NotAnonymous() |
|
151 | @NotAnonymous() | |
152 | def delete(self, gist_id): |
|
152 | def delete(self, gist_id): | |
153 | """DELETE /admin/gists/gist_id: Delete an existing item""" |
|
153 | """DELETE /admin/gists/gist_id: Delete an existing item""" | |
154 | # Forms posted to this method should contain a hidden field: |
|
154 | # Forms posted to this method should contain a hidden field: | |
155 | # <input type="hidden" name="_method" value="DELETE" /> |
|
155 | # <input type="hidden" name="_method" value="DELETE" /> | |
156 | # Or using helpers: |
|
156 | # Or using helpers: | |
157 | # h.form(url('gist', gist_id=ID), |
|
157 | # h.form(url('gist', gist_id=ID), | |
158 | # method='delete') |
|
158 | # method='delete') | |
159 | # url('gist', gist_id=ID) |
|
159 | # url('gist', gist_id=ID) | |
160 | gist = GistModel().get_gist(gist_id) |
|
160 | gist = GistModel().get_gist(gist_id) | |
161 | owner = gist.gist_owner == c.rhodecode_user.user_id |
|
161 | owner = gist.gist_owner == c.rhodecode_user.user_id | |
162 | if h.HasPermissionAny('hg.admin')() or owner: |
|
162 | if h.HasPermissionAny('hg.admin')() or owner: | |
163 | GistModel().delete(gist) |
|
163 | GistModel().delete(gist) | |
164 | Session().commit() |
|
164 | Session().commit() | |
165 | h.flash(_('Deleted gist %s') % gist.gist_access_id, category='success') |
|
165 | h.flash(_('Deleted gist %s') % gist.gist_access_id, category='success') | |
166 | else: |
|
166 | else: | |
167 | raise HTTPForbidden() |
|
167 | raise HTTPForbidden() | |
168 |
|
168 | |||
169 | return redirect(url('gists')) |
|
169 | return redirect(url('gists')) | |
170 |
|
170 | |||
171 | @LoginRequired() |
|
171 | @LoginRequired() | |
172 | def show(self, gist_id, format='html'): |
|
172 | def show(self, gist_id, format='html', revision='tip', f_path=None): | |
173 | """GET /admin/gists/gist_id: Show a specific item""" |
|
173 | """GET /admin/gists/gist_id: Show a specific item""" | |
174 | # url('gist', gist_id=ID) |
|
174 | # url('gist', gist_id=ID) | |
175 | c.gist = Gist.get_or_404(gist_id) |
|
175 | c.gist = Gist.get_or_404(gist_id) | |
176 |
|
176 | |||
177 | #check if this gist is not expired |
|
177 | #check if this gist is not expired | |
178 | if c.gist.gist_expires != -1: |
|
178 | if c.gist.gist_expires != -1: | |
179 | if time.time() > c.gist.gist_expires: |
|
179 | if time.time() > c.gist.gist_expires: | |
180 | log.error('Gist expired at %s' % |
|
180 | log.error('Gist expired at %s' % | |
181 | (time_to_datetime(c.gist.gist_expires))) |
|
181 | (time_to_datetime(c.gist.gist_expires))) | |
182 | raise HTTPNotFound() |
|
182 | raise HTTPNotFound() | |
183 | try: |
|
183 | try: | |
184 | c.file_changeset, c.files = GistModel().get_gist_files(gist_id) |
|
184 | c.file_changeset, c.files = GistModel().get_gist_files(gist_id) | |
185 | except VCSError: |
|
185 | except VCSError: | |
186 | log.error(traceback.format_exc()) |
|
186 | log.error(traceback.format_exc()) | |
187 | raise HTTPNotFound() |
|
187 | raise HTTPNotFound() | |
188 |
|
188 | if format == 'raw': | ||
|
189 | content = '\n\n'.join([f.content for f in c.files if (f_path is None or f.path == f_path)]) | |||
|
190 | response.content_type = 'text/plain' | |||
|
191 | return content | |||
189 | return render('admin/gists/show.html') |
|
192 | return render('admin/gists/show.html') | |
190 |
|
193 | |||
191 | @LoginRequired() |
|
194 | @LoginRequired() | |
192 | @NotAnonymous() |
|
195 | @NotAnonymous() | |
193 | def edit(self, gist_id, format='html'): |
|
196 | def edit(self, gist_id, format='html'): | |
194 | """GET /admin/gists/gist_id/edit: Form to edit an existing item""" |
|
197 | """GET /admin/gists/gist_id/edit: Form to edit an existing item""" | |
195 | # url('edit_gist', gist_id=ID) |
|
198 | # url('edit_gist', gist_id=ID) |
@@ -1,92 +1,97 b'' | |||||
1 | ## -*- coding: utf-8 -*- |
|
1 | ## -*- coding: utf-8 -*- | |
2 | <%inherit file="/base/base.html"/> |
|
2 | <%inherit file="/base/base.html"/> | |
3 |
|
3 | |||
4 | <%def name="title()"> |
|
4 | <%def name="title()"> | |
5 | ${_('gist')}:${c.gist.gist_access_id} · ${c.rhodecode_name} |
|
5 | ${_('gist')}:${c.gist.gist_access_id} · ${c.rhodecode_name} | |
6 | </%def> |
|
6 | </%def> | |
7 |
|
7 | |||
8 | <%def name="breadcrumbs_links()"> |
|
8 | <%def name="breadcrumbs_links()"> | |
9 | ${_('Gist')} · gist:${c.gist.gist_access_id} |
|
9 | ${_('Gist')} · gist:${c.gist.gist_access_id} | |
10 | </%def> |
|
10 | </%def> | |
11 |
|
11 | |||
12 | <%def name="page_nav()"> |
|
12 | <%def name="page_nav()"> | |
13 | ${self.menu('gists')} |
|
13 | ${self.menu('gists')} | |
14 | </%def> |
|
14 | </%def> | |
15 |
|
15 | |||
16 | <%def name="main()"> |
|
16 | <%def name="main()"> | |
17 | <div class="box"> |
|
17 | <div class="box"> | |
18 | <!-- box / title --> |
|
18 | <!-- box / title --> | |
19 | <div class="title"> |
|
19 | <div class="title"> | |
20 | ${self.breadcrumbs()} |
|
20 | ${self.breadcrumbs()} | |
21 | %if c.rhodecode_user.username != 'default': |
|
21 | %if c.rhodecode_user.username != 'default': | |
22 | <ul class="links"> |
|
22 | <ul class="links"> | |
23 | <li> |
|
23 | <li> | |
24 | <span>${h.link_to(_(u'Create new gist'), h.url('new_gist'))}</span> |
|
24 | <span>${h.link_to(_(u'Create new gist'), h.url('new_gist'))}</span> | |
25 | </li> |
|
25 | </li> | |
26 | </ul> |
|
26 | </ul> | |
27 | %endif |
|
27 | %endif | |
28 | </div> |
|
28 | </div> | |
29 | <div class="table"> |
|
29 | <div class="table"> | |
30 | <div id="files_data"> |
|
30 | <div id="files_data"> | |
31 | <div id="body" class="codeblock"> |
|
31 | <div id="body" class="codeblock"> | |
32 | <div class="code-header"> |
|
32 | <div class="code-header"> | |
33 | <div class="stats"> |
|
33 | <div class="stats"> | |
34 | <div class="left" style="margin: -4px 0px 0px 0px"> |
|
34 | <div class="left" style="margin: -4px 0px 0px 0px"> | |
35 | %if c.gist.gist_type == 'public': |
|
35 | %if c.gist.gist_type == 'public': | |
36 | <div class="ui-btn green badge">${_('Public gist')}</div> |
|
36 | <div class="ui-btn green badge">${_('Public gist')}</div> | |
37 | %else: |
|
37 | %else: | |
38 | <div class="ui-btn yellow badge">${_('Private gist')}</div> |
|
38 | <div class="ui-btn yellow badge">${_('Private gist')}</div> | |
39 | %endif |
|
39 | %endif | |
40 | </div> |
|
40 | </div> | |
41 | <div class="left item ${'' if c.gist.gist_description else 'last'}" style="color: #AAA"> |
|
41 | <div class="left item ${'' if c.gist.gist_description else 'last'}" style="color: #AAA"> | |
42 | %if c.gist.gist_expires == -1: |
|
42 | %if c.gist.gist_expires == -1: | |
43 | ${_('Expires')}: ${_('never')} |
|
43 | ${_('Expires')}: ${_('never')} | |
44 | %else: |
|
44 | %else: | |
45 | ${_('Expires')}: ${h.age(h.time_to_datetime(c.gist.gist_expires))} |
|
45 | ${_('Expires')}: ${h.age(h.time_to_datetime(c.gist.gist_expires))} | |
46 | %endif |
|
46 | %endif | |
47 | </div> |
|
47 | </div> | |
48 | <div class="left item last"> |
|
48 | <div class="left item last"> | |
49 | ${c.gist.gist_description} |
|
49 | ${c.gist.gist_description} | |
50 | </div> |
|
50 | </div> | |
51 | <div class="buttons"> |
|
51 | %if h.HasPermissionAny('hg.admin')() or c.gist.gist_owner == c.rhodecode_user.user_id: | |
52 | ## only owner should see that |
|
52 | <div style="float:right;margin:-4px 0px 0px 0px"> | |
53 | %if h.HasPermissionAny('hg.admin')() or c.gist.gist_owner == c.rhodecode_user.user_id: |
|
|||
54 | ##${h.link_to(_('Edit'),h.url(''),class_="ui-btn")} |
|
|||
55 | ${h.form(url('gist', gist_id=c.gist.gist_id),method='delete')} |
|
53 | ${h.form(url('gist', gist_id=c.gist.gist_id),method='delete')} | |
56 | ${h.submit('remove_gist', _('Delete'),class_="ui-btn red",onclick="return confirm('"+_('Confirm to delete this gist')+"');")} |
|
54 | ${h.submit('remove_gist', _('Delete'),class_="ui-btn red",onclick="return confirm('"+_('Confirm to delete this gist')+"');")} | |
57 | ${h.end_form()} |
|
55 | ${h.end_form()} | |
58 |
|
|
56 | </div> | |
|
57 | %endif | |||
|
58 | <div class="buttons"> | |||
|
59 | ## only owner should see that | |||
|
60 | ##%if h.HasPermissionAny('hg.admin')() or c.gist.gist_owner == c.rhodecode_user.user_id: | |||
|
61 | ##${h.link_to(_('Edit'),h.url(''),class_="ui-btn")} | |||
|
62 | ##%endif | |||
|
63 | ${h.link_to(_('Show as raw'),h.url('formatted_gist', gist_id=c.gist.gist_id, format='raw'),class_="ui-btn")} | |||
59 | </div> |
|
64 | </div> | |
60 | </div> |
|
65 | </div> | |
61 |
|
66 | |||
62 | <div class="author"> |
|
67 | <div class="author"> | |
63 | <div class="gravatar"> |
|
68 | <div class="gravatar"> | |
64 | <img alt="gravatar" src="${h.gravatar_url(h.email_or_none(c.file_changeset.author),16)}"/> |
|
69 | <img alt="gravatar" src="${h.gravatar_url(h.email_or_none(c.file_changeset.author),16)}"/> | |
65 | </div> |
|
70 | </div> | |
66 | <div title="${c.file_changeset.author}" class="user">${h.person(c.file_changeset.author)} - ${_('created')} ${h.age(c.file_changeset.date)}</div> |
|
71 | <div title="${c.file_changeset.author}" class="user">${h.person(c.file_changeset.author)} - ${_('created')} ${h.age(c.file_changeset.date)}</div> | |
67 | </div> |
|
72 | </div> | |
68 | <div class="commit">${h.urlify_commit(c.file_changeset.message,c.repo_name)}</div> |
|
73 | <div class="commit">${h.urlify_commit(c.file_changeset.message,c.repo_name)}</div> | |
69 | </div> |
|
74 | </div> | |
70 | </div> |
|
75 | </div> | |
71 |
|
76 | |||
72 | ## iterate over the files |
|
77 | ## iterate over the files | |
73 | % for file in c.files: |
|
78 | % for file in c.files: | |
74 | <div style="border: 1px solid #EEE;margin-top:20px"> |
|
79 | <div style="border: 1px solid #EEE;margin-top:20px"> | |
75 | <div id="${h.FID('G', file.path)}" class="stats" style="border-bottom: 1px solid #DDD;padding: 8px 14px;"> |
|
80 | <div id="${h.FID('G', file.path)}" class="stats" style="border-bottom: 1px solid #DDD;padding: 8px 14px;"> | |
76 | <a href="${c.gist.gist_url()}">¶</a> |
|
81 | <a href="${c.gist.gist_url()}">¶</a> | |
77 | <b style="margin:0px 0px 0px 4px">${file.path}</b> |
|
82 | <b style="margin:0px 0px 0px 4px">${file.path}</b> | |
78 |
|
|
83 | <div style="float:right"> | |
79 | ## ${h.link_to(_('Show as raw'),h.url(''),class_="ui-btn")} |
|
84 | ${h.link_to(_('Show as raw'),h.url('formatted_gist_file', gist_id=c.gist.gist_id, format='raw', revision=file.changeset.raw_id, f_path=file.path),class_="ui-btn")} | |
80 |
|
|
85 | </div> | |
81 | </div> |
|
86 | </div> | |
82 | <div class="code-body"> |
|
87 | <div class="code-body"> | |
83 | ${h.pygmentize(file,linenos=True,anchorlinenos=True,lineanchors='L',cssclass="code-highlight")} |
|
88 | ${h.pygmentize(file,linenos=True,anchorlinenos=True,lineanchors='L',cssclass="code-highlight")} | |
84 | </div> |
|
89 | </div> | |
85 | </div> |
|
90 | </div> | |
86 | %endfor |
|
91 | %endfor | |
87 | </div> |
|
92 | </div> | |
88 | </div> |
|
93 | </div> | |
89 |
|
94 | |||
90 |
|
95 | |||
91 | </div> |
|
96 | </div> | |
92 | </%def> |
|
97 | </%def> |
General Comments 0
You need to be logged in to leave comments.
Login now