index : gitrs
A lightweight web interface for browsing Git repositories, implemented in Rust
about summary refs log tree commit diff
gitrs / templates / repository / tree.html
-rw-r--r-- blob abea3e30aee92ca3293450439e124111405f64e1 3004 bytes (plain)
1
{% extends "base.html" %}
2
3
{% block title %}{{ repo.name }} — {{ repo.description }}{% endblock %}
4
5
{% block header %}
6
  {{ macros::header(Some(repo), branch_names, Some(current_ref)) }}
7
{% endblock %}
8
9
{% block tabs %}
10
  {{ macros::repo_tabs(repo, current_ref, query, "tree") }}
11
{% endblock %}
12
13
{% decl parameters %}
14
{% if !current_ref.is_head %}
15
{% let parameters %}?h={{ current_ref.name }}{% endlet %}
16
{% else %}
17
{% let parameters = "".to_string() %}
18
{% endif %}
19
20
{% block breadcrumb %}
21
  <div class="tree-breadcrumb">
22
    <a href="/{{ repo.name }}/tree/{{ parameters }}">{{ repo.name }}</a>
23
    {% for crumb in breadcrumbs %}
24
    /
25
    <a href="/{{ repo.name }}/tree/{{ crumb.path }}{{ parameters }}">{{ crumb.name }}</a>
26
    {% endfor %}
27
  </div>
28
{% endblock %}
29
30
{% block content %}
31
  {% match kind %}
32
    {% when PathView::Tree(entries) %}
33
      <table class="tree-table">
34
        <thead>
35
          <tr>
36
            <th class="mode">Mode</th>
37
            <th>Name</th>
38
            <th>Size</th>
39
          </tr>
40
        </thead>
41
        <tbody>
42
          {% if let Some(up) = parent_path %}
43
            <tr class="tree-parent">
44
              <td></td>
45
              <td><a href="/{{ repo.name }}/tree/{{ up }}{{ parameters }}">..</a></td>
46
              <td></td>
47
            </tr>
48
          {% endif %}
49
          {% for entry in entries %}
50
            <tr>
51
              <td class="mode">{{ entry.mode_display() }}</td>
52
              <td>
53
                {% match entry.kind %}
54
                  {% when EntryKind::Tree %}
55
                    <a class="folder" href="/{{ repo.name }}/tree/{{ entry.path }}/{{ parameters }}">{{ entry.name }}</a>
56
                  {% when EntryKind::Commit %}
57
                    <span class="submodule">{{ entry.name }} @ {{ entry.id }}</span>
58
                  {% when _ %}
59
                    <a href="/{{ repo.name }}/tree/{{ entry.path }}{{ parameters }}">{{ entry.name }}</a>
60
                {% endmatch %}
61
              </td>
62
              <td class="size">{{ entry.size_display() }}</td>
63
            </tr>
64
          {% endfor %}
65
        </tbody>
66
      </table>
67
    {% when PathView::Blob(blob) %}
68
      <div class="blob-meta">
69
        <span class="mode">{{ blob.mode_display() }}</span>
70
        <span class="blob-id">blob {{ blob.id }}</span>
71
        <span class="size">{{ blob.size }} bytes</span>
72
        (<a href="/{{ repo.name }}/raw/{{ filepath }}?h={{ current_ref.name }}">plain</a>)
73
      </div>
74
      {% if let Some(lines) = blob.lines %}
75
        <table class="blob-table">
76
          <tbody>
77
            {% for line in lines %}
78
              <tr>
79
                <td class="line-no">{{ loop.index }}</td>
80
                <td class="line-content"><pre>{{ line }}</pre></td>
81
              </tr>
82
            {% endfor %}
83
          </tbody>
84
        </table>
85
      {% else %}
86
        <p>Binary file not shown. <a href="/{{ repo.name }}/raw/{{ filepath }}?h={{ current_ref.name }}">Download raw</a>.</p>
87
      {% endif %}
88
  {% endmatch %}
89
{% endblock %}