jgm / gitit

A wiki using HAppS, pandoc, and git
GNU General Public License v2.0
2.15k stars 225 forks source link

Support accesskey like Wikipedia #609

Open tim-janik opened 6 years ago

tim-janik commented 6 years ago

The $tabs$ generated by gitit are unfortunately not editable via tempates/ so I'm filing this as a bug. Please add the accesskey attribute to the default HTML generated by gitit, along the lines Wikipedia does it:

<a id="loginlink" class="login" href="/_login"    accesskey="o">
<li><a href="..."  accesskey="c"  >view</a>
<li><a href="..."  accesskey="e" >edit</a></li>
<li><a href="..."  accesskey="h" >history</a></li>
<li><a href="..."  accesskey="t"  >discuss</a></li>
<input name="patterns" id="patterns" type="text"                 accesskey="f" >
<input name="logMsg" id="logMsg" value="" type="text"                 accesskey="b" >
<input name="update" id="update" value="Save" type="submit"     accesskey="s"  >
<input class="editButton" id="previewButton" value="Preview" type="button" accesskey="p"  >
rybak commented 1 year ago

For reference, what English Wikipedia supports is described at https://en.wikipedia.org/wiki/Wikipedia:Keyboard_shortcuts

rybak commented 1 year ago

I haven't written Haskell in quite some time, so bare with me.

As an example, "edit" links on English Wikipedia use key e as accesskey. E.g. the main page has following HTML:

<a href="/w/index.php?title=Main_Page&amp;action=edit" title="This page is protected.
You can view its source [Alt+Shift+e]" accesskey="e"><span>View source</span></a>

In Gitit, the "edit" links have _edit in their URL, and it seems to be generated by these lines of code of Gitit: https://github.com/jgm/gitit/blob/eed32638f4f6e3b2f4b8a9a04c4b72001acf9ad8/src/Network/Gitit/Layout.hs#L146-L153

It seems that it uses the function anchor from Haskell module Text.XHtml.Strict of xhtml package. Same lines of code also use the href function. Unfortunately, documentation in xhtml package is a bit scarce, but it seems that it would be possible to add support of accesskey attribute via function strAttr.