##// END OF EJS Templates
made global funcion to clean repo names, and remove all special chars from the name....
marcink -
r260:6ada8c22 default
parent child Browse files
Show More
@@ -8,7 +8,7 b' from pylons.i18n.translation import _'
8 from pylons_app.lib.base import BaseController, render
8 from pylons_app.lib.base import BaseController, render
9 from pylons.middleware import media_path
9 from pylons.middleware import media_path
10 from pylons_app.lib.utils import check_repo
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 log = logging.getLogger(__name__)
12 log = logging.getLogger(__name__)
13
13
14 class ErrorController(BaseController):
14 class ErrorController(BaseController):
@@ -39,7 +39,7 b' class ErrorController(BaseController):'
39 if resp.status_int == 404:
39 if resp.status_int == 404:
40 org_e = request.environ.get('pylons.original_request').environ
40 org_e = request.environ.get('pylons.original_request').environ
41 c.repo_name = repo_name = org_e['PATH_INFO'].split('/')[1]
41 c.repo_name = repo_name = org_e['PATH_INFO'].split('/')[1]
42 c.repo_name_cleaned = clean_repo(c.repo_name)
42 c.repo_name_cleaned = h.repo_name_slug(c.repo_name)
43 if check_repo(repo_name, g.base_path):
43 if check_repo(repo_name, g.base_path):
44 return render('/errors/error_404.html')
44 return render('/errors/error_404.html')
45
45
@@ -26,14 +26,6 b' simple filters for hg apps html template'
26
26
27 from mercurial import util
27 from mercurial import util
28 from mercurial.templatefilters import age as _age, person as _person
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 age = lambda x:_age(x)
30 age = lambda x:_age(x)
39 capitalize = lambda x: x.capitalize()
31 capitalize = lambda x: x.capitalize()
@@ -21,7 +21,7 b' from webhelpers.pylonslib import Flash a'
21 from webhelpers.pylonslib.secure_form import secure_form
21 from webhelpers.pylonslib.secure_form import secure_form
22 from webhelpers.text import chop_at, collapse, convert_accented_entities, \
22 from webhelpers.text import chop_at, collapse, convert_accented_entities, \
23 convert_misc_entities, lchop, plural, rchop, remove_formatting, \
23 convert_misc_entities, lchop, plural, rchop, remove_formatting, \
24 replace_whitespace, urlify
24 replace_whitespace, urlify, truncate
25
25
26
26
27 #Custom helper here :)
27 #Custom helper here :)
@@ -92,6 +92,35 b' def pygmentize_annotation(filenode, **kw'
92
92
93 return literal(annotate_highlight(filenode, url_func, **kwargs))
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 files_breadcrumbs = _FilesBreadCrumbs()
124 files_breadcrumbs = _FilesBreadCrumbs()
96 link = _Link()
125 link = _Link()
97 flash = _Flash()
126 flash = _Flash()
@@ -151,15 +151,4 b' def is_current(selected):'
151 </span>
151 </span>
152 %endif
152 %endif
153 %endif
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 </%def> No newline at end of file
154 </%def>
@@ -37,7 +37,7 b' from pylons_app.lib import filters'
37 %for cnt,repo in enumerate(c.repos_list):
37 %for cnt,repo in enumerate(c.repos_list):
38 <tr class="parity${cnt%2}">
38 <tr class="parity${cnt%2}">
39 <td>${h.link(repo['name'],h.url('summary_home',repo_name=repo['name']))}</td>
39 <td>${h.link(repo['name'],h.url('summary_home',repo_name=repo['name']))}</td>
40 <td title="${repo['description']}">${self.message_slug(repo['description'])}</td>
40 <td title="${repo['description']}">${h.truncate(repo['description'],60)}</td>
41 <td>${repo['last_change']|n,filters.age}</td>
41 <td>${repo['last_change']|n,filters.age}</td>
42 <td>${h.link_to('r%s:%s' % (repo['rev'],repo['tip']),h.url('changeset_home',repo_name=repo['name'],revision=repo['tip']))}</td>
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 <td title="${repo['contact']}">${repo['contact']|n,filters.person}</td>
43 <td title="${repo['contact']}">${repo['contact']|n,filters.person}</td>
@@ -9,7 +9,7 b' from pylons_app.lib import filters'
9 <td title="${cs.author}">${cs.author|n,filters.person}</td>
9 <td title="${cs.author}">${cs.author|n,filters.person}</td>
10 <td>r${cs.revision}</td>
10 <td>r${cs.revision}</td>
11 <td>
11 <td>
12 ${h.link_to(self.message_slug(cs.message),
12 ${h.link_to(h.truncate(cs.message,60),
13 h.url('changeset_home',repo_name=c.repo_name,revision=cs._short),
13 h.url('changeset_home',repo_name=c.repo_name,revision=cs._short),
14 title=cs.message)}
14 title=cs.message)}
15 </td>
15 </td>
@@ -64,22 +64,13 b' E.onDOMReady(function(e){'
64
64
65 <h2>${h.link_to(_('Changes'),h.url('changelog_home',repo_name=c.repo_name))}</h2>
65 <h2>${h.link_to(_('Changes'),h.url('changelog_home',repo_name=c.repo_name))}</h2>
66 <table>
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 %for cnt,cs in enumerate(c.repo_changesets):
67 %for cnt,cs in enumerate(c.repo_changesets):
77 <tr class="parity${cnt%2}">
68 <tr class="parity${cnt%2}">
78 <td>${cs._ctx.date()|n,filters.age}</td>
69 <td>${cs._ctx.date()|n,filters.age}</td>
79 <td>${cs.author|n,filters.person}</td>
70 <td>${cs.author|n,filters.person}</td>
80 <td>r${cs.revision}</td>
71 <td>r${cs.revision}</td>
81 <td>
72 <td>
82 ${h.link_to(message_slug(cs.message),
73 ${h.link_to(truncate(cs.message,60),
83 h.url('changeset_home',repo_name=c.repo_name,revision=cs._short),
74 h.url('changeset_home',repo_name=c.repo_name,revision=cs._short),
84 title=cs.message)}
75 title=cs.message)}
85 </td>
76 </td>
General Comments 0
You need to be logged in to leave comments. Login now