samjeston / openhub Public
Sam Jeston Working vertical 9aa3c45 · History
53 lines· 3.1 KB ·HTML
Raw
1{# Expects `diff` (DiffSummary), `file_ref` (commit to link files at) and `base` (repo URL). #}
2<div class="diff-toolbar">
3 <span>Showing <strong>{{ crate::web::fmt::plural(diff.files.len(), "changed file") }}</strong> with <strong class="text-success">{{ crate::web::fmt::plural(diff.additions, "addition") }}</strong> and <strong class="text-danger">{{ crate::web::fmt::plural(diff.deletions, "deletion") }}</strong>.</span>
4 {% if diff.files.len() > 1 %}
5 <details class="dropdown dropdown-right">
6 <summary class="btn btn-sm">{{ crate::web::fmt::icon("file")|safe }} Jump to file {{ crate::web::fmt::icon("chevron-down")|safe }}</summary>
7 <div class="dropdown-menu dropdown-wide">
8 <div class="dropdown-scroll">
9 {% for f in diff.files %}
10 <a class="dropdown-item" href="#diff-{{ f.index }}"><span class="diff-mini-stat"><span class="text-success">+{{ f.additions }}</span> <span class="text-danger">−{{ f.deletions }}</span></span><span class="truncate">{{ f.display_path() }}</span></a>
11 {% endfor %}
12 </div>
13 </div>
14 </details>
15 {% endif %}
16</div>
17{% for f in diff.files %}
18<div class="diff-file" id="diff-{{ f.index }}">
19 <div class="diff-file-header">
20 <button type="button" class="diff-toggle" data-collapse aria-label="Collapse file">{{ crate::web::fmt::icon("chevron-down")|safe }}</button>
21 <span class="diff-counts"><span class="text-success">+{{ f.additions }}</span> <span class="text-danger">−{{ f.deletions }}</span></span>
22 <span class="diff-blocks" aria-hidden="true">{% for b in f.stat_blocks() %}<span class="block block-{{ b }}"></span>{% endfor %}</span>
23 <span class="diff-path">{{ f.display_path() }}</span>
24 {% if f.status != "modified" %}<span class="label label-{{ f.status }}">{{ f.status }}</span>{% endif %}
25 {% if f.status != "deleted" %}
26 <a class="btn btn-sm btn-ghost diff-view" href="{{ base }}/blob/{{ file_ref }}/{{ crate::web::fmt::urlpath(f.new_path) }}">View file</a>
27 {% endif %}
28 </div>
29 <div class="diff-body">
30 {% if f.binary %}
31 <div class="diff-note">Binary file not shown.</div>
32 {% else if f.too_large %}
33 <div class="diff-note">Large diff not rendered ({{ f.additions }} additions, {{ f.deletions }} deletions).</div>
34 {% else if f.hunks.is_empty() %}
35 <div class="diff-note">{% if f.status == "renamed" %}File renamed without changes.{% else %}No content changes.{% endif %}</div>
36 {% else %}
37 <div class="diff-scroll">
38 <table class="diff-table">
39 {% for h in f.hunks %}
40 <tr class="diff-hunk"><td class="num"></td><td class="num"></td><td class="code">{{ h.header }}</td></tr>
41 {% for l in h.lines %}
42 <tr class="diff-line {{ l.class() }}"><td class="num">{% if let Some(n) = l.old_no %}{{ n }}{% endif %}</td><td class="num">{% if let Some(n) = l.new_no %}{{ n }}{% endif %}</td><td class="code"><span class="marker">{{ l.marker() }}</span>{{ l.html|safe }}</td></tr>
43 {% endfor %}
44 {% endfor %}
45 </table>
46 </div>
47 {% endif %}
48 </div>
49</div>
50{% endfor %}
51{% if diff.files.is_empty() %}
52<div class="blankslate blankslate-sm"><p>No file changes.</p></div>
53{% endif %}