[PATCH 1 of 5] hgweb: code selection without line numbers in file code view

Alexander Plavin me at aplavin.ru
Fri May 31 05:35:08 CDT 2013


# HG changeset patch
# User Alexander Plavin <me at aplavin.ru>
# Date 1369988709 -14400
#      Fri May 31 12:25:09 2013 +0400
# Node ID fb5ca82f275afc3cbacd10441a9f55f1730a538d
# Parent  1bef6f99a12d9062e737bb623da627719a3987e6
hgweb: code selection without line numbers in file code view

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

diff -r 1bef6f99a12d -r fb5ca82f275a mercurial/templatefilters.py
--- a/mercurial/templatefilters.py	Thu May 23 17:53:38 2013 -0500
+++ b/mercurial/templatefilters.py	Fri May 31 12:25:09 2013 +0400
@@ -354,6 +354,9 @@
             .replace("'", ''')) # ' invalid in HTML
     return re.sub('[\x00-\x08\x0B\x0C\x0E-\x1F]', ' ', text)
 
+def spaceifempty(text):
+    return text or ' '
+
 filters = {
     "addbreaks": addbreaks,
     "age": age,
@@ -381,6 +384,7 @@
     "short": short,
     "shortbisect": shortbisect,
     "shortdate": shortdate,
+    'spaceifempty': spaceifempty,
     "stringescape": stringescape,
     "stringify": stringify,
     "strip": strip,
diff -r 1bef6f99a12d -r fb5ca82f275a mercurial/templates/paper/filerevision.tmpl
--- a/mercurial/templates/paper/filerevision.tmpl	Thu May 23 17:53:38 2013 -0500
+++ b/mercurial/templates/paper/filerevision.tmpl	Fri May 31 12:25:09 2013 +0400
@@ -67,8 +67,10 @@
 </table>
 
 <div class="overflow">
-<div class="sourcefirst"> line source</div>
+<div class="sourcefirst"></div>
+<ol>
 {text%fileline}
+</ol>
 <div class="sourcelast"></div>
 </div>
 </div>
diff -r 1bef6f99a12d -r fb5ca82f275a mercurial/templates/paper/map
--- a/mercurial/templates/paper/map	Thu May 23 17:53:38 2013 -0500
+++ b/mercurial/templates/paper/map	Fri May 31 12:25:09 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>{line|escape|spaceifempty}</div></li>'
 filelogentry = filelogentry.tmpl
 
 annotateline = '
diff -r 1bef6f99a12d -r fb5ca82f275a mercurial/templates/static/style-paper.css
--- a/mercurial/templates/static/style-paper.css	Thu May 23 17:53:38 2013 -0500
+++ b/mercurial/templates/static/style-paper.css	Fri May 31 12:25:09 2013 +0400
@@ -198,10 +198,9 @@
 .bigtable td.annotate { font-size: smaller; }
 .bigtable td.source { font-size: inherit; }
 
-.source, .sourcefirst, .sourcelast {
+.source {
   font-family: monospace;
-  white-space: pre;
-  padding: 1px 4px;
+  white-space: pre-wrap;
   font-size: 90%;
 }
 .sourcefirst { border-bottom: 1px solid #999; font-weight: bold; }
@@ -209,6 +208,39 @@
 .source a { color: #999; font-size: smaller; font-family: monospace;}
 .bottomline { border-bottom: 1px solid #999; }
 
+div.source, td.source { padding: 1px 4px; }
+
+ol {
+  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;
+  position: relative;
+  color: #000;
+  font-size: 111%;
+}
+
 .fileline { font-family: monospace; }
 .fileline img { border: 0; }
 


More information about the Mercurial-devel mailing list