Download:
child 38:cf936f5403ff
parent 36:c43e16e3c768
37:5f59998fb5eb
Anton Shestakov <av6@dwimlabs.net>, Wed, 15 Apr 2020 15:20:29 +0800
kit: use CSS counters to render line numbers where possible Affects changeset, file view, file diff and file annotate pages. Doesn't affect file comparison page (aka side-by-side file diff). Page size, regular file view (mercurial/commands.py): - 987963 B before - 596244 B after Page size, changeset (4441705b7111): - 1319976 B before - 923672 B after

3 файлов изменено, 46 вставок(+), 8 удалений(-) [+]
templates/kit/changeset.tmpl file | annotate | diff | comparison | revisions
templates/kit/map file | annotate | diff | comparison | revisions
templates/static/style-kit.css file | annotate | diff | comparison | revisions
--- a/templates/kit/changeset.tmpl Mon Apr 13 10:05:40 2020 +0800
+++ b/templates/kit/changeset.tmpl Wed Apr 15 15:20:29 2020 +0800
@@ -60,7 +60,7 @@
<table class="uk-table uk-table-hover uk-text-nowrap">{files}</table>
- {diff}
+ <div class="kit-diffs">{diff}</div>
</div>
{footer}
--- a/templates/kit/map Mon Apr 13 10:05:40 2020 +0800
+++ b/templates/kit/map Wed Apr 15 15:20:29 2020 +0800
@@ -103,7 +103,7 @@
filediff = filediff.tmpl
filecomparison = filecomparison.tmpl
filelog = filelog.tmpl
-fileline = '<div id="{lineid}"><a href="#{lineid}" class="kit-line-number" data-line-number="{linenumber}"></a>{strip(line|escape, '\r\n')}</div>'
+fileline = '<div id="{lineid}"><a href="#{lineid}"></a>{strip(line|escape, '\r\n')}</div>'
annotateline = '
<tr id="{lineid}" {ifeq(node, originalnode, ' class="kit-this-rev"')}>
<td class="uk-visible-hover uk-position-relative uk-text-top kit-block-parity{blockparity}">
@@ -119,13 +119,13 @@
<a href="{url|urlescape}diff/{node|short}/{file|urlescape}{sessionvars%urlparameter}">diff</a>
</div>
</td>
- <td class="kit-monospace kit-annotate-line"><a href="#{lineid}" class="kit-line-number" data-line-number="{linenumber}"></a>{line|escape}</td>
+ <td class="kit-monospace kit-annotate-line"><a href="#{lineid}"></a>{line|escape}</td>
</tr>'
annotateparent = '<a class="kit-monospace" href="{url|urlescape}annotate/{node|short}/{file|urlescape}{sessionvars%urlparameter}">{rev}:{node|short}</a>'
-difflineplus = '<div id="{lineid}" class="kit-line-plus"><a href="#{lineid}" class="kit-line-number" data-line-number="{linenumber}"></a>{strip(line|escape, '\r\n')}</div>'
-difflineminus = '<div id="{lineid}" class="kit-line-minus"><a href="#{lineid}" class="kit-line-number" data-line-number="{linenumber}"></a>{strip(line|escape, '\r\n')}</div>'
-difflineat = '<div id="{lineid}" class="kit-line-at"><a href="#{lineid}" class="kit-line-number" data-line-number="{linenumber}"></a>{strip(line|escape, '\r\n')}</div>'
-diffline = '<div id="{lineid}"><a href="#{lineid}" class="kit-line-number" data-line-number="{linenumber}"></a>{strip(line|escape, '\r\n')}</div>'
+difflineplus = '<div id="{lineid}" class="kit-line-plus"><a href="#{lineid}"></a>{strip(line|escape, '\r\n')}</div>'
+difflineminus = '<div id="{lineid}" class="kit-line-minus"><a href="#{lineid}"></a>{strip(line|escape, '\r\n')}</div>'
+difflineat = '<div id="{lineid}" class="kit-line-at"><a href="#{lineid}"></a>{strip(line|escape, '\r\n')}</div>'
+diffline = '<div id="{lineid}"><a href="#{lineid}"></a>{strip(line|escape, '\r\n')}</div>'
comparisonblock = '<tbody class="kit-monospace kit-comparison">{lines}</tbody>'
comparisonline = '
--- a/templates/static/style-kit.css Mon Apr 13 10:05:40 2020 +0800
+++ b/templates/static/style-kit.css Wed Apr 15 15:20:29 2020 +0800
@@ -132,6 +132,29 @@
background-color: #f0f0f0;
}
+.kit-diffs {
+ counter-reset: diff;
+}
+
+.kit-diff {
+ counter-increment: diff;
+}
+
+.kit-file,
+.kit-diff,
+.kit-annotate {
+ counter-reset: lineno;
+}
+
+.kit-file div,
+.kit-diff div,
+.kit-annotate-line {
+ counter-increment: lineno;
+}
+
+.kit-file a,
+.kit-diff a,
+.kit-annotate-line a,
a.kit-line-number {
display: inline-block;
text-align: right;
@@ -142,9 +165,24 @@
white-space: normal;
}
+.kit-file a::before,
+.kit-diff a::before,
+.kit-annotate-line a::before,
+a.kit-line-number::before {
+ padding-right: 10px;
+}
+
+.kit-file a::before,
+.kit-annotate-line a::before {
+ content: counter(lineno);
+}
+
+.kit-diff a::before {
+ content: counter(diff) "." counter(lineno);
+}
+
a.kit-line-number::before {
content: attr(data-line-number);
- padding-right: 10px;
}
.kit-diffstat-add,