This is an archive of the discontinued Mercurial Phabricator instance.

hgweb: add HTML elements to control whitespace settings for annotate
ClosedPublic

Authored by indygreg on Sep 30 2017, 4:08 AM.

Details

Summary

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.

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

indygreg created this revision.Sep 30 2017, 4:08 AM
simpkins accepted this revision.Oct 1 2017, 6:40 AM
simpkins added a subscriber: simpkins.

Looks fine to me, but I'm no HTML/JS expert.
dogscience

durin42 accepted this revision.Oct 1 2017, 6:40 AM
This revision is now accepted and ready to land.Oct 1 2017, 6:40 AM
This revision was automatically updated to reflect the committed changes.
yuja added a subscriber: yuja.Oct 1 2017, 8:57 AM
yuja added inline comments.
mercurial/templates/gitweb/map
352

Maybe extra </div>?