Show More
@@ -8,7 +8,7 b' from pylons.i18n.translation import _' | |||
|
8 | 8 | from pylons_app.lib.base import BaseController, render |
|
9 | 9 | from pylons.middleware import media_path |
|
10 | 10 | from pylons_app.lib.utils import check_repo |
|
11 | from pylons_app.lib.filters import clean_repo | |
|
11 | import pylons_app.lib.helpers as h | |
|
12 | 12 | log = logging.getLogger(__name__) |
|
13 | 13 | |
|
14 | 14 | class ErrorController(BaseController): |
@@ -39,7 +39,7 b' class ErrorController(BaseController):' | |||
|
39 | 39 | if resp.status_int == 404: |
|
40 | 40 | org_e = request.environ.get('pylons.original_request').environ |
|
41 | 41 | c.repo_name = repo_name = org_e['PATH_INFO'].split('/')[1] |
|
42 |
c.repo_name_cleaned = |
|
|
42 | c.repo_name_cleaned = h.repo_name_slug(c.repo_name) | |
|
43 | 43 | if check_repo(repo_name, g.base_path): |
|
44 | 44 | return render('/errors/error_404.html') |
|
45 | 45 |
@@ -26,14 +26,6 b' simple filters for hg apps html template' | |||
|
26 | 26 | |
|
27 | 27 | from mercurial import util |
|
28 | 28 | from mercurial.templatefilters import age as _age, person as _person |
|
29 | from string import punctuation | |
|
30 | ||
|
31 | def clean_repo(repo_name): | |
|
32 | for x in punctuation: | |
|
33 | if x != '_': | |
|
34 | repo_name = repo_name.replace(x, '') | |
|
35 | repo_name = repo_name.lower().strip() | |
|
36 | return repo_name.replace(' ', '_') | |
|
37 | 29 | |
|
38 | 30 | age = lambda x:_age(x) |
|
39 | 31 | capitalize = lambda x: x.capitalize() |
@@ -21,7 +21,7 b' from webhelpers.pylonslib import Flash a' | |||
|
21 | 21 | from webhelpers.pylonslib.secure_form import secure_form |
|
22 | 22 | from webhelpers.text import chop_at, collapse, convert_accented_entities, \ |
|
23 | 23 | convert_misc_entities, lchop, plural, rchop, remove_formatting, \ |
|
24 | replace_whitespace, urlify | |
|
24 | replace_whitespace, urlify, truncate | |
|
25 | 25 | |
|
26 | 26 | |
|
27 | 27 | #Custom helper here :) |
@@ -92,6 +92,35 b' def pygmentize_annotation(filenode, **kw' | |||
|
92 | 92 | |
|
93 | 93 | return literal(annotate_highlight(filenode, url_func, **kwargs)) |
|
94 | 94 | |
|
95 | def recursive_replace(str, replace=' '): | |
|
96 | """ | |
|
97 | Recursive replace of given sign to just one instance | |
|
98 | @param str: given string | |
|
99 | @param replace:char to find and replace multiple instances | |
|
100 | ||
|
101 | Examples:: | |
|
102 | >>> recursive_replace("Mighty---Mighty-Bo--sstones",'-') | |
|
103 | 'Mighty-Mighty-Bo-sstones' | |
|
104 | """ | |
|
105 | ||
|
106 | if str.find(replace * 2) == -1: | |
|
107 | return str | |
|
108 | else: | |
|
109 | str = str.replace(replace * 2, replace) | |
|
110 | return recursive_replace(str, replace) | |
|
111 | ||
|
112 | def repo_name_slug(value): | |
|
113 | """ | |
|
114 | Return slug of name of repository | |
|
115 | """ | |
|
116 | slug = urlify(value) | |
|
117 | for c in """=[]\;',/~!@#$%^&*()+{}|:""": | |
|
118 | slug = slug.replace(c, '-') | |
|
119 | print slug | |
|
120 | slug = recursive_replace(slug, '-') | |
|
121 | print slug | |
|
122 | return slug | |
|
123 | ||
|
95 | 124 | files_breadcrumbs = _FilesBreadCrumbs() |
|
96 | 125 | link = _Link() |
|
97 | 126 | flash = _Flash() |
@@ -151,15 +151,4 b' def is_current(selected):' | |||
|
151 | 151 | </span> |
|
152 | 152 | %endif |
|
153 | 153 | %endif |
|
154 | </%def> | |
|
155 | ||
|
156 | <!-- SHORTER LONGER STRINGS --> | |
|
157 | <%def name="message_slug(msg)"> | |
|
158 | <% | |
|
159 | limit = 60 | |
|
160 | if len(msg) > limit: | |
|
161 | return msg[:limit]+'...' | |
|
162 | else: | |
|
163 | return msg | |
|
164 | %> | |
|
165 | 154 | </%def> No newline at end of file |
@@ -37,7 +37,7 b' from pylons_app.lib import filters' | |||
|
37 | 37 | %for cnt,repo in enumerate(c.repos_list): |
|
38 | 38 | <tr class="parity${cnt%2}"> |
|
39 | 39 | <td>${h.link(repo['name'],h.url('summary_home',repo_name=repo['name']))}</td> |
|
40 |
<td title="${repo['description']}">${ |
|
|
40 | <td title="${repo['description']}">${h.truncate(repo['description'],60)}</td> | |
|
41 | 41 | <td>${repo['last_change']|n,filters.age}</td> |
|
42 | 42 | <td>${h.link_to('r%s:%s' % (repo['rev'],repo['tip']),h.url('changeset_home',repo_name=repo['name'],revision=repo['tip']))}</td> |
|
43 | 43 | <td title="${repo['contact']}">${repo['contact']|n,filters.person}</td> |
@@ -9,7 +9,7 b' from pylons_app.lib import filters' | |||
|
9 | 9 | <td title="${cs.author}">${cs.author|n,filters.person}</td> |
|
10 | 10 | <td>r${cs.revision}</td> |
|
11 | 11 | <td> |
|
12 |
${h.link_to( |
|
|
12 | ${h.link_to(h.truncate(cs.message,60), | |
|
13 | 13 | h.url('changeset_home',repo_name=c.repo_name,revision=cs._short), |
|
14 | 14 | title=cs.message)} |
|
15 | 15 | </td> |
@@ -64,22 +64,13 b' E.onDOMReady(function(e){' | |||
|
64 | 64 | |
|
65 | 65 | <h2>${h.link_to(_('Changes'),h.url('changelog_home',repo_name=c.repo_name))}</h2> |
|
66 | 66 | <table> |
|
67 | <%def name="message_slug(msg)"> | |
|
68 | <% | |
|
69 | limit = 60 | |
|
70 | if len(msg) > limit: | |
|
71 | return msg[:limit]+'...' | |
|
72 | else: | |
|
73 | return msg | |
|
74 | %> | |
|
75 | </%def> | |
|
76 | 67 | %for cnt,cs in enumerate(c.repo_changesets): |
|
77 | 68 | <tr class="parity${cnt%2}"> |
|
78 | 69 | <td>${cs._ctx.date()|n,filters.age}</td> |
|
79 | 70 | <td>${cs.author|n,filters.person}</td> |
|
80 | 71 | <td>r${cs.revision}</td> |
|
81 | 72 | <td> |
|
82 |
${h.link_to( |
|
|
73 | ${h.link_to(truncate(cs.message,60), | |
|
83 | 74 | h.url('changeset_home',repo_name=c.repo_name,revision=cs._short), |
|
84 | 75 | title=cs.message)} |
|
85 | 76 | </td> |
General Comments 0
You need to be logged in to leave comments.
Login now