home » zplus/clif.git
Author zPlus <zplus@peers.community> 2022-08-09 15:12:14
Committer zPlus <zplus@peers.community> 2022-08-09 15:12:14
Commit d448d3c (patch)
Tree b4247be
Parent(s)

Add links to blobs in the commit page. Add links for opening blob files directly from the diff view of the commit page.


commits diff: 357fac4..d448d3c
2 files changed, 38 insertions, 34 deletionsdownload


Diffstat
-rw-r--r-- static/css/clif.css 38
-rw-r--r-- templates/repository/commit.html 34

Diff options
View
Side
Whitespace
Context lines
Inter-hunk lines
+20/-18 M   static/css/clif.css
index 2833fba..3a4612f
old size: 10K - new size: 10K
@@ -440,12 +440,6 @@ div.commit {
440 440 padding: .5rem .5rem;
441 441 }
442 442
443 - div.commit details.diff_view .diff .lineno {
444 - color: gray;
445 - text-align: center;
446 - width: 0;
447 - }
448 -
449 443 div.commit details.diff_view .diff .origin {
450 444 width: 0;
451 445 }
@@ -488,19 +482,27 @@ div.commit {
488 482 .highlight {
489 483 background: none;
490 484 }
491 -
492 - .highlight .linenos {
493 - border-right: 1px solid #aaa;
494 - padding-right: .5rem;
495 - }
496 -
497 - .highlight .linenos a,
498 - .highlight .linenos a:hover,
499 - .highlight .linenos a:visited {
500 - color: gray;
501 - text-decoration: none;
502 - }
503 485
504 486 .highlight .code {
505 487 padding-left: 1rem;
506 488 }
489 +
490 + /* Line numbers when showind diffs or blobs.
491 + * Do not change class name, because this is an extension of the "lineos" class
492 + * that is generated from Pygments. */
493 + .linenos {
494 + border-right: 1px solid #aaa;
495 + text-align: right;
496 + width: 0;
497 + }
498 +
499 + .linenos a,
500 + .linenos a:hover,
501 + .linenos a:visited {
502 + color: gray;
503 + text-decoration: none;
504 + }
505 +
506 + .linenos a:hover {
507 + color: black;
508 + }

+18/-16 M   templates/repository/commit.html
index 3e8224e..9cd61dd
old size: 18K - new size: 19K
@@ -71,7 +71,9 @@
71 71 {% for patch in diff %}
72 72 <tr>
73 73 <td class="filemode">{{ patch.delta.new_file.mode|filemode }}</td>
74 - <td class="path">{{ patch.delta.new_file.path }}</td>
74 + <td class="path">
75 + <a href="{{ url('tree_path', repository=repository[:-4], revision=commit.id, tree_path=patch.delta.new_file.path) }}">{{ patch.delta.new_file.path }}</a>
76 + </td>
75 77 <td class="lines">{{ patch.line_stats[1] + patch.line_stats[2] }}</td>
76 78 <td class="histogram">
77 79 {% if diff_stats.insertions + diff_stats.deletions > 0 %}
@@ -202,7 +204,7 @@
202 204 <table>
203 205 <tr>
204 206 <td>
205 - index {{ (patch.delta.old_file.id|string)[:7] }}..{{ (patch.delta.new_file.id|string)[:7] }}
207 + index <a href="{{ url('tree_path', repository=repository[:-4], revision=commit.parents[0].id, tree_path=patch.delta.old_file.path) }}">{{ (patch.delta.old_file.id|string)[:7] }}</a>..<a href="{{ url('tree_path', repository=repository[:-4], revision=commit.id, tree_path=patch.delta.new_file.path) }}">{{ (patch.delta.new_file.id|string)[:7] }}</a>
206 208 </td>
207 209 </tr>
208 210 <tr>
@@ -252,14 +254,14 @@
252 254
253 255 {% for line in hunk.lines %}
254 256 <tr class="udiff {{ 'insertion' if line.old_lineno < 0 }} {{ 'deletion' if line.new_lineno < 0 }}">
255 - <td class="lineno">
257 + <td class="linenos">
256 258 {% if line.old_lineno >= 0 %}
257 - {{ line.old_lineno }}
259 + <a href="{{ url('tree_path', repository=repository[:-4], revision=commit.parents[0].id, tree_path=patch.delta.old_file.path) }}#line-{{ line.old_lineno }}">{{ line.old_lineno }}</a>
258 260 {% endif %}
259 261 </td>
260 - <td class="lineno">
262 + <td class="linenos">
261 263 {% if line.new_lineno >= 0 %}
262 - {{ line.new_lineno }}
264 + <a href="{{ url('tree_path', repository=repository[:-4], revision=commit.id, tree_path=patch.delta.new_file.path) }}#line-{{ line.new_lineno }}">{{ line.new_lineno }}</a>
263 265 {% endif %}
264 266 </td>
265 267 <td class="origin">{{ line.origin }}</td>
@@ -282,23 +284,23 @@
282 284 {% for buffer_del, buffer_ins in zip_longest(buffer_deletions, buffer_insertions) %}
283 285 <tr class="ssdiff">
284 286 {% if buffer_del %}
285 - <td class="lineno">
286 - {{ buffer_del.old_lineno }}
287 + <td class="linenos">
288 + <a href="{{ url('tree_path', repository=repository[:-4], revision=commit.parents[0].id, tree_path=patch.delta.old_file.path) }}#line-{{ buffer_del.old_lineno }}">{{ buffer_del.old_lineno }}</a>
287 289 </td>
288 290 <td class="content {{ 'deletion' if buffer_insertions|length == 0 else 'change' }}">{{ buffer_del.content }}</td>
289 291 {% else %}
290 - <td class="lineno">
292 + <td class="linenos">
291 293 </td>
292 294 <td class="content"></td>
293 295 {% endif %}
294 296
295 297 {% if buffer_ins %}
296 - <td class="lineno">
297 - {{ buffer_ins.new_lineno }}
298 + <td class="linenos">
299 + <a href="{{ url('tree_path', repository=repository[:-4], revision=commit.id, tree_path=patch.delta.new_file.path) }}#line-{{ buffer_ins.new_lineno }}">{{ buffer_ins.new_lineno }}</a>
298 300 </td>
299 301 <td class="content {{ 'insertion' if buffer_deletions|length == 0 else 'change' }}">{{ buffer_ins.content }}</td>
300 302 {% else %}
301 - <td class="lineno">
303 + <td class="linenos">
302 304 </td>
303 305 <td class="content"></td>
304 306 {% endif %}
@@ -334,13 +336,13 @@
334 336
335 337 {# Insert the unchanged line. #}
336 338 <tr class="ssdiff">
337 - <td class="lineno">
338 - {{ line.old_lineno }}
339 + <td class="linenos">
340 + <a href="{{ url('tree_path', repository=repository[:-4], revision=commit.parents[0].id, tree_path=patch.delta.old_file.path) }}#line-{{ line.old_lineno }}">{{ line.old_lineno }}</a>
339 341 </td>
340 342 <td class="content">{{ line.content }}</td>
341 343
342 - <td class="lineno">
343 - {{ line.new_lineno }}
344 + <td class="linenos">
345 + <a href="{{ url('tree_path', repository=repository[:-4], revision=commit.id, tree_path=patch.delta.new_file.path) }}#line-{{ line.new_lineno }}">{{ line.new_lineno }}</a>
344 346 </td>
345 347 <td class="content">{{ line.content }}</td>
346 348 </tr>