##// END OF EJS Templates
hgweb: add HTML elements to control whitespace settings for annotate...
Gregory Szorc -
r34392:6797f1fb default
parent child Browse files
Show More
@@ -930,6 +930,9 b' def annotate(web, req, tmpl):'
930 "linenumber": "% 6d" % (lineno + 1),
930 "linenumber": "% 6d" % (lineno + 1),
931 "revdate": f.date()}
931 "revdate": f.date()}
932
932
933 diffopts = webutil.difffeatureopts(req, web.repo.ui, 'annotate')
934 diffopts = {k: getattr(diffopts, k) for k in diffopts.defaults}
935
933 return tmpl("fileannotate",
936 return tmpl("fileannotate",
934 file=f,
937 file=f,
935 annotate=annotate,
938 annotate=annotate,
@@ -938,6 +941,7 b' def annotate(web, req, tmpl):'
938 rename=webutil.renamelink(fctx),
941 rename=webutil.renamelink(fctx),
939 permissions=fctx.manifest().flags(f),
942 permissions=fctx.manifest().flags(f),
940 ishead=int(ishead),
943 ishead=int(ishead),
944 diffopts=diffopts,
941 **webutil.commonentry(web.repo, fctx))
945 **webutil.commonentry(web.repo, fctx))
942
946
943 @webcommand('filelog')
947 @webcommand('filelog')
@@ -62,6 +62,13 b' annotate |'
62 </div>
62 </div>
63
63
64 <div class="page_path description">{desc|strip|escape|websub|nonempty}</div>
64 <div class="page_path description">{desc|strip|escape|websub|nonempty}</div>
65
66 {diffoptsform}
67
68 <script type="text/javascript"{if(nonce, ' nonce="{nonce}"')}>
69 renderDiffOptsForm();
70 </script>
71
65 <div class="page_body">
72 <div class="page_body">
66 <table>
73 <table>
67 <tbody class="sourcelines"
74 <tbody class="sourcelines"
@@ -334,3 +334,19 b" searchform = '"
334 </div>'
334 </div>'
335 searchhint = 'Find changesets by keywords (author, files, the commit message), revision
335 searchhint = 'Find changesets by keywords (author, files, the commit message), revision
336 number or hash, or <a href="{url|urlescape}help/revsets">revset expression</a>.'
336 number or hash, or <a href="{url|urlescape}help/revsets">revset expression</a>.'
337
338 diffoptsform = '
339 <form id="diffopts-form"
340 data-ignorews="{if(get(diffopts, 'ignorews'), '1', '0')}"
341 data-ignorewsamount="{if(get(diffopts, 'ignorewsamount'), '1', '0')}"
342 data-ignorewseol="{if(get(diffopts, 'ignorewseol'), '1', '0')}"
343 data-ignoreblanklines="{if(get(diffopts, 'ignoreblanklines'), '1', '0')}">
344 <span>Ignore whitespace changes - </span>
345 <span>Everywhere:</span>
346 <input id="ignorews-checkbox" type="checkbox" />
347 <span>Within whitespace:</span>
348 <input id="ignorewsamount-checkbox" type="checkbox" />
349 <span>At end of lines:</span>
350 <input id="ignorewseol-checkbox" type="checkbox" />
351 </form>
352 </div>'
@@ -65,6 +65,12 b''
65 </tr>
65 </tr>
66 </table>
66 </table>
67
67
68 {diffoptsform}
69
70 <script type="text/javascript"{if(nonce, ' nonce="{nonce}"')}>
71 renderDiffOptsForm();
72 </script>
73
68 <div class="overflow">
74 <div class="overflow">
69 <table class="bigtable">
75 <table class="bigtable">
70 <thead>
76 <thead>
@@ -251,3 +251,18 b" searchform = '"
251 </form>'
251 </form>'
252 searchhint = 'Find changesets by keywords (author, files, the commit message), revision
252 searchhint = 'Find changesets by keywords (author, files, the commit message), revision
253 number or hash, or <a href="{url|urlescape}help/revsets">revset expression</a>.'
253 number or hash, or <a href="{url|urlescape}help/revsets">revset expression</a>.'
254
255 diffoptsform = '
256 <form id="diffopts-form"
257 data-ignorews="{if(get(diffopts, 'ignorews'), '1', '0')}"
258 data-ignorewsamount="{if(get(diffopts, 'ignorewsamount'), '1', '0')}"
259 data-ignorewseol="{if(get(diffopts, 'ignorewseol'), '1', '0')}"
260 data-ignoreblanklines="{if(get(diffopts, 'ignoreblanklines'), '1', '0')}">
261 <span>Ignore whitespace changes - </span>
262 <span>Everywhere:</span>
263 <input id="ignorews-checkbox" type="checkbox" />
264 <span>Within whitespace:</span>
265 <input id="ignorewsamount-checkbox" type="checkbox" />
266 <span>At end of lines:</span>
267 <input id="ignorewseol-checkbox" type="checkbox" />
268 </form>'
@@ -434,6 +434,56 b' function ajaxScrollInit(urlFormat,'
434 scrollHandler();
434 scrollHandler();
435 }
435 }
436
436
437 function renderDiffOptsForm() {
438 // We use URLSearchParams for query string manipulation. Old browsers don't
439 // support this API.
440 if (!("URLSearchParams" in window)) {
441 return;
442 }
443
444 var form = document.getElementById("diffopts-form");
445
446 var KEYS = [
447 "ignorews",
448 "ignorewsamount",
449 "ignorewseol",
450 "ignoreblanklines",
451 ];
452
453 var urlParams = new URLSearchParams(window.location.search);
454
455 function updateAndRefresh(e) {
456 var checkbox = e.target;
457 var name = checkbox.id.substr(0, checkbox.id.indexOf("-"));
458 urlParams.set(name, checkbox.checked ? "1" : "0");
459 window.location.search = urlParams.toString();
460 }
461
462 var allChecked = form.getAttribute("data-ignorews") == "1";
463
464 for (var i = 0; i < KEYS.length; i++) {
465 var key = KEYS[i];
466
467 var checkbox = document.getElementById(key + "-checkbox");
468 if (!checkbox) {
469 continue;
470 }
471
472 currentValue = form.getAttribute("data-" + key);
473 checkbox.checked = currentValue != "0";
474
475 // ignorews implies ignorewsamount and ignorewseol.
476 if (allChecked && (key == "ignorewsamount" || key == "ignorewseol")) {
477 checkbox.checked = true;
478 checkbox.disabled = true;
479 }
480
481 checkbox.addEventListener("change", updateAndRefresh, false);
482 }
483
484 form.style.display = 'block';
485 }
486
437 document.addEventListener('DOMContentLoaded', function() {
487 document.addEventListener('DOMContentLoaded', function() {
438 process_dates();
488 process_dates();
439 }, false);
489 }, false);
@@ -97,6 +97,12 b' div.annotate-info {'
97 }
97 }
98 div.annotate-info a { color: #0000FF; text-decoration: underline; }
98 div.annotate-info a { color: #0000FF; text-decoration: underline; }
99 td.annotate:hover div.annotate-info { display: inline; }
99 td.annotate:hover div.annotate-info { display: inline; }
100
101 #diffopts-form {
102 padding-left: 8px;
103 display: none;
104 }
105
100 .linenr { color:#999999; text-decoration:none }
106 .linenr { color:#999999; text-decoration:none }
101 div.rss_logo { float: right; white-space: nowrap; }
107 div.rss_logo { float: right; white-space: nowrap; }
102 div.rss_logo a {
108 div.rss_logo a {
@@ -226,6 +226,13 b' div.annotate-info {'
226 div.annotate-info a { color: #0000FF; }
226 div.annotate-info a { color: #0000FF; }
227 td.annotate:hover div.annotate-info { display: inline; }
227 td.annotate:hover div.annotate-info { display: inline; }
228
228
229 #diffopts-form {
230 font-size: smaller;
231 color: #424242;
232 padding-bottom: 10px;
233 display: none;
234 }
235
229 .source, .sourcefirst {
236 .source, .sourcefirst {
230 font-family: monospace;
237 font-family: monospace;
231 white-space: pre;
238 white-space: pre;
@@ -340,7 +340,7 b' static file'
340
340
341 $ get-with-headers.py --twice localhost:$HGPORT 'static/style-gitweb.css' - date etag server
341 $ get-with-headers.py --twice localhost:$HGPORT 'static/style-gitweb.css' - date etag server
342 200 Script output follows
342 200 Script output follows
343 content-length: 9007
343 content-length: 9066
344 content-type: text/css
344 content-type: text/css
345
345
346 body { font-family: sans-serif; font-size: 12px; border:solid #d9d8d1; border-width:1px; margin:10px; background: white; color: black; }
346 body { font-family: sans-serif; font-size: 12px; border:solid #d9d8d1; border-width:1px; margin:10px; background: white; color: black; }
@@ -442,6 +442,12 b' static file'
442 }
442 }
443 div.annotate-info a { color: #0000FF; text-decoration: underline; }
443 div.annotate-info a { color: #0000FF; text-decoration: underline; }
444 td.annotate:hover div.annotate-info { display: inline; }
444 td.annotate:hover div.annotate-info { display: inline; }
445
446 #diffopts-form {
447 padding-left: 8px;
448 display: none;
449 }
450
445 .linenr { color:#999999; text-decoration:none }
451 .linenr { color:#999999; text-decoration:none }
446 div.rss_logo { float: right; white-space: nowrap; }
452 div.rss_logo { float: right; white-space: nowrap; }
447 div.rss_logo a {
453 div.rss_logo a {
@@ -284,6 +284,25 b' hgweb fileannotate, html'
284 </tr>
284 </tr>
285 </table>
285 </table>
286
286
287
288 <form id="diffopts-form"
289 data-ignorews="0"
290 data-ignorewsamount="0"
291 data-ignorewseol="0"
292 data-ignoreblanklines="0">
293 <span>Ignore whitespace changes - </span>
294 <span>Everywhere:</span>
295 <input id="ignorews-checkbox" type="checkbox" />
296 <span>Within whitespace:</span>
297 <input id="ignorewsamount-checkbox" type="checkbox" />
298 <span>At end of lines:</span>
299 <input id="ignorewseol-checkbox" type="checkbox" />
300 </form>
301
302 <script type="text/javascript">
303 renderDiffOptsForm();
304 </script>
305
287 <div class="overflow">
306 <div class="overflow">
288 <table class="bigtable">
307 <table class="bigtable">
289 <thead>
308 <thead>
General Comments 0
You need to be logged in to leave comments. Login now