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
--- 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
<table class="uk-table uk-table-hover uk-text-nowrap">{files}</table>
+ <div class="kit-diffs">{diff}</div>
--- a/templates/kit/map Mon Apr 13 10:05:40 2020 +0800
+++ b/templates/kit/map Wed Apr 15 15:20:29 2020 +0800
filecomparison = filecomparison.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>'
<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}">
<a href="{url|urlescape}diff/{node|short}/{file|urlescape}{sessionvars%urlparameter}">diff</a>
- <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>
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>'
--- 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
background-color: #f0f0f0;
+ counter-increment: diff;
+ counter-increment: lineno;
+.kit-annotate-line a::before,
+a.kit-line-number::before {
+.kit-annotate-line a::before {
+ content: counter(lineno);
+ content: counter(diff) "." counter(lineno);
a.kit-line-number::before {
content: attr(data-line-number);