Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/hgweb/webcommands.py @ 34392:6797f1fbc642
hgweb: add HTML elements to control whitespace settings for annotate
Building on top of the new URL query string arguments to control
whitespace settings for annotate, this commit adds HTML checkboxes
reflecting the values of these arguments to the paper and gitweb
themes.
The actual diff settings are now exported to the templating layer.
The HTML templates add these as data-* attributes so they are
accessible to the DOM.
A new <form> with various <input> elements is added. The <form>
is initially hidden via CSS. A shared JavaScript function (which
runs after the <form> has been rendered but before the annotate
HTML (because annotate HTML could take a while to load and we want
the form to render quickly) takes care of setting the checked state
of each box from the data-* attributes. It also registers an event
handler to modify the URL and refresh the page whenever the checkbox
state is changed.
I'm using the URLSearchParams interface to perform URL manipulation.
https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams tells
me this may not be supported on older web browsers. Yes, apparently
the web API didn't have a standard API to parse and format query
strings until recently. Hence the check for the presence of this
feature in the JavaScript. If the browser doesn't support the
feature, the <form> will remain hidden and behavior will like it
currently is. We could polyfill this feature or implement our own
query string parsing. But I'm lazy and this could be done as a
follow-up if people miss it.
We could certainly expand this feature to support more diff options
(such as lines of context). That's why the potentially reusable code
is stored in a reusable place. It is also certainly possible to
add diff controls to other pages that display diffs. But since
Mozillians are making noise about controlling which revisions
annotate shows, I figured I'd start there.
.. feature::
Control whitespace settings for annotation on hgweb
/annotate URLs on hgweb now accept query string arguments to
influence how whitespace changes impact results.
The arguments "ignorews," "ignorewsamount," "ignorewseol," and
"ignoreblanklines" now have the same meaning as their [annotate]
config section counterparts. Any provided setting overrides the
server default.
HTML checkboxes have been added to the paper and gitweb themes
to expose current whitespace settings and to easily modify the
current view.
Differential Revision: https://phab.mercurial-scm.org/D850
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sat, 30 Sep 2017 09:01:36 +0100 |
parents | f6492f482c60 |
children | 407ebe7a9b93 |
comparison
equal
deleted
inserted
replaced
34391:f6492f482c60 | 34392:6797f1fbc642 |
---|---|
928 "lineno": lineno + 1, | 928 "lineno": lineno + 1, |
929 "lineid": "l%d" % (lineno + 1), | 929 "lineid": "l%d" % (lineno + 1), |
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, |
936 path=webutil.up(f), | 939 path=webutil.up(f), |
937 symrev=webutil.symrevorshortnode(req, fctx), | 940 symrev=webutil.symrevorshortnode(req, fctx), |
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') |
944 def filelog(web, req, tmpl): | 948 def filelog(web, req, tmpl): |
945 """ | 949 """ |