changeset 1087:51076a2a2b64 beta

fixed unicode problems with file paths. added feed arg to journal action mapper
author Marcin Kuzminski <marcin@python-works.com>
date Sat, 26 Feb 2011 16:04:38 +0100
parents b25a9f13fda1
children fee472613dfa
files rhodecode/lib/helpers.py rhodecode/templates/changeset/changeset.html rhodecode/templates/changeset/changeset_range.html rhodecode/templates/journal/public_journal.html rhodecode/tests/test_hg_operations.py
diffstat 5 files changed, 43 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/rhodecode/lib/helpers.py	Fri Feb 25 19:14:12 2011 +0100
+++ b/rhodecode/lib/helpers.py	Sat Feb 26 16:04:38 2011 +0100
@@ -422,11 +422,12 @@
     return value
 
 
-def action_parser(user_log):
-    """This helper will map the specified string action into translated
+def action_parser(user_log, feed=False):
+    """This helper will action_map the specified string action into translated
     fancy names with icons and links
     
     :param user_log: user log instance
+    :param feed: use output for feeds (no html and fancy icons)
     """
 
     action = user_log.action
@@ -470,11 +471,16 @@
             html_tmpl = ('<span> %s '
             '<a class="show_more" id="_%s" href="#more">%s</a> '
             '%s</span>')
-            cs_links += html_tmpl % (_('and'), uniq_id, _('%s more') \
+            if not feed:
+                cs_links += html_tmpl % (_('and'), uniq_id, _('%s more') \
                                         % (len(revs) - revs_limit),
                                         _('revisions'))
 
-            html_tmpl = '<span id="%s" style="display:none"> %s </span>'
+            if not feed:
+                html_tmpl = '<span id="%s" style="display:none"> %s </span>'
+            else:
+                html_tmpl = '<span id="%s"> %s </span>'
+
             cs_links += html_tmpl % (uniq_id, ', '.join([link_to(rev,
                 url('changeset_home',
                 repo_name=repo_name, revision=rev),
@@ -489,7 +495,7 @@
         return _('fork name ') + str(link_to(action_params, url('summary_home',
                                           repo_name=repo_name,)))
 
-    map = {'user_deleted_repo':(_('[deleted] repository'), None),
+    action_map = {'user_deleted_repo':(_('[deleted] repository'), None),
            'user_created_repo':(_('[created] repository'), None),
            'user_forked_repo':(_('[forked] repository'), get_fork_name),
            'user_updated_repo':(_('[updated] repository'), None),
@@ -503,8 +509,11 @@
            'stopped_following_repo':(_('[stopped following] repository'), None),
             }
 
-    action_str = map.get(action, action)
-    action = action_str[0].replace('[', '<span class="journal_highlight">')\
+    action_str = action_map.get(action, action)
+    if feed:
+        action = action_str[0].replace('[', '').replace(']', '')
+    else:
+        action = action_str[0].replace('[', '<span class="journal_highlight">')\
                    .replace(']', '</span>')
     action_params_func = lambda :""
 
@@ -588,6 +597,6 @@
         suf = ''
         if len(nodes) > 30:
             suf = '<br/>' + _(' and %s more') % (len(nodes) - 30)
-        return literal(pref + '<br/> '.join([x.path for x in nodes[:30]]) + suf)
+        return literal(pref + '<br/> '.join([x.path.decode('utf-8') for x in nodes[:30]]) + suf)
     else:
         return ': ' + _('No Files')
--- a/rhodecode/templates/changeset/changeset.html	Fri Feb 25 19:14:12 2011 +0100
+++ b/rhodecode/templates/changeset/changeset.html	Sat Feb 26 16:04:38 2011 +0100
@@ -81,7 +81,7 @@
 	        <span style="font-size:1.1em;font-weight: bold">${_('Files affected')}</span>
 	        <div class="cs_files">
 	                %for change,filenode,diff,cs1,cs2 in c.changes:
-	                    <div class="cs_${change}">${h.link_to(filenode.path,h.url.current(anchor=h.repo_name_slug('C%s' % filenode.path)))}</div>
+	                    <div class="cs_${change}">${h.link_to(filenode.path.decode('utf-8'),h.url.current(anchor=h.repo_name_slug('C%s' % filenode.path.decode('utf-8'))))}</div>
 	                %endfor
 	        </div>         
 	    </div>
@@ -92,19 +92,19 @@
 		%if change !='removed':
 		<div style="clear:both;height:10px"></div>
 		<div class="diffblock">
-			<div id="${h.repo_name_slug('C%s' % filenode.path)}" class="code-header">
+			<div id="${h.repo_name_slug('C%s' % filenode.path.decode('utf-8'))}" class="code-header">
 				<div class="changeset_header">
 					<span class="changeset_file">
-						${h.link_to_if(change!='removed',filenode.path,h.url('files_home',repo_name=c.repo_name,
-						revision=filenode.changeset.raw_id,f_path=filenode.path))}
+						${h.link_to_if(change!='removed',filenode.path.decode('utf-8'),h.url('files_home',repo_name=c.repo_name,
+						revision=filenode.changeset.raw_id,f_path=filenode.path.decode('utf-8')))}
 					</span>
 					%if 1:
 					&raquo; <span>${h.link_to(_('diff'),
-					h.url('files_diff_home',repo_name=c.repo_name,f_path=filenode.path,diff2=cs2,diff1=cs1,diff='diff'))}</span>
+					h.url('files_diff_home',repo_name=c.repo_name,f_path=filenode.path.decode('utf-8'),diff2=cs2,diff1=cs1,diff='diff'))}</span>
 					&raquo; <span>${h.link_to(_('raw diff'),
-					h.url('files_diff_home',repo_name=c.repo_name,f_path=filenode.path,diff2=cs2,diff1=cs1,diff='raw'))}</span>
+					h.url('files_diff_home',repo_name=c.repo_name,f_path=filenode.path.decode('utf-8'),diff2=cs2,diff1=cs1,diff='raw'))}</span>
 					&raquo; <span>${h.link_to(_('download diff'),
-					h.url('files_diff_home',repo_name=c.repo_name,f_path=filenode.path,diff2=cs2,diff1=cs1,diff='download'))}</span>
+					h.url('files_diff_home',repo_name=c.repo_name,f_path=filenode.path.decode('utf-8'),diff2=cs2,diff1=cs1,diff='download'))}</span>
 					%endif
 				</div>
 			</div>
--- a/rhodecode/templates/changeset/changeset_range.html	Fri Feb 25 19:14:12 2011 +0100
+++ b/rhodecode/templates/changeset/changeset_range.html	Sat Feb 26 16:04:38 2011 +0100
@@ -54,7 +54,7 @@
 	               %for cs in c.cs_ranges:
 	                   <div class="cur_cs">r${cs}</div>
 	                %for change,filenode,diff,cs1,cs2 in c.changes[cs.raw_id]:
-	                    <div class="cs_${change}">${h.link_to(filenode.path,h.url.current(anchor=h.repo_name_slug('C%s-%s' % (cs.short_id,filenode.path))))}</div>
+	                    <div class="cs_${change}">${h.link_to(filenode.path.decode('utf-8'),h.url.current(anchor=h.repo_name_slug('C%s-%s' % (cs.short_id,filenode.path.decode('utf-8')))))}</div>
 	                %endfor
 	               %endfor 
 	        </div>         
@@ -66,19 +66,19 @@
 		%if change !='removed':
 		<div style="clear:both;height:10px"></div>
 		<div class="diffblock">
-			<div id="${h.repo_name_slug('C%s-%s' % (cs.short_id,filenode.path))}" class="code-header">
+			<div id="${h.repo_name_slug('C%s-%s' % (cs.short_id,filenode.path.decode('utf-8')))}" class="code-header">
 				<div class="changeset_header">
 					<span class="changeset_file">
-						${h.link_to_if(change!='removed',filenode.path,h.url('files_home',repo_name=c.repo_name,
-						revision=filenode.changeset.raw_id,f_path=filenode.path))}
+						${h.link_to_if(change!='removed',filenode.path.decode('utf-8'),h.url('files_home',repo_name=c.repo_name,
+						revision=filenode.changeset.raw_id,f_path=filenode.path.decode('utf-8')))}
 					</span>
 					%if 1:
 					&raquo; <span>${h.link_to(_('diff'),
-					h.url('files_diff_home',repo_name=c.repo_name,f_path=filenode.path,diff2=cs2,diff1=cs1,diff='diff'))}</span>
+					h.url('files_diff_home',repo_name=c.repo_name,f_path=filenode.path.decode('utf-8'),diff2=cs2,diff1=cs1,diff='diff'))}</span>
 					&raquo; <span>${h.link_to(_('raw diff'),
-					h.url('files_diff_home',repo_name=c.repo_name,f_path=filenode.path,diff2=cs2,diff1=cs1,diff='raw'))}</span>
+					h.url('files_diff_home',repo_name=c.repo_name,f_path=filenode.path.decode('utf-8'),diff2=cs2,diff1=cs1,diff='raw'))}</span>
 					&raquo; <span>${h.link_to(_('download diff'),
-					h.url('files_diff_home',repo_name=c.repo_name,f_path=filenode.path,diff2=cs2,diff1=cs1,diff='download'))}</span>
+					h.url('files_diff_home',repo_name=c.repo_name,f_path=filenode.path.decode('utf-8'),diff2=cs2,diff1=cs1,diff='download'))}</span>
 					%endif
 				</div>
 			</div>
--- a/rhodecode/templates/journal/public_journal.html	Fri Feb 25 19:14:12 2011 +0100
+++ b/rhodecode/templates/journal/public_journal.html	Sat Feb 26 16:04:38 2011 +0100
@@ -15,6 +15,16 @@
 	    <!-- box / title -->
 	    <div class="title">
 	        <h5>${_('Public Journal')}</h5>
+                <ul class="links">
+                  <li>
+                    <span>${h.link_to(_('RSS'),h.url('public_journal_rss'),class_='rss_icon')}</span>
+                  </li>
+                  <li>
+                    <span>${h.link_to(_('Atom'),h.url('public_journal_atom'),class_='atom_icon')}</span>
+                  </li>                  
+                  
+                </ul>  	        
+	        
 	    </div>
 		<script type="text/javascript">
 		function show_more_event(){
--- a/rhodecode/tests/test_hg_operations.py	Fri Feb 25 19:14:12 2011 +0100
+++ b/rhodecode/tests/test_hg_operations.py	Sat Feb 26 16:04:38 2011 +0100
@@ -241,7 +241,7 @@
     test_clone(no_errors=True)
 
     cwd = path = jn(TESTS_TMP_PATH, HG_REPO)
-    added_file = jn(path, '%ssetup.py' % _RandomNameSequence().next())
+    added_file = jn(path, '%ssetupążźć.py' % _RandomNameSequence().next())
 
     Command(cwd).execute('touch %s' % added_file)
 
@@ -325,7 +325,7 @@
     #test_clone_wrong_credentials()
 
     #test_pull()
-    test_push_new_file(commits=2)
+    test_push_new_file(commits=15)
     #test_push_wrong_path()
     #test_push_wrong_credentials()