Show More
@@ -266,8 +266,3 b' class FilesController(BaseController):' | |||||
266 |
|
266 | |||
267 | return hist_l |
|
267 | return hist_l | |
268 |
|
268 | |||
269 | # [ |
|
|||
270 | # ([("u1", "User1"), ("u2", "User2")], "Users"), |
|
|||
271 | # ([("g1", "Group1"), ("g2", "Group2")], "Groups") |
|
|||
272 | # ] |
|
|||
273 |
|
@@ -31,6 +31,8 b' from webhelpers.html.tags import _set_in' | |||||
31 | convert_boolean_attrs, NotGiven |
|
31 | convert_boolean_attrs, NotGiven | |
32 |
|
32 | |||
33 | def _reset(name, value=None, id=NotGiven, type="reset", **attrs): |
|
33 | def _reset(name, value=None, id=NotGiven, type="reset", **attrs): | |
|
34 | """Reset button | |||
|
35 | """ | |||
34 | _set_input_attrs(attrs, type, name, value) |
|
36 | _set_input_attrs(attrs, type, name, value) | |
35 | _set_id_attr(attrs, id, name) |
|
37 | _set_id_attr(attrs, id, name) | |
36 | convert_boolean_attrs(attrs, ["disabled"]) |
|
38 | convert_boolean_attrs(attrs, ["disabled"]) | |
@@ -55,24 +57,13 b' def get_token():' | |||||
55 | session.save() |
|
57 | session.save() | |
56 | return session[token_key] |
|
58 | return session[token_key] | |
57 |
|
59 | |||
58 |
|
||||
59 | #Custom helpers here :) |
|
|||
60 | class _Link(object): |
|
|||
61 | ''' |
|
|||
62 | Make a url based on label and url with help of url_for |
|
|||
63 | :param label:name of link if not defined url is used |
|
|||
64 | :param url: the url for link |
|
|||
65 | ''' |
|
|||
66 |
|
||||
67 | def __call__(self, label='', *url_, **urlargs): |
|
|||
68 | if label is None or '': |
|
|||
69 | label = url |
|
|||
70 | link_fn = link_to(label, url(*url_, **urlargs)) |
|
|||
71 | return link_fn |
|
|||
72 |
|
||||
73 | link = _Link() |
|
|||
74 |
|
||||
75 | class _GetError(object): |
|
60 | class _GetError(object): | |
|
61 | """Get error from form_errors, and represent it as span wrapped error | |||
|
62 | message | |||
|
63 | ||||
|
64 | :param field_name: field to fetch errors for | |||
|
65 | :param form_errors: form errors dict | |||
|
66 | """ | |||
76 |
|
67 | |||
77 | def __call__(self, field_name, form_errors): |
|
68 | def __call__(self, field_name, form_errors): | |
78 | tmpl = """<span class="error_msg">%s</span>""" |
|
69 | tmpl = """<span class="error_msg">%s</span>""" | |
@@ -82,10 +73,10 b' class _GetError(object):' | |||||
82 | get_error = _GetError() |
|
73 | get_error = _GetError() | |
83 |
|
74 | |||
84 | def recursive_replace(str, replace=' '): |
|
75 | def recursive_replace(str, replace=' '): | |
85 | """ |
|
76 | """Recursive replace of given sign to just one instance | |
86 | Recursive replace of given sign to just one instance |
|
77 | ||
87 | :param str: given string |
|
78 | :param str: given string | |
88 | :param replace:char to find and replace multiple instances |
|
79 | :param replace: char to find and replace multiple instances | |
89 |
|
80 | |||
90 | Examples:: |
|
81 | Examples:: | |
91 | >>> recursive_replace("Mighty---Mighty-Bo--sstones",'-') |
|
82 | >>> recursive_replace("Mighty---Mighty-Bo--sstones",'-') | |
@@ -245,6 +236,7 b' class _FilesBreadCrumbs(object):' | |||||
245 | return literal('/'.join(url_l)) |
|
236 | return literal('/'.join(url_l)) | |
246 |
|
237 | |||
247 | files_breadcrumbs = _FilesBreadCrumbs() |
|
238 | files_breadcrumbs = _FilesBreadCrumbs() | |
|
239 | ||||
248 | class CodeHtmlFormatter(HtmlFormatter): |
|
240 | class CodeHtmlFormatter(HtmlFormatter): | |
249 |
|
241 | |||
250 | def wrap(self, source, outfile): |
|
242 | def wrap(self, source, outfile): | |
@@ -256,16 +248,17 b' class CodeHtmlFormatter(HtmlFormatter):' | |||||
256 | t = '<div id="#S-%s">%s</div>' % (cnt + 1, t) |
|
248 | t = '<div id="#S-%s">%s</div>' % (cnt + 1, t) | |
257 | yield i, t |
|
249 | yield i, t | |
258 | def pygmentize(filenode, **kwargs): |
|
250 | def pygmentize(filenode, **kwargs): | |
259 | """ |
|
251 | """pygmentize function using pygments | |
260 | pygmentize function using pygments |
|
252 | ||
261 | :param filenode: |
|
253 | :param filenode: | |
262 | """ |
|
254 | """ | |
|
255 | ||||
263 | return literal(code_highlight(filenode.content, |
|
256 | return literal(code_highlight(filenode.content, | |
264 | filenode.lexer, CodeHtmlFormatter(**kwargs))) |
|
257 | filenode.lexer, CodeHtmlFormatter(**kwargs))) | |
265 |
|
258 | |||
266 | def pygmentize_annotation(filenode, **kwargs): |
|
259 | def pygmentize_annotation(filenode, **kwargs): | |
267 | """ |
|
260 | """pygmentize function for annotation | |
268 | pygmentize function for annotation |
|
261 | ||
269 | :param filenode: |
|
262 | :param filenode: | |
270 | """ |
|
263 | """ | |
271 |
|
264 | |||
@@ -322,6 +315,7 b' def repo_name_slug(value):' | |||||
322 | This function is called on each creation/modification |
|
315 | This function is called on each creation/modification | |
323 | of repository to prevent bad names in repo |
|
316 | of repository to prevent bad names in repo | |
324 | """ |
|
317 | """ | |
|
318 | ||||
325 | slug = remove_formatting(value) |
|
319 | slug = remove_formatting(value) | |
326 | slug = strip_tags(slug) |
|
320 | slug = strip_tags(slug) | |
327 |
|
321 | |||
@@ -355,8 +349,6 b' flash = _Flash()' | |||||
355 | from mercurial import util |
|
349 | from mercurial import util | |
356 | from mercurial.templatefilters import person as _person |
|
350 | from mercurial.templatefilters import person as _person | |
357 |
|
351 | |||
358 |
|
||||
359 |
|
||||
360 | def _age(curdate): |
|
352 | def _age(curdate): | |
361 | """turns a datetime into an age string.""" |
|
353 | """turns a datetime into an age string.""" | |
362 |
|
354 | |||
@@ -392,9 +384,9 b' short_id = lambda x: x[:12]' | |||||
392 |
|
384 | |||
393 |
|
385 | |||
394 | def bool2icon(value): |
|
386 | def bool2icon(value): | |
395 | """ |
|
387 | """Returns True/False values represented as small html image of true/false | |
396 | Returns True/False values represented as small html image of true/false |
|
|||
397 | icons |
|
388 | icons | |
|
389 | ||||
398 | :param value: bool value |
|
390 | :param value: bool value | |
399 | """ |
|
391 | """ | |
400 |
|
392 | |||
@@ -408,12 +400,12 b' def bool2icon(value):' | |||||
408 |
|
400 | |||
409 |
|
401 | |||
410 | def action_parser(user_log): |
|
402 | def action_parser(user_log): | |
411 | """ |
|
403 | """This helper will map the specified string action into translated | |
412 | This helper will map the specified string action into translated |
|
|||
413 | fancy names with icons and links |
|
404 | fancy names with icons and links | |
414 |
|
405 | |||
415 | @param action: |
|
406 | :param user_log: user log instance | |
416 | """ |
|
407 | """ | |
|
408 | ||||
417 | action = user_log.action |
|
409 | action = user_log.action | |
418 | action_params = ' ' |
|
410 | action_params = ' ' | |
419 |
|
411 | |||
@@ -424,12 +416,20 b' def action_parser(user_log):' | |||||
424 |
|
416 | |||
425 | def get_cs_links(): |
|
417 | def get_cs_links(): | |
426 | if action == 'push': |
|
418 | if action == 'push': | |
427 | revs_limit = 5 |
|
419 | revs_limit = 5 #display this amount always | |
|
420 | revs_top_limit = 50 #show upto this amount of changesets hidden | |||
428 | revs = action_params.split(',') |
|
421 | revs = action_params.split(',') | |
429 | cs_links = " " + ', '.join ([link(rev, |
|
422 | repo_name = user_log.repository.repo_name | |
|
423 | from rhodecode.model.scm import ScmModel | |||
|
424 | ||||
|
425 | message = lambda rev: get_changeset_safe(ScmModel().get(repo_name), | |||
|
426 | rev).message | |||
|
427 | ||||
|
428 | cs_links = " " + ', '.join ([link_to(rev, | |||
430 | url('changeset_home', |
|
429 | url('changeset_home', | |
431 |
repo_name= |
|
430 | repo_name=repo_name, | |
432 |
revision=rev)) |
|
431 | revision=rev), tooltip_title=message(rev), | |
|
432 | class_='tooltip') for rev in revs[:revs_limit] ]) | |||
433 | if len(revs) > revs_limit: |
|
433 | if len(revs) > revs_limit: | |
434 | uniq_id = revs[0] |
|
434 | uniq_id = revs[0] | |
435 | html_tmpl = ('<span> %s ' |
|
435 | html_tmpl = ('<span> %s ' | |
@@ -440,10 +440,11 b' def action_parser(user_log):' | |||||
440 | _('revisions')) |
|
440 | _('revisions')) | |
441 |
|
441 | |||
442 | html_tmpl = '<span id="%s" style="display:none"> %s </span>' |
|
442 | html_tmpl = '<span id="%s" style="display:none"> %s </span>' | |
443 | cs_links += html_tmpl % (uniq_id, ', '.join([link(rev, |
|
443 | cs_links += html_tmpl % (uniq_id, ', '.join([link_to(rev, | |
444 | url('changeset_home', |
|
444 | url('changeset_home', | |
445 |
repo_name= |
|
445 | repo_name=repo_name, revision=rev), | |
446 | revision=rev)) for rev in revs[revs_limit:] ])) |
|
446 | tooltip_title=message(rev), class_='tooltip') | |
|
447 | for rev in revs[revs_limit:revs_top_limit]])) | |||
447 |
|
448 | |||
448 | return cs_links |
|
449 | return cs_links | |
449 | return '' |
|
450 | return '' | |
@@ -491,7 +492,7 b' def action_parser_icon(user_log):' | |||||
491 | 'user_forked_repo':'arrow_divide.png', |
|
492 | 'user_forked_repo':'arrow_divide.png', | |
492 | 'user_updated_repo':'database_edit.png', |
|
493 | 'user_updated_repo':'database_edit.png', | |
493 | 'admin_deleted_repo':'database_delete.png', |
|
494 | 'admin_deleted_repo':'database_delete.png', | |
494 |
'admin_created_repo':'database_ |
|
495 | 'admin_created_repo':'database_add.png', | |
495 | 'admin_forked_repo':'arrow_divide.png', |
|
496 | 'admin_forked_repo':'arrow_divide.png', | |
496 | 'admin_updated_repo':'database_edit.png', |
|
497 | 'admin_updated_repo':'database_edit.png', | |
497 | 'push':'script_add.png', |
|
498 | 'push':'script_add.png', |
General Comments 0
You need to be logged in to leave comments.
Login now