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 %}{{ basename }} 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 17<p> 18<a href="/{{ data.owner_name }}">{{ data.owner_name }}</a>,<br> 19{% trans receive_date=data.receive_date.strftime('%A, %e %B %Y, %H:%M:%S'), author_date=data.author_date.strftime("%A, %e %B %Y, %H:%M:%S"), 20receive_unix=data.receive_date.timestamp() | int, author_unix=data.author_date.timestamp() | int 21%} 22created on {{ author_date }} ({{ author_unix }}), 23received on {{ receive_date }} ({{ receive_unix }}) 24{% endtrans %} 25<br> 26{% trans %}Author identity:{% endtrans %} <code>{{ data.owner_identity | harvester_protection | safe }}</code> 27</p> 28 29<code>{{ data.sha }}</code> 30 31<x-vbox> 32{% for file in diff %} 33<article class="card"> 34<section class="card-main"> 35<h2>{{ file }}</h2> 36{% set vars = namespace(original_line=0, modified_line=0, hunk_started=false) %} 37{% for line in diff[file] %} 38{% if line.startswith("@@") %} 39{% if vars.hunk_started %} 40</pre> <!-- close the previous pre block if this isn't the first hunk --> 41{% endif %} 42{% set vars.hunk_started = true %} 43{% set diff_location = line|parse_diff_location %} 44{% set vars.original_line = diff_location[0][0] %} 45{% set vars.modified_line = diff_location[1][0] %} 46<h3 class="diff-position">{{ line }}</h3> 47<pre class="code-view"> 48{% elif vars.hunk_started %} 49{% if line.startswith("+") %} 50<button class="line-number" data-file="{{ file }}" data-line="{{ vars.modified_line }}">{{ vars.modified_line }} +</button> 51<ins>{{ line[1:] }}</ins> 52{% set vars.modified_line = vars.modified_line + 1 %} 53{% elif line.startswith("-") %} 54<button class="line-number" data-file="{{ file }}" data-line="{{ vars.original_line }}">{{ vars.original_line }} -</button> 55<del>{{ line[1:] }}</del> 56{% set vars.original_line = vars.original_line + 1 %} 57{% elif not line.startswith("\\") %} 58{% if line %} 59<button class="line-number" data-file="{{ file }}" data-line="{{ vars.modified_line }}">{{ vars.modified_line }} </button> 60<x-codeline>{{ line[1:] }}</x-codeline> 61{% endif %} 62{% if not line.startswith("@@") %} 63{% set vars.original_line = vars.original_line + 1 %} 64{% set vars.modified_line = vars.modified_line + 1 %} 65{% endif %} 66{% endif %} 67{% endif %} 68{% for comment in comment_query.filter_by(commit=data, file=file, line_number=vars.original_line, state=1).all() %} 69<div class="comment"> 70{{ comment.message }} 71<x-buttonbox> 72{% if comment.author == current_user or data.owner == current_user or permission_level >= 2 %} 73<form method="post" action="{{ repo_data.route }}/commit/{{ data.sha }}/resolve_comment/{{ comment.number }}"> 74<button type="submit"> 75Resolve 76</button> 77</form> 78<form method="post" action="{{ repo_data.route }}/commit/{{ data.sha }}/delete_comment/{{ comment.number }}"> 79<button type="submit" class="button-flat">Delete</button> 80</form> 81{% endif %} 82</x-buttonbox> 83</div> 84{% endfor %} 85{% if comment_query.filter_by(commit=data, file=file, line_number=vars.original_line, state=0).count() %} 86<details class="resolved-comments"> 87<summary>{% trans count=comment_query.filter_by(commit=data, file=file, line_number=vars.original_line, state=0).count() %}Resolved comments ({{ count }}){% endtrans %}</summary> 88{% for comment in comment_query.filter_by(commit=data, file=file, line_number=vars.original_line, state=0).all() %} 89<div class="comment"> 90{{ comment.message }} 91<x-buttonbox> 92{% if comment.author == current_user or data.owner == current_user or permission_level >= 2 %} 93<form method="post" action="{{ repo_data.route }}/commit/{{ data.sha }}/resolve_comment/{{ comment.number }}"> 94<button type="submit"> 95Un-resolve 96</button> 97</form> 98<form method="post" action="{{ repo_data.route }}/commit/{{ data.sha }}/delete_comment/{{ comment.number }}"> 99<button type="submit" class="button-flat">Delete</button> 100</form> 101{% endif %} 102</x-buttonbox> 103</div> 104{% endfor %} 105</details> 106{% endif %} 107{% endfor %} 108{% if vars.hunk_started %} 109</pre> {# close the last hunk #} 110{% endif %} 111</section> 112</article> 113{% endfor %} 114</x-vbox> 115</x-vbox> 116</x-frame> 117</x-vbox> 118<dialog id="add-comment-dialog"> 119<article class="card"> 120<header class="card-top"> 121<div class="navbar navbar-mini"> 122<ul> 123<li><h4>{% trans %}Add comment{% endtrans %}</h4></li> 124</ul> 125<x-buttonbox class="dialog-tools"> 126<button class="button-flat button-neutral big-button" type="submit" form="info-form"><iconify-icon icon="mdi:close"></iconify-icon></button> 127</x-buttonbox> 128</div> 129</header> 130<section class="card-main" style="padding-top: var(--padding-card-top);"> 131<form method="post" action="{{ repo_data.route }}/commit/{{ data.sha }}/add_comment"> 132<input type="hidden" name="file" value=""> 133<input type="hidden" name="line" value=""> 134<textarea name="comment" required></textarea> 135<button type="submit">Post</button> 136</form> 137</section> 138</article> 139</dialog> 140{% endblock %} 141{% block scripts %} 142<script> 143document.querySelectorAll(".line-number").forEach(function (element) { 144element.addEventListener("click", function () { 145let file = element.getAttribute("data-file"); 146let line = element.getAttribute("data-line"); 147let dialog = document.getElementById("add-comment-dialog"); 148dialog.querySelector("input[name=file]").value = file; 149dialog.querySelector("input[name=line]").value = line; 150dialog.showModal(); 151}); 152}); 153</script> 154{% endblock %} 155