[PATCH RFC V2] hgweb: code selection without line numbers in file source view

Alexander Plavin me at aplavin.ru
Thu Jun 27 08:34:43 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 e59f138284d9cc03b3c9a894f4b7d3b3970cb749
# Parent  7a4e0ab91bcc550e85693bcb0dda1e11924a1a4e
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 7a4e0ab91bcc -r e59f138284d9 mercurial/templates/paper/filerevision.tmpl
--- a/mercurial/templates/paper/filerevision.tmpl	Wed Jun 26 12:41:21 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 7a4e0ab91bcc -r e59f138284d9 mercurial/templates/paper/map
--- a/mercurial/templates/paper/map	Wed Jun 26 12:41:21 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>{ifeq(strip(line, '\r\n'), '', ' ', '')}{strip(line|escape, "\r\n")}</div></li>'
 filelogentry = filelogentry.tmpl
 
 annotateline = '
diff -r 7a4e0ab91bcc -r e59f138284d9 mercurial/templates/static/style-paper.css
--- a/mercurial/templates/static/style-paper.css	Wed Jun 26 12:41:21 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