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

Alexander Plavin me at aplavin.ru
Fri May 31 05:51:53 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 88877f36f75166b4bd12317cf3f986b17ae8cf2c
# 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 88877f36f751 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
@@ -299,6 +299,9 @@
     """:shortdate: Date. Returns a date like "2006-09-18"."""
     return util.shortdate(text)
 
+def spaceifempty(text):
+    return text or ' '
+
 def stringescape(text):
     return text.encode('string_escape')
 
@@ -381,6 +384,7 @@
     "short": short,
     "shortbisect": shortbisect,
     "shortdate": shortdate,
+    "spaceifempty": spaceifempty,
     "stringescape": stringescape,
     "stringify": stringify,
     "strip": strip,
diff -r 1bef6f99a12d -r 88877f36f751 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 88877f36f751 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 88877f36f751 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