repo-commit.html
HTML document, ASCII text
1
{% extends "repo.html" %}
2
3
{% set active_page = "log" %}
4
5
{% block title %}
6
{% trans message=data.message|split("\n\n")|first, username=username, repository=repository %}{{ message }} in {{ username }}/{{ repository }}{% endtrans %}
7
{% endblock %}
8
{% block content %}
9
<x-vbox>
10
<x-frame style="--width: 896px;" class="flexible-space">
11
<x-vbox>
12
<article>
13
<h1>{{ data.message | split("\n\n", 1) | first | inline_markdown }}</h1>
14
{{ data.message | split("\n\n", 1) | last | markdown }}
15
</article>
16
<p>
17
{%- trans receive_date=data.receive_date | strftime('%A, %e %B %Y, %H:%M:%S'),
18
author_date=data.author_date | strftime("%A, %e %B %Y, %H:%M:%S"),
19
receive_unix=data.receive_date.timestamp() | int,
20
author_unix=data.author_date.timestamp() | int,
21
owner_name=data.owner_name,
22
profile_url=owner_name | profile_url,
23
pusher_name=data.pusher.username
24
-%}
25
by <a href="{{ profile_url }}">{{ owner_name }}</a>,
26
{{ author_date }} ({{ author_unix }}),
27
pushed by <a href="/{{ pusher_name }}">{{ pusher_name }}</a>,
28
{{ receive_date }} ({{ receive_unix }})
29
{% endtrans %}
30
</p>
31
<p>
32
{% trans %}Author identity:{% endtrans %} <code>{{ data.owner_identity | harvester_protection | safe }}</code>
33
</p>
34
35
<code class="commit-sha">{{ data.sha }}</code>
36
37
<x-vbox>
38
{% for file in diff %}
39
<article class="card">
40
<section class="card-main">
41
<h2>{{ file }}</h2>
42
{% set vars = namespace(original_line=0, modified_line=0, hunk_started=false, actual_line=0, line_type=0) %}
43
{% for line in diff[file] %}
44
{% if line.startswith("@@") %}
45
{% if vars.hunk_started %}
46
</pre> <!-- close the previous pre block if this isn't the first hunk -->
47
{% endif %}
48
{% set vars.hunk_started = true %}
49
{% set diff_location = line|parse_diff_location %}
50
{% set vars.original_line = diff_location[0][0] %}
51
{% set vars.modified_line = diff_location[1][0] %}
52
<h3 class="diff-position">{{ line }}</h3>
53
<pre class="code-view">
54
{% elif vars.hunk_started %}
55
{% if line.startswith("+") %}
56
<button class="line-number" data-file="{{ file }}" data-line="+{{ vars.modified_line }}">{{ vars.modified_line }} +</button>
57
<ins>{{ line[1:] }}</ins>
58
{% set vars.actual_line = vars.modified_line %}
59
{% set vars.line_type = 1 %}
60
{% set vars.modified_line = vars.modified_line + 1 %}
61
{% elif line.startswith("-") %}
62
<button class="line-number" data-file="{{ file }}" data-line="-{{ vars.original_line }}">{{ vars.original_line }} -</button>
63
<del>{{ line[1:] }}</del>
64
{% set vars.actual_line = vars.original_line %}
65
{% set vars.line_type = 0 %}
66
{% set vars.original_line = vars.original_line + 1 %}
67
{% elif not line.startswith("\\") %}
68
{% if line %}
69
<button class="line-number" data-file="{{ file }}" data-line="+{{ vars.modified_line }}">{{ vars.modified_line }} </button>
70
<x-codeline>{{ line[1:] }}</x-codeline>
71
{% endif %}
72
{% if not line.startswith("@@") %}
73
{% set vars.actual_line = vars.modified_line %}
74
{% set vars.line_type = 1 %}
75
{% set vars.original_line = vars.original_line + 1 %}
76
{% set vars.modified_line = vars.modified_line + 1 %}
77
{% endif %}
78
{% endif %}
79
{% endif %}
80
{% for comment in comment_query.filter_by(commit=data, file=file, line_number=vars.actual_line, line_type=vars.line_type, state=1).all() %}
81
<div class="comment">
82
<article>
83
{{ comment.text | safe }} {# this was generated by the markdown parser which escapes HTML #}
84
</article>
85
<small>
86
{% trans %}by{% endtrans %} <a href="/{{ comment.owner_name }}">{{ comment.owner.username }}</a>,
87
{{ comment.date | strftime('%A, %e %B %Y, %H:%M:%S') }}
88
</small>
89
<x-buttonbox>
90
{% if comment.author == current_user or data.owner == current_user or permission_level >= 2 %}
91
<form method="post" action="{{ repo_data.route }}/commit/{{ data.sha }}/resolve_comment/{{ comment.number }}">
92
<button type="submit">
93
{% trans %}Resolve{% endtrans %}
94
</button>
95
</form>
96
<form method="post" action="{{ repo_data.route }}/commit/{{ data.sha }}/delete_comment/{{ comment.number }}">
97
<button type="submit" class="button-flat">{% trans %}Delete{% endtrans %}</button>
98
</form>
99
{% endif %}
100
</x-buttonbox>
101
</div>
102
{% endfor %}
103
{% if comment_query.filter_by(commit=data, file=file, line_number=vars.actual_line, line_type=vars.line_type, state=0).count() %}
104
<details class="resolved-comments">
105
<summary>{% trans count=comment_query.filter_by(commit=data, file=file, line_number=vars.actual_line, line_type=vars.line_type, state=0).count() %}Resolved comments ({{ count }}){% endtrans %}</summary>
106
{% for comment in comment_query.filter_by(commit=data, file=file, line_number=vars.actual_line, line_type=vars.line_type, state=0).all() %}
107
<div class="comment">
108
{{ comment.text | safe }} {# this was generated by the markdown parser which escapes HML #}
109
<x-buttonbox>
110
{% if comment.author == current_user or data.owner == current_user or permission_level >= 2 %}
111
<form method="post" action="{{ repo_data.route }}/commit/{{ data.sha }}/resolve_comment/{{ comment.number }}">
112
<button type="submit">
113
{% trans %}Unresolve{% endtrans %}
114
</button>
115
</form>
116
<form method="post" action="{{ repo_data.route }}/commit/{{ data.sha }}/delete_comment/{{ comment.number }}">
117
<button type="submit" class="button-flat">{% trans %}Delete{% endtrans %}</button>
118
</form>
119
{% endif %}
120
</x-buttonbox>
121
</div>
122
{% endfor %}
123
</details>
124
{% endif %}
125
{% endfor %}
126
{% if vars.hunk_started %}
127
</pre> {# close the last hunk #}
128
{% endif %}
129
</section>
130
</article>
131
{% endfor %}
132
</x-vbox>
133
</x-vbox>
134
</x-frame>
135
</x-vbox>
136
<dialog id="add-comment-dialog">
137
<article class="card">
138
<header class="card-top">
139
<div class="navbar navbar-mini">
140
<ul>
141
<li><h4>{% trans %}Add comment{% endtrans %}</h4></li>
142
</ul>
143
<form class="buttonbox dialog-tools" method="dialog">
144
<button class="button-flat button-neutral big-button" type="submit"><iconify-icon icon="mdi:close"></iconify-icon></button>
145
</form>
146
</div>
147
</header>
148
<section class="card-main" style="padding-top: var(--padding-card-top);">
149
<form method="post" action="{{ repo_data.route }}/commit/{{ data.sha }}/add_comment">
150
<input type="hidden" name="file" value="">
151
<input type="hidden" name="line" value="">
152
<textarea name="comment" required autofocus></textarea>
153
<button type="submit">
154
{% trans %}Post{% endtrans %}
155
</button>
156
</form>
157
</section>
158
</article>
159
</dialog>
160
{% endblock %}
161
{% block scripts %}
162
{% if logged_in_user %}
163
<script>
164
document.querySelectorAll(".line-number").forEach(function (element) {
165
element.addEventListener("click", function () {
166
let file = element.getAttribute("data-file");
167
let line = element.getAttribute("data-line");
168
let dialog = document.getElementById("add-comment-dialog");
169
dialog.querySelector("input[name=file]").value = file;
170
dialog.querySelector("input[name=line]").value = line;
171
dialog.showModal();
172
});
173
});
174
document.querySelectorAll()
175
</script>
176
{% endif %}
177
{% endblock %}
178