Skip to content
Snippets Groups Projects
Commit 39319e08 authored by Antoine R. Dumont's avatar Antoine R. Dumont
Browse files

Permit to display a visual difference in listing dir and files

TODO: define such style
parent 5556ff3b
Branches directory-list
No related tags found
No related merge requests found
......@@ -4,7 +4,7 @@
{{ message }}
{% if ls is not none %}
{% for e in files %}
<div><p><a href="{{e.link}}">{{ e.name }}</a></p></div>
<div><p><a class="link{{e.type}}" href="{{e.link}}">{{ e.name }}</a></p></div>
{% endfor %}
{% endif %}
{% endblock %}
......@@ -105,11 +105,14 @@ class UtilsTestCase(unittest.TestCase):
'name': 'some-other-dirname'}]
expected_output = [{'link': '/path/to/url/dir/123',
'name': 'some-dir-name'},
'name': 'some-dir-name',
'type': 'dir'},
{'link': '/path/to/url/file/654',
'name': 'some-filename'},
'name': 'some-filename',
'type': 'file'},
{'link': '/path/to/url/dir/987',
'name': 'some-other-dirname'}]
'name': 'some-other-dirname',
'type': 'dir'}]
# when
actual_outputs = utils.prepare_directory_listing(inputs)
......
......@@ -39,14 +39,14 @@ def prepare_directory_listing(files):
"""
ls = []
for entry in files:
new_entry = {}
new_entry = {'name': entry['name'],
'type': entry['type']}
if entry['type'] == 'dir':
new_entry['link'] = flask.url_for('browse_directory',
sha1_git=entry['target'])
else:
new_entry['link'] = flask.url_for('show_content',
q=entry['sha1'])
new_entry['name'] = entry['name']
ls.append(new_entry)
return ls
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment