Files
GitList/views/tree.twig
Nate Eagleson 421574b5a9 Correctly support branch names with slashes
Previously, branches with slashes in the name would consume all slashed
segments in a URL, causing the routes to capture incorrect file paths.

This solution is not particularly elegant - anywhere a route used
both a commit-ish identifier and a path, we collapse those two params
into a single param, and parse that param inside the route.

It seems to be working reasonably reliably, but has not seen extensive
testing.

It is also not particularly pretty. If anyone sees ways to improve it,
please, have at it.
2013-02-08 20:10:11 -05:00

68 lines
2.8 KiB
Twig

{% extends 'layout_page.twig' %}
{% set page = 'files' %}
{% block title %}GitList{% endblock %}
{% block content %}
{% embed 'breadcrumb.twig' with {breadcrumbs: breadcrumbs} %}
{% block extra %}
<div class="pull-right">
<div class="btn-group download-buttons">
<a href="{{ path('archive', {repo: repo, branch: branch, format: 'zip'}) }}" class="btn btn-mini" title="Download '{{ branch }}' as a ZIP archive">ZIP</a>
<a href="{{ path('archive', {repo: repo, branch: branch, format: 'tar'}) }}" class="btn btn-mini" title="Download '{{ branch }}' as a TAR archive">TAR</a>
</div>
<a href="{{ path('rss', {repo: repo, branch: branch}) }}" class="rss-icon"><i class="rss"></i></a>
</div>
{% endblock %}
{% endembed %}
<table class="tree">
<thead>
<tr>
<th width="80%">name</th>
<th width="10%">mode</th>
<th width="10%">size</th>
</tr>
</thead>
<tbody>
{% if parent is not null %}
<tr>
<td><i class="icon-spaced"></i>
{% if not parent %}
<a href="{{ path('branch', {repo: repo, branch: branch}) }}">..</a>
{% else %}
<a href="{{ path('tree', {repo: repo, commitish_path: branch ~ '/' ~ parent}) }}">..</a>
{% endif %}
</td>
<td></td>
<td></td>
</tr>
{% endif %}
{% for file in files %}
<tr>
<td><i class="{{ file.type == "folder" or file.type == "symlink" ? "icon-folder-open" : "icon-file" }} icon-spaced"></i> <a href="
{%- if file.type == "folder" or file.type == "symlink" -%}
{{ path('tree', {repo: repo, commitish_path: branch ~ '/' ~ path ~ (file.type == "symlink" ? file.path : file.name)}) }}
{%- else -%}
{{ path('blob', {repo: repo, commitish_path: branch ~ '/' ~ path ~ (file.type == "symlink" ? file.path : file.name)}) }}
{%- endif -%}
">{{ file.name }}</a></td>
<td>{{ file.mode }}</td>
<td>{% if file.size %}{{ (file.size / 1024) | number_format }} kb{% endif %}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% if readme is defined and readme is not empty %}
<div class="readme-view">
<div class="readme-header">
<div class="meta">{{ readme.filename }}</div>
</div>
<div id="readme-content">{{ readme.content }}</div>
</div>
{% endif %}
<hr />
{% endblock %}