changeset 7636:25bdf9f62ab6 stable

files: reduce duplication in display of file entries Avoid special casing of the 'parent directory' link (..) by extracting some logic to a helper function. This avoids duplication. A subsequent commit will make changes to this logic and by introducing this helper function we only need to change in one place.
author Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
date Tue, 16 Apr 2019 20:39:13 +0200
parents b293ec74ef98
children 5bb7a18b0431
files kallithea/templates/files/files_browser.html
diffstat 1 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/templates/files/files_browser.html	Sun Apr 14 20:32:10 2019 +0200
+++ b/kallithea/templates/files/files_browser.html	Tue Apr 16 20:39:13 2019 +0200
@@ -16,6 +16,9 @@
         <%return h.url('files_home', repo_name=c.repo_name, revision=c.changeset.raw_id, f_path=h.safe_unicode(node.path))%>
     %endif
 </%def>
+<%def name="_file_name(iconclass, name)">
+    <%return h.literal('<i class="%s"></i><span>%s</span>' % (iconclass, name))%>
+</%def>
 <%def name="file_name(node)">
     <%
         c = "icon-folder-open"
@@ -24,7 +27,7 @@
         elif node.is_submodule():
             c = "icon-file-submodule"
     %>
-    <%return h.literal('<i class="%s"></i><span>%s</span>' % (c, h.escape(node.name)))%>
+    <%return _file_name(c, h.escape(node.name))%>
 </%def>
 <div id="body" class="panel panel-default">
     <div class="panel-heading clearfix">
@@ -60,7 +63,7 @@
                 %if c.file.parent:
                 <tr class="parity0">
                     <td>
-                        ${h.link_to(h.literal('<i class="icon-folder-open"></i><span>..</span>'),h.url('files_home',repo_name=c.repo_name,revision=c.changeset.raw_id,f_path=c.file.parent.path),class_="browser-dir ypjax-link")}
+                        ${h.link_to(_file_name('icon-folder-open', '..'),h.url('files_home',repo_name=c.repo_name,revision=c.changeset.raw_id,f_path=c.file.parent.path),class_="browser-dir ypjax-link")}
                     </td>
                     <td></td>
                     <td></td>