{% extends "mini_buildd/base.html" %}
{% block title %}{% block titledup %}{{ route|title }} dir: /{{ path }}{% endblock %}{% endblock %}
{% block tooltip %}Directory Listing{% endblock %}

{% block content %}
	{% if view.mbd_scandir %}
		{% mbd_token as table_id %}
		<table id="{{ table_id }}" style="width: 100%;">
			{% mbd_datatable table_id order='[0, "asc"]' %}
			<thead>
				<tr>
					<th>Name</th>
					<th>Size</th>
					<th>Modified</th>
				</tr>
			</thead>
			<tbody>
				{% if path %}
					{% url name path|mbd_parent as up %}
					{% if up %}
						<tr>
							<td data-search=".." data-order="..">
								<img class="mbd-icon" src="{% static 'icons/'|add:'places/folder.svg' %}" alt="Dir">
								<a href="{{ up }}" title="Parent dir"><code>..</code></a>
							</td>
							<td></td>
							<td></td>
						</tr>
					{% endif %}
				{% endif %}

				{% for direntry in view.mbd_scandir %}
					<tr>
						<td data-search="{{ direntry.name }}" data-order="{{ direntry.name }}">
							{% if direntry.is_dir %}
								<img class="mbd-icon" src="{% static 'icons/'|add:'places/folder.svg' %}" alt="Dir">
								<a href="{% mbd_join request.path direntry.name %}" title="Browse {{ direntry.name }}"><code>{{ direntry.name }}</code></a>
							{% else %}
								<a href="{% mbd_join request.path direntry.name %}" title="View {{ direntry.name }}"><img class="mbd-icon" src="{% static 'icons/'|add:'mimetypes/text-x-generic.svg' %}" alt="File"></a>
								<a href="{% mbd_join view.mbd_static_uri direntry.name %}" title="Download {{ direntry.name }}"><code>{{ direntry.name }}</code></a>
							{% endif %}
						</td>
						<td>
							{{ direntry.stat.st_size }}
						</td>
						{% with mtime=direntry.stat.st_mtime|mbd_fromtimestamp %}
							<td class="mbd-localize-date" title="{{ mtime|date:"r" }}" data-order="{{ mtime|date:"U:u" }}">
								{{ mtime|date:"r" }}
							</td>
						{% endwith %}
					</tr>
				{% endfor %}
			</tbody>
		</table>
	{% else %}
		{% mbd_file file_path=view.mbd_fullpath uri=view.mbd_static_uri %}
	{% endif %}
{% endblock %}
