# HG changeset patch # User Thomas De Schampheleire # Date 2019-04-16 20:39:13 # Node ID 25bdf9f62ab6d38c586f831c865ed7c00160c848 # Parent b293ec74ef989195daaeb33fd5259bfd01dbe5b8 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. diff --git a/kallithea/templates/files/files_browser.html b/kallithea/templates/files/files_browser.html --- a/kallithea/templates/files/files_browser.html +++ b/kallithea/templates/files/files_browser.html @@ -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 name="_file_name(iconclass, name)"> + <%return h.literal('%s' % (iconclass, name))%> + <%def name="file_name(node)"> <% c = "icon-folder-open" @@ -24,7 +27,7 @@ elif node.is_submodule(): c = "icon-file-submodule" %> - <%return h.literal('%s' % (c, h.escape(node.name)))%> + <%return _file_name(c, h.escape(node.name))%>
@@ -60,7 +63,7 @@ %if c.file.parent: - ${h.link_to(h.literal('..'),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")}