Show More
@@ -1,661 +1,656 b'' | |||
|
1 | 1 | """ |
|
2 | 2 | Routes configuration |
|
3 | 3 | |
|
4 | 4 | The more specific and detailed routes should be defined first so they |
|
5 | 5 | may take precedent over the more generic routes. For more information |
|
6 | 6 | refer to the routes manual at http://routes.groovie.org/docs/ |
|
7 | 7 | """ |
|
8 | 8 | from __future__ import with_statement |
|
9 | 9 | from routes import Mapper |
|
10 | 10 | |
|
11 | 11 | # prefix for non repository related links needs to be prefixed with `/` |
|
12 | 12 | ADMIN_PREFIX = '/_admin' |
|
13 | 13 | |
|
14 | 14 | |
|
15 | 15 | def make_map(config): |
|
16 | 16 | """Create, configure and return the routes Mapper""" |
|
17 | 17 | rmap = Mapper(directory=config['pylons.paths']['controllers'], |
|
18 | 18 | always_scan=config['debug']) |
|
19 | 19 | rmap.minimization = False |
|
20 | 20 | rmap.explicit = False |
|
21 | 21 | |
|
22 | 22 | from rhodecode.lib.utils import is_valid_repo |
|
23 | 23 | from rhodecode.lib.utils import is_valid_repos_group |
|
24 | 24 | |
|
25 | 25 | def check_repo(environ, match_dict): |
|
26 | 26 | """ |
|
27 | 27 | check for valid repository for proper 404 handling |
|
28 | 28 | |
|
29 | 29 | :param environ: |
|
30 | 30 | :param match_dict: |
|
31 | 31 | """ |
|
32 | 32 | from rhodecode.model.db import Repository |
|
33 | 33 | repo_name = match_dict.get('repo_name') |
|
34 | 34 | |
|
35 | 35 | if match_dict.get('f_path'): |
|
36 | 36 | #fix for multiple initial slashes that causes errors |
|
37 | 37 | match_dict['f_path'] = match_dict['f_path'].lstrip('/') |
|
38 | 38 | |
|
39 | 39 | try: |
|
40 | 40 | by_id = repo_name.split('_') |
|
41 | 41 | if len(by_id) == 2 and by_id[1].isdigit() and by_id[0] == '': |
|
42 | 42 | repo_name = Repository.get(by_id[1]).repo_name |
|
43 | 43 | match_dict['repo_name'] = repo_name |
|
44 | 44 | except Exception: |
|
45 | 45 | pass |
|
46 | 46 | |
|
47 | 47 | return is_valid_repo(repo_name, config['base_path']) |
|
48 | 48 | |
|
49 | 49 | def check_group(environ, match_dict): |
|
50 | 50 | """ |
|
51 | 51 | check for valid repository group for proper 404 handling |
|
52 | 52 | |
|
53 | 53 | :param environ: |
|
54 | 54 | :param match_dict: |
|
55 | 55 | """ |
|
56 | 56 | repos_group_name = match_dict.get('group_name') |
|
57 | 57 | return is_valid_repos_group(repos_group_name, config['base_path']) |
|
58 | 58 | |
|
59 | 59 | def check_group_skip_path(environ, match_dict): |
|
60 | 60 | """ |
|
61 | 61 | check for valid repository group for proper 404 handling, but skips |
|
62 | 62 | verification of existing path |
|
63 | 63 | |
|
64 | 64 | :param environ: |
|
65 | 65 | :param match_dict: |
|
66 | 66 | """ |
|
67 | 67 | repos_group_name = match_dict.get('group_name') |
|
68 | 68 | return is_valid_repos_group(repos_group_name, config['base_path'], |
|
69 | 69 | skip_path_check=True) |
|
70 | 70 | |
|
71 | 71 | def check_int(environ, match_dict): |
|
72 | 72 | return match_dict.get('id').isdigit() |
|
73 | 73 | |
|
74 | 74 | # The ErrorController route (handles 404/500 error pages); it should |
|
75 | 75 | # likely stay at the top, ensuring it can always be resolved |
|
76 | 76 | rmap.connect('/error/{action}', controller='error') |
|
77 | 77 | rmap.connect('/error/{action}/{id}', controller='error') |
|
78 | 78 | |
|
79 | 79 | #========================================================================== |
|
80 | 80 | # CUSTOM ROUTES HERE |
|
81 | 81 | #========================================================================== |
|
82 | 82 | |
|
83 | 83 | #MAIN PAGE |
|
84 | 84 | rmap.connect('home', '/', controller='home', action='index') |
|
85 | 85 | rmap.connect('repo_switcher', '/repos', controller='home', |
|
86 | 86 | action='repo_switcher') |
|
87 | 87 | rmap.connect('branch_tag_switcher', '/branches-tags/{repo_name:.*?}', |
|
88 | 88 | controller='home', action='branch_tag_switcher') |
|
89 | 89 | rmap.connect('bugtracker', |
|
90 | 90 | "http://bitbucket.org/marcinkuzminski/rhodecode/issues", |
|
91 | 91 | _static=True) |
|
92 | 92 | rmap.connect('rst_help', |
|
93 | 93 | "http://docutils.sourceforge.net/docs/user/rst/quickref.html", |
|
94 | 94 | _static=True) |
|
95 | 95 | rmap.connect('rhodecode_official', "http://rhodecode.org", _static=True) |
|
96 | 96 | |
|
97 | 97 | #ADMIN REPOSITORY REST ROUTES |
|
98 | 98 | with rmap.submapper(path_prefix=ADMIN_PREFIX, |
|
99 | 99 | controller='admin/repos') as m: |
|
100 | 100 | m.connect("repos", "/repos", |
|
101 | 101 | action="create", conditions=dict(method=["POST"])) |
|
102 | 102 | m.connect("repos", "/repos", |
|
103 | 103 | action="index", conditions=dict(method=["GET"])) |
|
104 | 104 | m.connect("formatted_repos", "/repos.{format}", |
|
105 | 105 | action="index", |
|
106 | 106 | conditions=dict(method=["GET"])) |
|
107 |
m.connect("new_repo", "/ |
|
|
108 | action="new", conditions=dict(method=["GET"])) | |
|
109 | #TODO: refactor the name | |
|
110 | m.connect("admin_settings_create_repository", "/create_repository", | |
|
107 | m.connect("new_repo", "/create_repository", | |
|
111 | 108 | action="create_repository", conditions=dict(method=["GET"])) |
|
112 | m.connect("formatted_new_repo", "/repos/new.{format}", | |
|
113 | action="new", conditions=dict(method=["GET"])) | |
|
114 | 109 | m.connect("/repos/{repo_name:.*?}", |
|
115 | 110 | action="update", conditions=dict(method=["PUT"], |
|
116 | 111 | function=check_repo)) |
|
117 | 112 | m.connect("/repos/{repo_name:.*?}", |
|
118 | 113 | action="delete", conditions=dict(method=["DELETE"], |
|
119 | 114 | function=check_repo)) |
|
120 | 115 | m.connect("formatted_edit_repo", "/repos/{repo_name:.*?}.{format}/edit", |
|
121 | 116 | action="edit", conditions=dict(method=["GET"], |
|
122 | 117 | function=check_repo)) |
|
123 | 118 | m.connect("repo", "/repos/{repo_name:.*?}", |
|
124 | 119 | action="show", conditions=dict(method=["GET"], |
|
125 | 120 | function=check_repo)) |
|
126 | 121 | m.connect("formatted_repo", "/repos/{repo_name:.*?}.{format}", |
|
127 | 122 | action="show", conditions=dict(method=["GET"], |
|
128 | 123 | function=check_repo)) |
|
129 | 124 | #add repo perm member |
|
130 | 125 | m.connect('set_repo_perm_member', "/set_repo_perm_member/{repo_name:.*?}", |
|
131 | 126 | action="set_repo_perm_member", |
|
132 | 127 | conditions=dict(method=["POST"], function=check_repo)) |
|
133 | 128 | |
|
134 | 129 | #ajax delete repo perm user |
|
135 | 130 | m.connect('delete_repo_user', "/repos_delete_user/{repo_name:.*?}", |
|
136 | 131 | action="delete_perm_user", |
|
137 | 132 | conditions=dict(method=["DELETE"], function=check_repo)) |
|
138 | 133 | |
|
139 | 134 | #ajax delete repo perm users_group |
|
140 | 135 | m.connect('delete_repo_users_group', |
|
141 | 136 | "/repos_delete_users_group/{repo_name:.*?}", |
|
142 | 137 | action="delete_perm_users_group", |
|
143 | 138 | conditions=dict(method=["DELETE"], function=check_repo)) |
|
144 | 139 | |
|
145 | 140 | #settings actions |
|
146 | 141 | m.connect('repo_stats', "/repos_stats/{repo_name:.*?}", |
|
147 | 142 | action="repo_stats", conditions=dict(method=["DELETE"], |
|
148 | 143 | function=check_repo)) |
|
149 | 144 | m.connect('repo_cache', "/repos_cache/{repo_name:.*?}", |
|
150 | 145 | action="repo_cache", conditions=dict(method=["DELETE"], |
|
151 | 146 | function=check_repo)) |
|
152 | 147 | m.connect('repo_public_journal', "/repos_public_journal/{repo_name:.*?}", |
|
153 | 148 | action="repo_public_journal", conditions=dict(method=["PUT"], |
|
154 | 149 | function=check_repo)) |
|
155 | 150 | m.connect('repo_pull', "/repo_pull/{repo_name:.*?}", |
|
156 | 151 | action="repo_pull", conditions=dict(method=["PUT"], |
|
157 | 152 | function=check_repo)) |
|
158 | 153 | m.connect('repo_as_fork', "/repo_as_fork/{repo_name:.*?}", |
|
159 | 154 | action="repo_as_fork", conditions=dict(method=["PUT"], |
|
160 | 155 | function=check_repo)) |
|
161 | 156 | m.connect('repo_locking', "/repo_locking/{repo_name:.*?}", |
|
162 | 157 | action="repo_locking", conditions=dict(method=["PUT"], |
|
163 | 158 | function=check_repo)) |
|
164 | 159 | m.connect('toggle_locking', "/locking_toggle/{repo_name:.*?}", |
|
165 | 160 | action="toggle_locking", conditions=dict(method=["GET"], |
|
166 | 161 | function=check_repo)) |
|
167 | 162 | |
|
168 | 163 | #repo fields |
|
169 | 164 | m.connect('create_repo_fields', "/repo_fields/{repo_name:.*?}/new", |
|
170 | 165 | action="create_repo_field", conditions=dict(method=["PUT"], |
|
171 | 166 | function=check_repo)) |
|
172 | 167 | |
|
173 | 168 | m.connect('delete_repo_fields', "/repo_fields/{repo_name:.*?}/{field_id}", |
|
174 | 169 | action="delete_repo_field", conditions=dict(method=["DELETE"], |
|
175 | 170 | function=check_repo)) |
|
176 | 171 | |
|
177 | 172 | with rmap.submapper(path_prefix=ADMIN_PREFIX, |
|
178 | 173 | controller='admin/repos_groups') as m: |
|
179 | 174 | m.connect("repos_groups", "/repos_groups", |
|
180 | 175 | action="create", conditions=dict(method=["POST"])) |
|
181 | 176 | m.connect("repos_groups", "/repos_groups", |
|
182 | 177 | action="index", conditions=dict(method=["GET"])) |
|
183 | 178 | m.connect("formatted_repos_groups", "/repos_groups.{format}", |
|
184 | 179 | action="index", conditions=dict(method=["GET"])) |
|
185 | 180 | m.connect("new_repos_group", "/repos_groups/new", |
|
186 | 181 | action="new", conditions=dict(method=["GET"])) |
|
187 | 182 | m.connect("formatted_new_repos_group", "/repos_groups/new.{format}", |
|
188 | 183 | action="new", conditions=dict(method=["GET"])) |
|
189 | 184 | m.connect("update_repos_group", "/repos_groups/{group_name:.*?}", |
|
190 | 185 | action="update", conditions=dict(method=["PUT"], |
|
191 | 186 | function=check_group)) |
|
192 | 187 | m.connect("delete_repos_group", "/repos_groups/{group_name:.*?}", |
|
193 | 188 | action="delete", conditions=dict(method=["DELETE"], |
|
194 | 189 | function=check_group_skip_path)) |
|
195 | 190 | m.connect("edit_repos_group", "/repos_groups/{group_name:.*?}/edit", |
|
196 | 191 | action="edit", conditions=dict(method=["GET"], |
|
197 | 192 | function=check_group)) |
|
198 | 193 | m.connect("formatted_edit_repos_group", |
|
199 | 194 | "/repos_groups/{group_name:.*?}.{format}/edit", |
|
200 | 195 | action="edit", conditions=dict(method=["GET"], |
|
201 | 196 | function=check_group)) |
|
202 | 197 | m.connect("repos_group", "/repos_groups/{group_name:.*?}", |
|
203 | 198 | action="show", conditions=dict(method=["GET"], |
|
204 | 199 | function=check_group)) |
|
205 | 200 | m.connect("formatted_repos_group", "/repos_groups/{group_name:.*?}.{format}", |
|
206 | 201 | action="show", conditions=dict(method=["GET"], |
|
207 | 202 | function=check_group)) |
|
208 | 203 | # ajax delete repository group perm user |
|
209 | 204 | m.connect('delete_repos_group_user_perm', |
|
210 | 205 | "/delete_repos_group_user_perm/{group_name:.*?}", |
|
211 | 206 | action="delete_repos_group_user_perm", |
|
212 | 207 | conditions=dict(method=["DELETE"], function=check_group)) |
|
213 | 208 | |
|
214 | 209 | # ajax delete repository group perm users_group |
|
215 | 210 | m.connect('delete_repos_group_users_group_perm', |
|
216 | 211 | "/delete_repos_group_users_group_perm/{group_name:.*?}", |
|
217 | 212 | action="delete_repos_group_users_group_perm", |
|
218 | 213 | conditions=dict(method=["DELETE"], function=check_group)) |
|
219 | 214 | |
|
220 | 215 | #ADMIN USER REST ROUTES |
|
221 | 216 | with rmap.submapper(path_prefix=ADMIN_PREFIX, |
|
222 | 217 | controller='admin/users') as m: |
|
223 | 218 | m.connect("users", "/users", |
|
224 | 219 | action="create", conditions=dict(method=["POST"])) |
|
225 | 220 | m.connect("users", "/users", |
|
226 | 221 | action="index", conditions=dict(method=["GET"])) |
|
227 | 222 | m.connect("formatted_users", "/users.{format}", |
|
228 | 223 | action="index", conditions=dict(method=["GET"])) |
|
229 | 224 | m.connect("new_user", "/users/new", |
|
230 | 225 | action="new", conditions=dict(method=["GET"])) |
|
231 | 226 | m.connect("formatted_new_user", "/users/new.{format}", |
|
232 | 227 | action="new", conditions=dict(method=["GET"])) |
|
233 | 228 | m.connect("update_user", "/users/{id}", |
|
234 | 229 | action="update", conditions=dict(method=["PUT"])) |
|
235 | 230 | m.connect("delete_user", "/users/{id}", |
|
236 | 231 | action="delete", conditions=dict(method=["DELETE"])) |
|
237 | 232 | m.connect("edit_user", "/users/{id}/edit", |
|
238 | 233 | action="edit", conditions=dict(method=["GET"])) |
|
239 | 234 | m.connect("formatted_edit_user", |
|
240 | 235 | "/users/{id}.{format}/edit", |
|
241 | 236 | action="edit", conditions=dict(method=["GET"])) |
|
242 | 237 | m.connect("user", "/users/{id}", |
|
243 | 238 | action="show", conditions=dict(method=["GET"])) |
|
244 | 239 | m.connect("formatted_user", "/users/{id}.{format}", |
|
245 | 240 | action="show", conditions=dict(method=["GET"])) |
|
246 | 241 | |
|
247 | 242 | #EXTRAS USER ROUTES |
|
248 | 243 | m.connect("user_perm", "/users_perm/{id}", |
|
249 | 244 | action="update_perm", conditions=dict(method=["PUT"])) |
|
250 | 245 | m.connect("user_emails", "/users_emails/{id}", |
|
251 | 246 | action="add_email", conditions=dict(method=["PUT"])) |
|
252 | 247 | m.connect("user_emails_delete", "/users_emails/{id}", |
|
253 | 248 | action="delete_email", conditions=dict(method=["DELETE"])) |
|
254 | 249 | m.connect("user_ips", "/users_ips/{id}", |
|
255 | 250 | action="add_ip", conditions=dict(method=["PUT"])) |
|
256 | 251 | m.connect("user_ips_delete", "/users_ips/{id}", |
|
257 | 252 | action="delete_ip", conditions=dict(method=["DELETE"])) |
|
258 | 253 | |
|
259 | 254 | #ADMIN USER GROUPS REST ROUTES |
|
260 | 255 | with rmap.submapper(path_prefix=ADMIN_PREFIX, |
|
261 | 256 | controller='admin/users_groups') as m: |
|
262 | 257 | m.connect("users_groups", "/users_groups", |
|
263 | 258 | action="create", conditions=dict(method=["POST"])) |
|
264 | 259 | m.connect("users_groups", "/users_groups", |
|
265 | 260 | action="index", conditions=dict(method=["GET"])) |
|
266 | 261 | m.connect("formatted_users_groups", "/users_groups.{format}", |
|
267 | 262 | action="index", conditions=dict(method=["GET"])) |
|
268 | 263 | m.connect("new_users_group", "/users_groups/new", |
|
269 | 264 | action="new", conditions=dict(method=["GET"])) |
|
270 | 265 | m.connect("formatted_new_users_group", "/users_groups/new.{format}", |
|
271 | 266 | action="new", conditions=dict(method=["GET"])) |
|
272 | 267 | m.connect("update_users_group", "/users_groups/{id}", |
|
273 | 268 | action="update", conditions=dict(method=["PUT"])) |
|
274 | 269 | m.connect("delete_users_group", "/users_groups/{id}", |
|
275 | 270 | action="delete", conditions=dict(method=["DELETE"])) |
|
276 | 271 | m.connect("edit_users_group", "/users_groups/{id}/edit", |
|
277 | 272 | action="edit", conditions=dict(method=["GET"])) |
|
278 | 273 | m.connect("formatted_edit_users_group", |
|
279 | 274 | "/users_groups/{id}.{format}/edit", |
|
280 | 275 | action="edit", conditions=dict(method=["GET"])) |
|
281 | 276 | m.connect("users_group", "/users_groups/{id}", |
|
282 | 277 | action="show", conditions=dict(method=["GET"])) |
|
283 | 278 | m.connect("formatted_users_group", "/users_groups/{id}.{format}", |
|
284 | 279 | action="show", conditions=dict(method=["GET"])) |
|
285 | 280 | |
|
286 | 281 | #EXTRAS USER ROUTES |
|
287 | 282 | m.connect("users_group_perm", "/users_groups_perm/{id}", |
|
288 | 283 | action="update_perm", conditions=dict(method=["PUT"])) |
|
289 | 284 | |
|
290 | 285 | #ADMIN GROUP REST ROUTES |
|
291 | 286 | rmap.resource('group', 'groups', |
|
292 | 287 | controller='admin/groups', path_prefix=ADMIN_PREFIX) |
|
293 | 288 | |
|
294 | 289 | #ADMIN PERMISSIONS REST ROUTES |
|
295 | 290 | rmap.resource('permission', 'permissions', |
|
296 | 291 | controller='admin/permissions', path_prefix=ADMIN_PREFIX) |
|
297 | 292 | |
|
298 | 293 | #ADMIN DEFAULTS REST ROUTES |
|
299 | 294 | rmap.resource('default', 'defaults', |
|
300 | 295 | controller='admin/defaults', path_prefix=ADMIN_PREFIX) |
|
301 | 296 | |
|
302 | 297 | ##ADMIN LDAP SETTINGS |
|
303 | 298 | rmap.connect('ldap_settings', '%s/ldap' % ADMIN_PREFIX, |
|
304 | 299 | controller='admin/ldap_settings', action='ldap_settings', |
|
305 | 300 | conditions=dict(method=["POST"])) |
|
306 | 301 | |
|
307 | 302 | rmap.connect('ldap_home', '%s/ldap' % ADMIN_PREFIX, |
|
308 | 303 | controller='admin/ldap_settings') |
|
309 | 304 | |
|
310 | 305 | #ADMIN SETTINGS REST ROUTES |
|
311 | 306 | with rmap.submapper(path_prefix=ADMIN_PREFIX, |
|
312 | 307 | controller='admin/settings') as m: |
|
313 | 308 | m.connect("admin_settings", "/settings", |
|
314 | 309 | action="create", conditions=dict(method=["POST"])) |
|
315 | 310 | m.connect("admin_settings", "/settings", |
|
316 | 311 | action="index", conditions=dict(method=["GET"])) |
|
317 | 312 | m.connect("formatted_admin_settings", "/settings.{format}", |
|
318 | 313 | action="index", conditions=dict(method=["GET"])) |
|
319 | 314 | m.connect("admin_new_setting", "/settings/new", |
|
320 | 315 | action="new", conditions=dict(method=["GET"])) |
|
321 | 316 | m.connect("formatted_admin_new_setting", "/settings/new.{format}", |
|
322 | 317 | action="new", conditions=dict(method=["GET"])) |
|
323 | 318 | m.connect("/settings/{setting_id}", |
|
324 | 319 | action="update", conditions=dict(method=["PUT"])) |
|
325 | 320 | m.connect("/settings/{setting_id}", |
|
326 | 321 | action="delete", conditions=dict(method=["DELETE"])) |
|
327 | 322 | m.connect("admin_edit_setting", "/settings/{setting_id}/edit", |
|
328 | 323 | action="edit", conditions=dict(method=["GET"])) |
|
329 | 324 | m.connect("formatted_admin_edit_setting", |
|
330 | 325 | "/settings/{setting_id}.{format}/edit", |
|
331 | 326 | action="edit", conditions=dict(method=["GET"])) |
|
332 | 327 | m.connect("admin_setting", "/settings/{setting_id}", |
|
333 | 328 | action="show", conditions=dict(method=["GET"])) |
|
334 | 329 | m.connect("formatted_admin_setting", "/settings/{setting_id}.{format}", |
|
335 | 330 | action="show", conditions=dict(method=["GET"])) |
|
336 | 331 | m.connect("admin_settings_my_account", "/my_account", |
|
337 | 332 | action="my_account", conditions=dict(method=["GET"])) |
|
338 | 333 | m.connect("admin_settings_my_account_update", "/my_account_update", |
|
339 | 334 | action="my_account_update", conditions=dict(method=["PUT"])) |
|
340 | 335 | m.connect("admin_settings_my_repos", "/my_account/repos", |
|
341 | 336 | action="my_account_my_repos", conditions=dict(method=["GET"])) |
|
342 | 337 | m.connect("admin_settings_my_pullrequests", "/my_account/pull_requests", |
|
343 | 338 | action="my_account_my_pullrequests", conditions=dict(method=["GET"])) |
|
344 | 339 | |
|
345 | 340 | #NOTIFICATION REST ROUTES |
|
346 | 341 | with rmap.submapper(path_prefix=ADMIN_PREFIX, |
|
347 | 342 | controller='admin/notifications') as m: |
|
348 | 343 | m.connect("notifications", "/notifications", |
|
349 | 344 | action="create", conditions=dict(method=["POST"])) |
|
350 | 345 | m.connect("notifications", "/notifications", |
|
351 | 346 | action="index", conditions=dict(method=["GET"])) |
|
352 | 347 | m.connect("notifications_mark_all_read", "/notifications/mark_all_read", |
|
353 | 348 | action="mark_all_read", conditions=dict(method=["GET"])) |
|
354 | 349 | m.connect("formatted_notifications", "/notifications.{format}", |
|
355 | 350 | action="index", conditions=dict(method=["GET"])) |
|
356 | 351 | m.connect("new_notification", "/notifications/new", |
|
357 | 352 | action="new", conditions=dict(method=["GET"])) |
|
358 | 353 | m.connect("formatted_new_notification", "/notifications/new.{format}", |
|
359 | 354 | action="new", conditions=dict(method=["GET"])) |
|
360 | 355 | m.connect("/notification/{notification_id}", |
|
361 | 356 | action="update", conditions=dict(method=["PUT"])) |
|
362 | 357 | m.connect("/notification/{notification_id}", |
|
363 | 358 | action="delete", conditions=dict(method=["DELETE"])) |
|
364 | 359 | m.connect("edit_notification", "/notification/{notification_id}/edit", |
|
365 | 360 | action="edit", conditions=dict(method=["GET"])) |
|
366 | 361 | m.connect("formatted_edit_notification", |
|
367 | 362 | "/notification/{notification_id}.{format}/edit", |
|
368 | 363 | action="edit", conditions=dict(method=["GET"])) |
|
369 | 364 | m.connect("notification", "/notification/{notification_id}", |
|
370 | 365 | action="show", conditions=dict(method=["GET"])) |
|
371 | 366 | m.connect("formatted_notification", "/notifications/{notification_id}.{format}", |
|
372 | 367 | action="show", conditions=dict(method=["GET"])) |
|
373 | 368 | |
|
374 | 369 | #ADMIN MAIN PAGES |
|
375 | 370 | with rmap.submapper(path_prefix=ADMIN_PREFIX, |
|
376 | 371 | controller='admin/admin') as m: |
|
377 | 372 | m.connect('admin_home', '', action='index') |
|
378 | 373 | m.connect('admin_add_repo', '/add_repo/{new_repo:[a-z0-9\. _-]*}', |
|
379 | 374 | action='add_repo') |
|
380 | 375 | |
|
381 | 376 | #========================================================================== |
|
382 | 377 | # API V2 |
|
383 | 378 | #========================================================================== |
|
384 | 379 | with rmap.submapper(path_prefix=ADMIN_PREFIX, |
|
385 | 380 | controller='api/api') as m: |
|
386 | 381 | m.connect('api', '/api') |
|
387 | 382 | |
|
388 | 383 | #USER JOURNAL |
|
389 | 384 | rmap.connect('journal', '%s/journal' % ADMIN_PREFIX, |
|
390 | 385 | controller='journal', action='index') |
|
391 | 386 | rmap.connect('journal_rss', '%s/journal/rss' % ADMIN_PREFIX, |
|
392 | 387 | controller='journal', action='journal_rss') |
|
393 | 388 | rmap.connect('journal_atom', '%s/journal/atom' % ADMIN_PREFIX, |
|
394 | 389 | controller='journal', action='journal_atom') |
|
395 | 390 | |
|
396 | 391 | rmap.connect('public_journal', '%s/public_journal' % ADMIN_PREFIX, |
|
397 | 392 | controller='journal', action="public_journal") |
|
398 | 393 | |
|
399 | 394 | rmap.connect('public_journal_rss', '%s/public_journal/rss' % ADMIN_PREFIX, |
|
400 | 395 | controller='journal', action="public_journal_rss") |
|
401 | 396 | |
|
402 | 397 | rmap.connect('public_journal_rss_old', '%s/public_journal_rss' % ADMIN_PREFIX, |
|
403 | 398 | controller='journal', action="public_journal_rss") |
|
404 | 399 | |
|
405 | 400 | rmap.connect('public_journal_atom', |
|
406 | 401 | '%s/public_journal/atom' % ADMIN_PREFIX, controller='journal', |
|
407 | 402 | action="public_journal_atom") |
|
408 | 403 | |
|
409 | 404 | rmap.connect('public_journal_atom_old', |
|
410 | 405 | '%s/public_journal_atom' % ADMIN_PREFIX, controller='journal', |
|
411 | 406 | action="public_journal_atom") |
|
412 | 407 | |
|
413 | 408 | rmap.connect('toggle_following', '%s/toggle_following' % ADMIN_PREFIX, |
|
414 | 409 | controller='journal', action='toggle_following', |
|
415 | 410 | conditions=dict(method=["POST"])) |
|
416 | 411 | |
|
417 | 412 | #SEARCH |
|
418 | 413 | rmap.connect('search', '%s/search' % ADMIN_PREFIX, controller='search',) |
|
419 | 414 | rmap.connect('search_repo_admin', '%s/search/{repo_name:.*}' % ADMIN_PREFIX, |
|
420 | 415 | controller='search', |
|
421 | 416 | conditions=dict(function=check_repo)) |
|
422 | 417 | rmap.connect('search_repo', '/{repo_name:.*?}/search', |
|
423 | 418 | controller='search', |
|
424 | 419 | conditions=dict(function=check_repo), |
|
425 | 420 | ) |
|
426 | 421 | |
|
427 | 422 | #LOGIN/LOGOUT/REGISTER/SIGN IN |
|
428 | 423 | rmap.connect('login_home', '%s/login' % ADMIN_PREFIX, controller='login') |
|
429 | 424 | rmap.connect('logout_home', '%s/logout' % ADMIN_PREFIX, controller='login', |
|
430 | 425 | action='logout') |
|
431 | 426 | |
|
432 | 427 | rmap.connect('register', '%s/register' % ADMIN_PREFIX, controller='login', |
|
433 | 428 | action='register') |
|
434 | 429 | |
|
435 | 430 | rmap.connect('reset_password', '%s/password_reset' % ADMIN_PREFIX, |
|
436 | 431 | controller='login', action='password_reset') |
|
437 | 432 | |
|
438 | 433 | rmap.connect('reset_password_confirmation', |
|
439 | 434 | '%s/password_reset_confirmation' % ADMIN_PREFIX, |
|
440 | 435 | controller='login', action='password_reset_confirmation') |
|
441 | 436 | |
|
442 | 437 | #FEEDS |
|
443 | 438 | rmap.connect('rss_feed_home', '/{repo_name:.*?}/feed/rss', |
|
444 | 439 | controller='feed', action='rss', |
|
445 | 440 | conditions=dict(function=check_repo)) |
|
446 | 441 | |
|
447 | 442 | rmap.connect('atom_feed_home', '/{repo_name:.*?}/feed/atom', |
|
448 | 443 | controller='feed', action='atom', |
|
449 | 444 | conditions=dict(function=check_repo)) |
|
450 | 445 | |
|
451 | 446 | #========================================================================== |
|
452 | 447 | # REPOSITORY ROUTES |
|
453 | 448 | #========================================================================== |
|
454 | 449 | rmap.connect('summary_home', '/{repo_name:.*?}', |
|
455 | 450 | controller='summary', |
|
456 | 451 | conditions=dict(function=check_repo)) |
|
457 | 452 | |
|
458 | 453 | rmap.connect('repo_size', '/{repo_name:.*?}/repo_size', |
|
459 | 454 | controller='summary', action='repo_size', |
|
460 | 455 | conditions=dict(function=check_repo)) |
|
461 | 456 | |
|
462 | 457 | rmap.connect('repos_group_home', '/{group_name:.*}', |
|
463 | 458 | controller='admin/repos_groups', action="show_by_name", |
|
464 | 459 | conditions=dict(function=check_group)) |
|
465 | 460 | |
|
466 | 461 | rmap.connect('changeset_home', '/{repo_name:.*?}/changeset/{revision}', |
|
467 | 462 | controller='changeset', revision='tip', |
|
468 | 463 | conditions=dict(function=check_repo)) |
|
469 | 464 | |
|
470 | 465 | # no longer user, but kept for routes to work |
|
471 | 466 | rmap.connect("_edit_repo", "/{repo_name:.*?}/edit", |
|
472 | 467 | controller='admin/repos', action="edit", |
|
473 | 468 | conditions=dict(method=["GET"], function=check_repo) |
|
474 | 469 | ) |
|
475 | 470 | |
|
476 | 471 | rmap.connect("edit_repo", "/{repo_name:.*?}/settings", |
|
477 | 472 | controller='admin/repos', action="edit", |
|
478 | 473 | conditions=dict(method=["GET"], function=check_repo) |
|
479 | 474 | ) |
|
480 | 475 | |
|
481 | 476 | #still working url for backward compat. |
|
482 | 477 | rmap.connect('raw_changeset_home_depraced', |
|
483 | 478 | '/{repo_name:.*?}/raw-changeset/{revision}', |
|
484 | 479 | controller='changeset', action='changeset_raw', |
|
485 | 480 | revision='tip', conditions=dict(function=check_repo)) |
|
486 | 481 | |
|
487 | 482 | ## new URLs |
|
488 | 483 | rmap.connect('changeset_raw_home', |
|
489 | 484 | '/{repo_name:.*?}/changeset-diff/{revision}', |
|
490 | 485 | controller='changeset', action='changeset_raw', |
|
491 | 486 | revision='tip', conditions=dict(function=check_repo)) |
|
492 | 487 | |
|
493 | 488 | rmap.connect('changeset_patch_home', |
|
494 | 489 | '/{repo_name:.*?}/changeset-patch/{revision}', |
|
495 | 490 | controller='changeset', action='changeset_patch', |
|
496 | 491 | revision='tip', conditions=dict(function=check_repo)) |
|
497 | 492 | |
|
498 | 493 | rmap.connect('changeset_download_home', |
|
499 | 494 | '/{repo_name:.*?}/changeset-download/{revision}', |
|
500 | 495 | controller='changeset', action='changeset_download', |
|
501 | 496 | revision='tip', conditions=dict(function=check_repo)) |
|
502 | 497 | |
|
503 | 498 | rmap.connect('changeset_comment', |
|
504 | 499 | '/{repo_name:.*?}/changeset/{revision}/comment', |
|
505 | 500 | controller='changeset', revision='tip', action='comment', |
|
506 | 501 | conditions=dict(function=check_repo)) |
|
507 | 502 | |
|
508 | 503 | rmap.connect('changeset_comment_delete', |
|
509 | 504 | '/{repo_name:.*?}/changeset/comment/{comment_id}/delete', |
|
510 | 505 | controller='changeset', action='delete_comment', |
|
511 | 506 | conditions=dict(function=check_repo, method=["DELETE"])) |
|
512 | 507 | |
|
513 | 508 | rmap.connect('changeset_info', '/changeset_info/{repo_name:.*?}/{revision}', |
|
514 | 509 | controller='changeset', action='changeset_info') |
|
515 | 510 | |
|
516 | 511 | rmap.connect('compare_url', |
|
517 | 512 | '/{repo_name:.*?}/compare/{org_ref_type}@{org_ref:.*?}...{other_ref_type}@{other_ref:.*?}', |
|
518 | 513 | controller='compare', action='index', |
|
519 | 514 | conditions=dict(function=check_repo), |
|
520 | 515 | requirements=dict( |
|
521 | 516 | org_ref_type='(branch|book|tag|rev|__other_ref_type__)', |
|
522 | 517 | other_ref_type='(branch|book|tag|rev|__org_ref_type__)') |
|
523 | 518 | ) |
|
524 | 519 | |
|
525 | 520 | rmap.connect('pullrequest_home', |
|
526 | 521 | '/{repo_name:.*?}/pull-request/new', controller='pullrequests', |
|
527 | 522 | action='index', conditions=dict(function=check_repo, |
|
528 | 523 | method=["GET"])) |
|
529 | 524 | |
|
530 | 525 | rmap.connect('pullrequest', |
|
531 | 526 | '/{repo_name:.*?}/pull-request/new', controller='pullrequests', |
|
532 | 527 | action='create', conditions=dict(function=check_repo, |
|
533 | 528 | method=["POST"])) |
|
534 | 529 | |
|
535 | 530 | rmap.connect('pullrequest_show', |
|
536 | 531 | '/{repo_name:.*?}/pull-request/{pull_request_id}', |
|
537 | 532 | controller='pullrequests', |
|
538 | 533 | action='show', conditions=dict(function=check_repo, |
|
539 | 534 | method=["GET"])) |
|
540 | 535 | rmap.connect('pullrequest_update', |
|
541 | 536 | '/{repo_name:.*?}/pull-request/{pull_request_id}', |
|
542 | 537 | controller='pullrequests', |
|
543 | 538 | action='update', conditions=dict(function=check_repo, |
|
544 | 539 | method=["PUT"])) |
|
545 | 540 | rmap.connect('pullrequest_delete', |
|
546 | 541 | '/{repo_name:.*?}/pull-request/{pull_request_id}', |
|
547 | 542 | controller='pullrequests', |
|
548 | 543 | action='delete', conditions=dict(function=check_repo, |
|
549 | 544 | method=["DELETE"])) |
|
550 | 545 | |
|
551 | 546 | rmap.connect('pullrequest_show_all', |
|
552 | 547 | '/{repo_name:.*?}/pull-request', |
|
553 | 548 | controller='pullrequests', |
|
554 | 549 | action='show_all', conditions=dict(function=check_repo, |
|
555 | 550 | method=["GET"])) |
|
556 | 551 | |
|
557 | 552 | rmap.connect('pullrequest_comment', |
|
558 | 553 | '/{repo_name:.*?}/pull-request-comment/{pull_request_id}', |
|
559 | 554 | controller='pullrequests', |
|
560 | 555 | action='comment', conditions=dict(function=check_repo, |
|
561 | 556 | method=["POST"])) |
|
562 | 557 | |
|
563 | 558 | rmap.connect('pullrequest_comment_delete', |
|
564 | 559 | '/{repo_name:.*?}/pull-request-comment/{comment_id}/delete', |
|
565 | 560 | controller='pullrequests', action='delete_comment', |
|
566 | 561 | conditions=dict(function=check_repo, method=["DELETE"])) |
|
567 | 562 | |
|
568 | 563 | rmap.connect('summary_home_summary', '/{repo_name:.*?}/summary', |
|
569 | 564 | controller='summary', conditions=dict(function=check_repo)) |
|
570 | 565 | |
|
571 | 566 | rmap.connect('shortlog_home', '/{repo_name:.*?}/shortlog', |
|
572 | 567 | controller='shortlog', conditions=dict(function=check_repo)) |
|
573 | 568 | |
|
574 | 569 | rmap.connect('shortlog_file_home', '/{repo_name:.*?}/shortlog/{revision}/{f_path:.*}', |
|
575 | 570 | controller='shortlog', f_path=None, |
|
576 | 571 | conditions=dict(function=check_repo)) |
|
577 | 572 | |
|
578 | 573 | rmap.connect('branches_home', '/{repo_name:.*?}/branches', |
|
579 | 574 | controller='branches', conditions=dict(function=check_repo)) |
|
580 | 575 | |
|
581 | 576 | rmap.connect('tags_home', '/{repo_name:.*?}/tags', |
|
582 | 577 | controller='tags', conditions=dict(function=check_repo)) |
|
583 | 578 | |
|
584 | 579 | rmap.connect('bookmarks_home', '/{repo_name:.*?}/bookmarks', |
|
585 | 580 | controller='bookmarks', conditions=dict(function=check_repo)) |
|
586 | 581 | |
|
587 | 582 | rmap.connect('changelog_home', '/{repo_name:.*?}/changelog', |
|
588 | 583 | controller='changelog', conditions=dict(function=check_repo)) |
|
589 | 584 | |
|
590 | 585 | rmap.connect('changelog_details', '/{repo_name:.*?}/changelog_details/{cs}', |
|
591 | 586 | controller='changelog', action='changelog_details', |
|
592 | 587 | conditions=dict(function=check_repo)) |
|
593 | 588 | |
|
594 | 589 | rmap.connect('files_home', '/{repo_name:.*?}/files/{revision}/{f_path:.*}', |
|
595 | 590 | controller='files', revision='tip', f_path='', |
|
596 | 591 | conditions=dict(function=check_repo)) |
|
597 | 592 | |
|
598 | 593 | rmap.connect('files_home_nopath', '/{repo_name:.*?}/files/{revision}', |
|
599 | 594 | controller='files', revision='tip', f_path='', |
|
600 | 595 | conditions=dict(function=check_repo)) |
|
601 | 596 | |
|
602 | 597 | rmap.connect('files_history_home', |
|
603 | 598 | '/{repo_name:.*?}/history/{revision}/{f_path:.*}', |
|
604 | 599 | controller='files', action='history', revision='tip', f_path='', |
|
605 | 600 | conditions=dict(function=check_repo)) |
|
606 | 601 | |
|
607 | 602 | rmap.connect('files_diff_home', '/{repo_name:.*?}/diff/{f_path:.*}', |
|
608 | 603 | controller='files', action='diff', revision='tip', f_path='', |
|
609 | 604 | conditions=dict(function=check_repo)) |
|
610 | 605 | |
|
611 | 606 | rmap.connect('files_rawfile_home', |
|
612 | 607 | '/{repo_name:.*?}/rawfile/{revision}/{f_path:.*}', |
|
613 | 608 | controller='files', action='rawfile', revision='tip', |
|
614 | 609 | f_path='', conditions=dict(function=check_repo)) |
|
615 | 610 | |
|
616 | 611 | rmap.connect('files_raw_home', |
|
617 | 612 | '/{repo_name:.*?}/raw/{revision}/{f_path:.*}', |
|
618 | 613 | controller='files', action='raw', revision='tip', f_path='', |
|
619 | 614 | conditions=dict(function=check_repo)) |
|
620 | 615 | |
|
621 | 616 | rmap.connect('files_annotate_home', |
|
622 | 617 | '/{repo_name:.*?}/annotate/{revision}/{f_path:.*}', |
|
623 | 618 | controller='files', action='index', revision='tip', |
|
624 | 619 | f_path='', annotate=True, conditions=dict(function=check_repo)) |
|
625 | 620 | |
|
626 | 621 | rmap.connect('files_edit_home', |
|
627 | 622 | '/{repo_name:.*?}/edit/{revision}/{f_path:.*}', |
|
628 | 623 | controller='files', action='edit', revision='tip', |
|
629 | 624 | f_path='', conditions=dict(function=check_repo)) |
|
630 | 625 | |
|
631 | 626 | rmap.connect('files_add_home', |
|
632 | 627 | '/{repo_name:.*?}/add/{revision}/{f_path:.*}', |
|
633 | 628 | controller='files', action='add', revision='tip', |
|
634 | 629 | f_path='', conditions=dict(function=check_repo)) |
|
635 | 630 | |
|
636 | 631 | rmap.connect('files_archive_home', '/{repo_name:.*?}/archive/{fname}', |
|
637 | 632 | controller='files', action='archivefile', |
|
638 | 633 | conditions=dict(function=check_repo)) |
|
639 | 634 | |
|
640 | 635 | rmap.connect('files_nodelist_home', |
|
641 | 636 | '/{repo_name:.*?}/nodelist/{revision}/{f_path:.*}', |
|
642 | 637 | controller='files', action='nodelist', |
|
643 | 638 | conditions=dict(function=check_repo)) |
|
644 | 639 | |
|
645 | 640 | rmap.connect('repo_fork_create_home', '/{repo_name:.*?}/fork', |
|
646 | 641 | controller='forks', action='fork_create', |
|
647 | 642 | conditions=dict(function=check_repo, method=["POST"])) |
|
648 | 643 | |
|
649 | 644 | rmap.connect('repo_fork_home', '/{repo_name:.*?}/fork', |
|
650 | 645 | controller='forks', action='fork', |
|
651 | 646 | conditions=dict(function=check_repo)) |
|
652 | 647 | |
|
653 | 648 | rmap.connect('repo_forks_home', '/{repo_name:.*?}/forks', |
|
654 | 649 | controller='forks', action='forks', |
|
655 | 650 | conditions=dict(function=check_repo)) |
|
656 | 651 | |
|
657 | 652 | rmap.connect('repo_followers_home', '/{repo_name:.*?}/followers', |
|
658 | 653 | controller='followers', action='followers', |
|
659 | 654 | conditions=dict(function=check_repo)) |
|
660 | 655 | |
|
661 | 656 | return rmap |
@@ -1,340 +1,340 b'' | |||
|
1 | 1 | <%page args="parent" /> |
|
2 | 2 | <div class="box"> |
|
3 | 3 | <!-- box / title --> |
|
4 | 4 | <div class="title"> |
|
5 | 5 | <h5> |
|
6 | 6 | <input class="q_filter_box" id="q_filter" size="15" type="text" name="filter" value="${_('quick filter...')}"/> ${parent.breadcrumbs()} <span id="repo_count">0</span> ${_('repositories')} |
|
7 | 7 | </h5> |
|
8 | 8 | %if c.rhodecode_user.username != 'default': |
|
9 | 9 | <ul class="links"> |
|
10 | 10 | %if h.HasPermissionAny('hg.admin','hg.create.repository')() or h.HasReposGroupPermissionAny('group.write', 'group.admin')(c.group.group_name if c.group else None): |
|
11 | 11 | <li> |
|
12 | 12 | %if c.group: |
|
13 |
<span>${h.link_to(_('Add repository'),h.url(' |
|
|
13 | <span>${h.link_to(_('Add repository'),h.url('new_repo',parent_group=c.group.group_id))}</span> | |
|
14 | 14 | %if h.HasPermissionAny('hg.admin')() or h.HasReposGroupPermissionAny('group.admin')(c.group.group_name): |
|
15 | 15 | <span>${h.link_to(_(u'Add group'),h.url('new_repos_group', parent_group=c.group.group_id))}</span> |
|
16 | 16 | %endif |
|
17 | 17 | %else: |
|
18 |
<span>${h.link_to(_('Add repository'),h.url(' |
|
|
18 | <span>${h.link_to(_('Add repository'),h.url('new_repo'))}</span> | |
|
19 | 19 | %if h.HasPermissionAny('hg.admin')(): |
|
20 | 20 | <span>${h.link_to(_(u'Add group'),h.url('new_repos_group'))}</span> |
|
21 | 21 | %endif |
|
22 | 22 | %endif |
|
23 | 23 | </li> |
|
24 | 24 | %endif |
|
25 | 25 | %if c.group and h.HasReposGroupPermissionAny('group.admin')(c.group.group_name): |
|
26 | 26 | <li> |
|
27 | 27 | <span>${h.link_to(_('Edit group'),h.url('edit_repos_group',group_name=c.group.group_name), title=_('You have admin right to this group, and can edit it'))}</span> |
|
28 | 28 | </li> |
|
29 | 29 | %endif |
|
30 | 30 | </ul> |
|
31 | 31 | %endif |
|
32 | 32 | </div> |
|
33 | 33 | <!-- end box / title --> |
|
34 | 34 | <div class="table"> |
|
35 | 35 | % if c.groups: |
|
36 | 36 | <div id='groups_list_wrap' class="yui-skin-sam"> |
|
37 | 37 | <table id="groups_list"> |
|
38 | 38 | <thead> |
|
39 | 39 | <tr> |
|
40 | 40 | <th class="left"><a href="#">${_('Group name')}</a></th> |
|
41 | 41 | <th class="left"><a href="#">${_('Description')}</a></th> |
|
42 | 42 | ##<th class="left"><a href="#">${_('Number of repositories')}</a></th> |
|
43 | 43 | </tr> |
|
44 | 44 | </thead> |
|
45 | 45 | |
|
46 | 46 | ## REPO GROUPS |
|
47 | 47 | % for gr in c.groups: |
|
48 | 48 | <tr> |
|
49 | 49 | <td> |
|
50 | 50 | <div style="white-space: nowrap"> |
|
51 | 51 | <img class="icon" alt="${_('Repository group')}" src="${h.url('/images/icons/database_link.png')}"/> |
|
52 | 52 | ${h.link_to(gr.name,url('repos_group_home',group_name=gr.group_name))} |
|
53 | 53 | </div> |
|
54 | 54 | </td> |
|
55 | 55 | %if c.visual.stylify_metatags: |
|
56 | 56 | <td>${h.urlify_text(h.desc_stylize(gr.group_description))}</td> |
|
57 | 57 | %else: |
|
58 | 58 | <td>${gr.group_description}</td> |
|
59 | 59 | %endif |
|
60 | 60 | ## this is commented out since for multi nested repos can be HEAVY! |
|
61 | 61 | ## in number of executed queries during traversing uncomment at will |
|
62 | 62 | ##<td><b>${gr.repositories_recursive_count}</b></td> |
|
63 | 63 | </tr> |
|
64 | 64 | % endfor |
|
65 | 65 | </table> |
|
66 | 66 | </div> |
|
67 | 67 | <div id="group-user-paginator" style="padding: 0px 0px 0px 0px"></div> |
|
68 | 68 | <div style="height: 20px"></div> |
|
69 | 69 | % endif |
|
70 | 70 | <div id="welcome" style="display:none;text-align:center"> |
|
71 | 71 | <h1><a href="${h.url('home')}">${c.rhodecode_name} ${c.rhodecode_version}</a></h1> |
|
72 | 72 | </div> |
|
73 | 73 | <%cnt=0%> |
|
74 | 74 | <%namespace name="dt" file="/data_table/_dt_elements.html"/> |
|
75 | 75 | % if not c.visual.lightweight_dashboard: |
|
76 | 76 | ## old full detailed version |
|
77 | 77 | <div id='repos_list_wrap' class="yui-skin-sam"> |
|
78 | 78 | <table id="repos_list"> |
|
79 | 79 | <thead> |
|
80 | 80 | <tr> |
|
81 | 81 | <th class="left"></th> |
|
82 | 82 | <th class="left">${_('Name')}</th> |
|
83 | 83 | <th class="left">${_('Description')}</th> |
|
84 | 84 | <th class="left">${_('Last change')}</th> |
|
85 | 85 | <th class="left">${_('Tip')}</th> |
|
86 | 86 | <th class="left">${_('Owner')}</th> |
|
87 | 87 | <th class="left">${_('Atom')}</th> |
|
88 | 88 | </tr> |
|
89 | 89 | </thead> |
|
90 | 90 | <tbody> |
|
91 | 91 | %for cnt,repo in enumerate(c.repos_list): |
|
92 | 92 | <tr class="parity${(cnt+1)%2}"> |
|
93 | 93 | ##QUICK MENU |
|
94 | 94 | <td class="quick_repo_menu"> |
|
95 | 95 | ${dt.quick_menu(repo['name'])} |
|
96 | 96 | </td> |
|
97 | 97 | ##REPO NAME AND ICONS |
|
98 | 98 | <td class="reponame"> |
|
99 | 99 | ${dt.repo_name(repo['name'],repo['dbrepo']['repo_type'],repo['dbrepo']['private'],h.AttributeDict(repo['dbrepo_fork']),pageargs.get('short_repo_names'))} |
|
100 | 100 | </td> |
|
101 | 101 | ##DESCRIPTION |
|
102 | 102 | <td><span class="tooltip" title="${h.tooltip(repo['description'])}"> |
|
103 | 103 | %if c.visual.stylify_metatags: |
|
104 | 104 | ${h.urlify_text(h.desc_stylize(h.truncate(repo['description'],60)))}</span> |
|
105 | 105 | %else: |
|
106 | 106 | ${h.truncate(repo['description'],60)}</span> |
|
107 | 107 | %endif |
|
108 | 108 | </td> |
|
109 | 109 | ##LAST CHANGE DATE |
|
110 | 110 | <td> |
|
111 | 111 | ${dt.last_change(repo['last_change'])} |
|
112 | 112 | </td> |
|
113 | 113 | ##LAST REVISION |
|
114 | 114 | <td> |
|
115 | 115 | ${dt.revision(repo['name'],repo['rev'],repo['tip'],repo['author'],repo['last_msg'])} |
|
116 | 116 | </td> |
|
117 | 117 | ## |
|
118 | 118 | <td title="${repo['contact']}">${h.person(repo['contact'])}</td> |
|
119 | 119 | <td> |
|
120 | 120 | ${dt.atom(repo['name'])} |
|
121 | 121 | </td> |
|
122 | 122 | </tr> |
|
123 | 123 | %endfor |
|
124 | 124 | </tbody> |
|
125 | 125 | </table> |
|
126 | 126 | </div> |
|
127 | 127 | % else: |
|
128 | 128 | ## lightweight version |
|
129 | 129 | <div class="yui-skin-sam" id="repos_list_wrap"></div> |
|
130 | 130 | <div id="user-paginator" style="padding: 0px 0px 0px 0px"></div> |
|
131 | 131 | % endif |
|
132 | 132 | </div> |
|
133 | 133 | </div> |
|
134 | 134 | % if not c.visual.lightweight_dashboard: |
|
135 | 135 | <script> |
|
136 | 136 | YUD.get('repo_count').innerHTML = ${cnt+1 if cnt else 0}; |
|
137 | 137 | |
|
138 | 138 | // groups table sorting |
|
139 | 139 | var myColumnDefs = [ |
|
140 | 140 | {key:"name",label:"${_('Group name')}",sortable:true, |
|
141 | 141 | sortOptions: { sortFunction: groupNameSort }}, |
|
142 | 142 | {key:"desc",label:"${_('Description')}",sortable:true}, |
|
143 | 143 | ]; |
|
144 | 144 | |
|
145 | 145 | var myDataSource = new YAHOO.util.DataSource(YUD.get("groups_list")); |
|
146 | 146 | |
|
147 | 147 | myDataSource.responseType = YAHOO.util.DataSource.TYPE_HTMLTABLE; |
|
148 | 148 | myDataSource.responseSchema = { |
|
149 | 149 | fields: [ |
|
150 | 150 | {key:"name"}, |
|
151 | 151 | {key:"desc"}, |
|
152 | 152 | ] |
|
153 | 153 | }; |
|
154 | 154 | |
|
155 | 155 | var myDataTable = new YAHOO.widget.DataTable("groups_list_wrap", myColumnDefs, myDataSource,{ |
|
156 | 156 | sortedBy:{key:"name",dir:"asc"}, |
|
157 | 157 | paginator: new YAHOO.widget.Paginator({ |
|
158 | 158 | rowsPerPage: 50, |
|
159 | 159 | alwaysVisible: false, |
|
160 | 160 | template : "{PreviousPageLink} {FirstPageLink} {PageLinks} {LastPageLink} {NextPageLink}", |
|
161 | 161 | pageLinks: 5, |
|
162 | 162 | containerClass: 'pagination-wh', |
|
163 | 163 | currentPageClass: 'pager_curpage', |
|
164 | 164 | pageLinkClass: 'pager_link', |
|
165 | 165 | nextPageLinkLabel: '>', |
|
166 | 166 | previousPageLinkLabel: '<', |
|
167 | 167 | firstPageLinkLabel: '<<', |
|
168 | 168 | lastPageLinkLabel: '>>', |
|
169 | 169 | containers:['group-user-paginator'] |
|
170 | 170 | }), |
|
171 | 171 | MSG_SORTASC:"${_('Click to sort ascending')}", |
|
172 | 172 | MSG_SORTDESC:"${_('Click to sort descending')}" |
|
173 | 173 | }); |
|
174 | 174 | |
|
175 | 175 | // main table sorting |
|
176 | 176 | var myColumnDefs = [ |
|
177 | 177 | {key:"menu",label:"",sortable:false,className:"quick_repo_menu hidden"}, |
|
178 | 178 | {key:"name",label:"${_('Name')}",sortable:true, |
|
179 | 179 | sortOptions: { sortFunction: nameSort }}, |
|
180 | 180 | {key:"desc",label:"${_('Description')}",sortable:true}, |
|
181 | 181 | {key:"last_change",label:"${_('Last Change')}",sortable:true, |
|
182 | 182 | sortOptions: { sortFunction: ageSort }}, |
|
183 | 183 | {key:"tip",label:"${_('Tip')}",sortable:true, |
|
184 | 184 | sortOptions: { sortFunction: revisionSort }}, |
|
185 | 185 | {key:"owner",label:"${_('Owner')}",sortable:true}, |
|
186 | 186 | {key:"atom",label:"",sortable:false}, |
|
187 | 187 | ]; |
|
188 | 188 | |
|
189 | 189 | var myDataSource = new YAHOO.util.DataSource(YUD.get("repos_list")); |
|
190 | 190 | |
|
191 | 191 | myDataSource.responseType = YAHOO.util.DataSource.TYPE_HTMLTABLE; |
|
192 | 192 | |
|
193 | 193 | myDataSource.responseSchema = { |
|
194 | 194 | fields: [ |
|
195 | 195 | {key:"menu"}, |
|
196 | 196 | //{key:"raw_name"}, |
|
197 | 197 | {key:"name"}, |
|
198 | 198 | {key:"desc"}, |
|
199 | 199 | {key:"last_change"}, |
|
200 | 200 | {key:"tip"}, |
|
201 | 201 | {key:"owner"}, |
|
202 | 202 | {key:"atom"}, |
|
203 | 203 | ] |
|
204 | 204 | }; |
|
205 | 205 | |
|
206 | 206 | var myDataTable = new YAHOO.widget.DataTable("repos_list_wrap", myColumnDefs, myDataSource, |
|
207 | 207 | { |
|
208 | 208 | sortedBy:{key:"name",dir:"asc"}, |
|
209 | 209 | MSG_SORTASC:"${_('Click to sort ascending')}", |
|
210 | 210 | MSG_SORTDESC:"${_('Click to sort descending')}", |
|
211 | 211 | MSG_EMPTY:"${_('No records found.')}", |
|
212 | 212 | MSG_ERROR:"${_('Data error.')}", |
|
213 | 213 | MSG_LOADING:"${_('Loading...')}", |
|
214 | 214 | } |
|
215 | 215 | ); |
|
216 | 216 | myDataTable.subscribe('postRenderEvent',function(oArgs) { |
|
217 | 217 | tooltip_activate(); |
|
218 | 218 | quick_repo_menu(); |
|
219 | 219 | var func = function(node){ |
|
220 | 220 | return node.parentNode.parentNode.parentNode.parentNode; |
|
221 | 221 | } |
|
222 | 222 | q_filter('q_filter',YUQ('div.table tr td a.repo_name'),func); |
|
223 | 223 | }); |
|
224 | 224 | |
|
225 | 225 | </script> |
|
226 | 226 | % else: |
|
227 | 227 | <script> |
|
228 | 228 | var data = ${c.data|n}; |
|
229 | 229 | var myDataSource = new YAHOO.util.DataSource(data); |
|
230 | 230 | myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON; |
|
231 | 231 | |
|
232 | 232 | myDataSource.responseSchema = { |
|
233 | 233 | resultsList: "records", |
|
234 | 234 | fields: [ |
|
235 | 235 | {key:"menu"}, |
|
236 | 236 | {key:"raw_name"}, |
|
237 | 237 | {key:"name"}, |
|
238 | 238 | {key:"desc"}, |
|
239 | 239 | {key:"last_change"}, |
|
240 | 240 | {key:"last_changeset"}, |
|
241 | 241 | {key:"owner"}, |
|
242 | 242 | {key:"atom"}, |
|
243 | 243 | ] |
|
244 | 244 | }; |
|
245 | 245 | myDataSource.doBeforeCallback = function(req,raw,res,cb) { |
|
246 | 246 | // This is the filter function |
|
247 | 247 | var data = res.results || [], |
|
248 | 248 | filtered = [], |
|
249 | 249 | i,l; |
|
250 | 250 | |
|
251 | 251 | if (req) { |
|
252 | 252 | req = req.toLowerCase(); |
|
253 | 253 | for (i = 0; i<data.length; i++) { |
|
254 | 254 | var pos = data[i].raw_name.toLowerCase().indexOf(req) |
|
255 | 255 | if (pos != -1) { |
|
256 | 256 | filtered.push(data[i]); |
|
257 | 257 | } |
|
258 | 258 | } |
|
259 | 259 | res.results = filtered; |
|
260 | 260 | } |
|
261 | 261 | YUD.get('repo_count').innerHTML = res.results.length; |
|
262 | 262 | return res; |
|
263 | 263 | } |
|
264 | 264 | |
|
265 | 265 | // main table sorting |
|
266 | 266 | var myColumnDefs = [ |
|
267 | 267 | {key:"menu",label:"",sortable:false,className:"quick_repo_menu hidden"}, |
|
268 | 268 | {key:"name",label:"${_('Name')}",sortable:true, |
|
269 | 269 | sortOptions: { sortFunction: nameSort }}, |
|
270 | 270 | {key:"desc",label:"${_('Description')}",sortable:true}, |
|
271 | 271 | {key:"last_change",label:"${_('Last Change')}",sortable:true, |
|
272 | 272 | sortOptions: { sortFunction: ageSort }}, |
|
273 | 273 | {key:"last_changeset",label:"${_('Tip')}",sortable:true, |
|
274 | 274 | sortOptions: { sortFunction: revisionSort }}, |
|
275 | 275 | {key:"owner",label:"${_('Owner')}",sortable:true}, |
|
276 | 276 | {key:"atom",label:"",sortable:false}, |
|
277 | 277 | ]; |
|
278 | 278 | |
|
279 | 279 | var myDataTable = new YAHOO.widget.DataTable("repos_list_wrap", myColumnDefs, myDataSource,{ |
|
280 | 280 | sortedBy:{key:"name",dir:"asc"}, |
|
281 | 281 | paginator: new YAHOO.widget.Paginator({ |
|
282 | 282 | rowsPerPage: ${c.visual.lightweight_dashboard_items}, |
|
283 | 283 | alwaysVisible: false, |
|
284 | 284 | template : "{PreviousPageLink} {FirstPageLink} {PageLinks} {LastPageLink} {NextPageLink}", |
|
285 | 285 | pageLinks: 5, |
|
286 | 286 | containerClass: 'pagination-wh', |
|
287 | 287 | currentPageClass: 'pager_curpage', |
|
288 | 288 | pageLinkClass: 'pager_link', |
|
289 | 289 | nextPageLinkLabel: '>', |
|
290 | 290 | previousPageLinkLabel: '<', |
|
291 | 291 | firstPageLinkLabel: '<<', |
|
292 | 292 | lastPageLinkLabel: '>>', |
|
293 | 293 | containers:['user-paginator'] |
|
294 | 294 | }), |
|
295 | 295 | |
|
296 | 296 | MSG_SORTASC:"${_('Click to sort ascending')}", |
|
297 | 297 | MSG_SORTDESC:"${_('Click to sort descending')}", |
|
298 | 298 | MSG_EMPTY:"${_('No repositories found.')}", |
|
299 | 299 | MSG_ERROR:"${_('Data error.')}", |
|
300 | 300 | MSG_LOADING:"${_('Loading...')}", |
|
301 | 301 | } |
|
302 | 302 | ); |
|
303 | 303 | myDataTable.subscribe('postRenderEvent',function(oArgs) { |
|
304 | 304 | tooltip_activate(); |
|
305 | 305 | quick_repo_menu(); |
|
306 | 306 | }); |
|
307 | 307 | |
|
308 | 308 | var filterTimeout = null; |
|
309 | 309 | |
|
310 | 310 | updateFilter = function () { |
|
311 | 311 | // Reset timeout |
|
312 | 312 | filterTimeout = null; |
|
313 | 313 | |
|
314 | 314 | // Reset sort |
|
315 | 315 | var state = myDataTable.getState(); |
|
316 | 316 | state.sortedBy = {key:'name', dir:YAHOO.widget.DataTable.CLASS_ASC}; |
|
317 | 317 | |
|
318 | 318 | // Get filtered data |
|
319 | 319 | myDataSource.sendRequest(YUD.get('q_filter').value,{ |
|
320 | 320 | success : myDataTable.onDataReturnInitializeTable, |
|
321 | 321 | failure : myDataTable.onDataReturnInitializeTable, |
|
322 | 322 | scope : myDataTable, |
|
323 | 323 | argument: state |
|
324 | 324 | }); |
|
325 | 325 | |
|
326 | 326 | }; |
|
327 | 327 | YUE.on('q_filter','click',function(){ |
|
328 | 328 | if(!YUD.hasClass('q_filter', 'loaded')){ |
|
329 | 329 | YUD.get('q_filter').value = ''; |
|
330 | 330 | //TODO: load here full list later to do search within groups |
|
331 | 331 | YUD.addClass('q_filter', 'loaded'); |
|
332 | 332 | } |
|
333 | 333 | }); |
|
334 | 334 | |
|
335 | 335 | YUE.on('q_filter','keyup',function (e) { |
|
336 | 336 | clearTimeout(filterTimeout); |
|
337 | 337 | filterTimeout = setTimeout(updateFilter,600); |
|
338 | 338 | }); |
|
339 | 339 | </script> |
|
340 | 340 | % endif |
General Comments 0
You need to be logged in to leave comments.
Login now