sapling/mercurial/hgweb
Gregory Szorc 28b7db089e 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
2017-09-30 09:01:36 +01:00
..
__init__.py server: move service factory from hgweb 2016-10-15 14:09:36 +09:00
common.py python3: wrap all uses of <exception>.strerror with strtolocal 2017-08-22 20:03:07 -04:00
hgweb_mod.py configitems: register the 'web.stripes' config 2017-06-30 03:45:51 +02:00
hgwebdir_mod.py py3: remove use of str() in hgwebdir 2017-09-27 19:04:32 +09:00
protocol.py httppeer: add support for httppostargs when we're sending a file 2017-07-26 17:58:19 -04:00
request.py hgweb: use absolute_import 2015-10-31 22:07:40 +09:00
server.py hgweb: remove superfluous pass statements 2017-09-30 07:44:20 -04:00
webcommands.py hgweb: add HTML elements to control whitespace settings for annotate 2017-09-30 09:01:36 +01:00
webutil.py hgweb: query string arguments to control whitespace for annotate 2017-09-30 09:08:01 +01:00
wsgicgi.py py3: replace os.environ with encoding.environ (part 3 of 5) 2016-12-18 01:54:36 +05:30