# HG changeset patch # User Anton Shestakov # Date 1442858950 -28800 # Node ID 2239626369f5d89a8c4a1b8dffe2dfcbe33d9012 # Parent 5c217bcc4597ae4d8cae4912a4c3db61e9ac6d0b gitweb: port code selection without line numbers from paper This is adapted from f2e4fdb3dd27 and e92d4b8530cb. It also fixes issue4790 in gitweb; tab characters now have meaningful width on the modified pages (file view, file diff, changeset). diff -r 5c217bcc4597 -r 2239626369f5 mercurial/templates/gitweb/changeset.tmpl --- a/mercurial/templates/gitweb/changeset.tmpl Sun Sep 13 22:34:58 2015 +0900 +++ b/mercurial/templates/gitweb/changeset.tmpl Tue Sep 22 02:09:10 2015 +0800 @@ -52,6 +52,6 @@ {files} -
{diff}
+
{diff}
{footer} diff -r 5c217bcc4597 -r 2239626369f5 mercurial/templates/gitweb/filerevision.tmpl --- a/mercurial/templates/gitweb/filerevision.tmpl Sun Sep 13 22:34:58 2015 +0900 +++ b/mercurial/templates/gitweb/filerevision.tmpl Tue Sep 22 02:09:10 2015 +0800 @@ -64,7 +64,7 @@
-{text%fileline} +
{text%fileline}
{footer} diff -r 5c217bcc4597 -r 2239626369f5 mercurial/templates/gitweb/map --- a/mercurial/templates/gitweb/map Sun Sep 13 22:34:58 2015 +0900 +++ b/mercurial/templates/gitweb/map Tue Sep 22 02:09:10 2015 +0800 @@ -93,9 +93,7 @@ filecomparison = filecomparison.tmpl filelog = filelog.tmpl fileline = ' -
-
{linenumber} {line|escape}
-
' + {strip(line|escape, '\r\n')}' annotateline = ' @@ -105,10 +103,14 @@
{linenumber}
{line|escape}
' -difflineplus = '{linenumber} {line|escape}' -difflineminus = '{linenumber} {line|escape}' -difflineat = '{linenumber} {line|escape}' -diffline = '{linenumber} {line|escape}' +difflineplus = ' + {strip(line|escape, '\r\n')}' +difflineminus = ' + {strip(line|escape, '\r\n')}' +difflineat = ' + {strip(line|escape, '\r\n')}' +diffline = ' + {strip(line|escape, '\r\n')}' comparisonblock =' @@ -223,7 +225,7 @@ files ' -diffblock = '
{lines}
' +diffblock = '
{lines}
' filediffparent = ' parent {rev} diff -r 5c217bcc4597 -r 2239626369f5 mercurial/templates/static/style-gitweb.css --- a/mercurial/templates/static/style-gitweb.css Sun Sep 13 22:34:58 2015 +0900 +++ b/mercurial/templates/static/style-gitweb.css Tue Sep 22 02:09:10 2015 +0800 @@ -29,9 +29,9 @@ a.list:hover { text-decoration:underline; color:#880000; } table { padding:8px 4px; } th { padding:2px 5px; font-size:12px; text-align:left; } -tr.light:hover, .parity0:hover { background-color:#edece6; } -tr.dark, .parity1 { background-color:#f6f6f0; } -tr.dark:hover, .parity1:hover { background-color:#edece6; } +tr.light:hover, .parity0:hover, pre.sourcelines.stripes > :nth-child(4n+1):hover { background-color:#edece6; } +tr.dark, .parity1, pre.sourcelines.stripes > :nth-child(4n+3) { background-color:#f6f6f0; } +tr.dark:hover, .parity1:hover, pre.sourcelines.stripes > :nth-child(4n+3):hover { background-color:#edece6; } td { padding:2px 5px; font-size:12px; vertical-align:top; } td.closed { background-color: #99f; } td.link { padding:2px 5px; font-family:sans-serif; font-size:10px; } @@ -87,6 +87,37 @@ span.difflineplus { color:#008800; } span.difflineminus { color:#cc0000; } span.difflineat { color:#990099; } +div.diffblocks { counter-reset: lineno; } +div.diffblock { counter-increment: lineno; } +pre.sourcelines { position: relative; counter-reset: lineno; } +pre.sourcelines > span { + display: inline-block; + box-sizing: border-box; + width: 100%; + padding: 0 0 0 5em; + counter-increment: lineno; +} +pre.sourcelines > span:before { + -moz-user-select: -moz-none; + -khtml-user-select: none; + -webkit-user-select: none; + -ms-user-select: none; + user-select: none; + display: inline-block; + margin-left: -5em; + width: 4em; + color: #999; + text-align: right; + content: counters(lineno,"."); + float: left; +} +pre.sourcelines > a { + display: inline-block; + position: absolute; + left: 0px; + width: 4em; + height: 1em; +} /* Graph */ div#wrapper { diff -r 5c217bcc4597 -r 2239626369f5 tests/test-hgweb.t --- a/tests/test-hgweb.t Sun Sep 13 22:34:58 2015 +0900 +++ b/tests/test-hgweb.t Tue Sep 22 02:09:10 2015 +0800 @@ -340,7 +340,7 @@ $ get-with-headers.py --twice localhost:$HGPORT 'static/style-gitweb.css' - date etag server 200 Script output follows - content-length: 5401 + content-length: 6242 content-type: text/css body { font-family: sans-serif; font-size: 12px; border:solid #d9d8d1; border-width:1px; margin:10px; } @@ -374,9 +374,9 @@ a.list:hover { text-decoration:underline; color:#880000; } table { padding:8px 4px; } th { padding:2px 5px; font-size:12px; text-align:left; } - tr.light:hover, .parity0:hover { background-color:#edece6; } - tr.dark, .parity1 { background-color:#f6f6f0; } - tr.dark:hover, .parity1:hover { background-color:#edece6; } + tr.light:hover, .parity0:hover, pre.sourcelines.stripes > :nth-child(4n+1):hover { background-color:#edece6; } + tr.dark, .parity1, pre.sourcelines.stripes > :nth-child(4n+3) { background-color:#f6f6f0; } + tr.dark:hover, .parity1:hover, pre.sourcelines.stripes > :nth-child(4n+3):hover { background-color:#edece6; } td { padding:2px 5px; font-size:12px; vertical-align:top; } td.closed { background-color: #99f; } td.link { padding:2px 5px; font-family:sans-serif; font-size:10px; } @@ -432,6 +432,37 @@ span.difflineplus { color:#008800; } span.difflineminus { color:#cc0000; } span.difflineat { color:#990099; } + div.diffblocks { counter-reset: lineno; } + div.diffblock { counter-increment: lineno; } + pre.sourcelines { position: relative; counter-reset: lineno; } + pre.sourcelines > span { + display: inline-block; + box-sizing: border-box; + width: 100%; + padding: 0 0 0 5em; + counter-increment: lineno; + } + pre.sourcelines > span:before { + -moz-user-select: -moz-none; + -khtml-user-select: none; + -webkit-user-select: none; + -ms-user-select: none; + user-select: none; + display: inline-block; + margin-left: -5em; + width: 4em; + color: #999; + text-align: right; + content: counters(lineno,"."); + float: left; + } + pre.sourcelines > a { + display: inline-block; + position: absolute; + left: 0px; + width: 4em; + height: 1em; + } /* Graph */ div#wrapper {