[PATCH 1 of 3 RFC] hgweb: code selection without line numbers in file source view

Alexander Plavin me at aplavin.ru
Sat Jun 29 09:06:55 CDT 2013


# HG changeset patch
# User Alexander Plavin <me at aplavin.ru>
# Date 1372180221 -14400
#      Tue Jun 25 21:10:21 2013 +0400
# Node ID 397045d4f1bed3b95c4c42d410edd762d20abd3f
# Parent  7e93df87bd7b380bb27c3812285e215774602352
hgweb: code selection without line numbers in file source view

File code is presented as HTML ordered list, so that
line numbers are not selected with the code itself.

After this patch there is no ability to get a link to a line,
(however, they work). This will be added later.

This patch changes the visual appearance of the source a little:
- line numbers have dots after them
- line numbers don't have the stripey background
- 'line source' heading above the source lines removed
- line numbers and lines have a vertical line between them
  for better distinction

diff -r 7e93df87bd7b -r 397045d4f1be mercurial/templates/paper/filerevision.tmpl
--- a/mercurial/templates/paper/filerevision.tmpl	Sat Jun 29 14:36:51 2013 +0400
+++ b/mercurial/templates/paper/filerevision.tmpl	Tue Jun 25 21:10:21 2013 +0400
@@ -67,8 +67,10 @@
 </table>
 
 <div class="overflow">
-<div class="sourcefirst"> line source</div>
+<div class="sourcefirst"></div>
+<ol class="sourcelines">
 {text%fileline}
+</ol>
 <div class="sourcelast"></div>
 </div>
 </div>
diff -r 7e93df87bd7b -r 397045d4f1be mercurial/templates/paper/map
--- a/mercurial/templates/paper/map	Sat Jun 29 14:36:51 2013 +0400
+++ b/mercurial/templates/paper/map	Tue Jun 25 21:10:21 2013 +0400
@@ -72,7 +72,7 @@
 filecomparison = filecomparison.tmpl
 filelog = filelog.tmpl
 fileline = '
-  <div class="parity{parity} source"><a href="#{lineid}" id="{lineid}">{linenumber}</a> {line|escape}</div>'
+  <li class="parity{parity} source" id="{lineid}"><div>{nonempty(strip(line|escape, '\r\n'), ' ')}</div></li>'
 filelogentry = filelogentry.tmpl
 
 annotateline = '
diff -r 7e93df87bd7b -r 397045d4f1be mercurial/templates/static/style-paper.css
--- a/mercurial/templates/static/style-paper.css	Sat Jun 29 14:36:51 2013 +0400
+++ b/mercurial/templates/static/style-paper.css	Tue Jun 25 21:10:21 2013 +0400
@@ -209,6 +209,38 @@
 .source a { color: #999; font-size: smaller; font-family: monospace;}
 .bottomline { border-bottom: 1px solid #999; }
 
+div.source, td.source { padding: 1px 4px; }
+
+ol.sourcelines {
+  background-color: #eee;
+  font-size: 90%;
+  margin: 0;
+  padding-left: 50px;
+}
+
+li.source {
+  -moz-user-select: -moz-none;
+  -khtml-user-select: none;
+  -webkit-user-select: none;
+  -ms-user-select: none;
+  user-select: none;
+  color: #999;
+  padding: 0 5px;
+}
+
+li.source div {
+  -moz-user-select: text;
+  -khtml-user-select: text;
+  -webkit-user-select: text;
+  -ms-user-select: text;
+  user-select: text;
+  padding: 1px 5px;
+  border-left: 1px solid #ccc;
+  margin: 0 0 0 -7px;
+  color: #000;
+  font-size: 111%;
+}
+
 .fileline { font-family: monospace; }
 .fileline img { border: 0; }
 


More information about the Mercurial-devel mailing list