-
-
Notifications
You must be signed in to change notification settings - Fork 225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for accesskey shortcuts #684
base: master
Are you sure you want to change the base?
Conversation
HTML attribute `accesskey` [1] allows user to quickly navigate the website. Add support for `accesskey` to links of Gitit using the shortcut scheme of MediaWiki [2]. This would allow users who edit MediaWiki websites to more easily navigate Gitit webpages. Closes jgm#609 [1] https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/accesskey [2] Documented in detail on English Wikipedia, one of the main instances of MediaWiki: https://en.wikipedia.org/wiki/Wikipedia:Keyboard_shortcuts See also https://www.mediawiki.org/wiki/Manual:Access_keys and https://meta.wikimedia.org/wiki/Help:Keyboard_shortcuts
Document accesskey addition of previous commit in the "Help" page added to Gitit wikis by default. The descriptions are partially borrowed from English Wikipedia's page about similar MediaWiki feature, attribution to authors is of that page is at https://en.wikipedia.org/w/index.php?title=Wikipedia:Keyboard_shortcuts&action=history
CI on Windows failed because of haskell-hvr/missingh#59, it seems. |
I'm trying to upgrade the stack resolver, but it looks like we're stuck until hoauth2 puts out a release that works on text >= 2. |
else tabli ViewTab << anchor ! | ||
[href $ base' ++ urlForPage page ++ | ||
case rev of | ||
Just r -> "?revision=" ++ r | ||
Nothing -> ""] << "view" | ||
Nothing -> "", accesskey 'c'] << "view" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the current implementation (as of commit 94cb5a4) when looking at a revision of a page, the c accesskey is useless. There is no way to go from a revision to the current/latest version of the page, which MediaWiki supports. For example, on https://en.wikipedia.org/w/index.php?title=Human&oldid=1128628188 pressing the accesskey combination with c navigates to https://en.wikipedia.org/wiki/Human
After using this for a bit, I think it would be better to mimic MediaWiki and move accesskey="c"
to a link, which would always go to the current version of the page, i.e. something along these lines:
diff --git a/data/templates/content.st b/data/templates/content.st
index 0d1229d..9c39d64 100644
--- a/data/templates/content.st
+++ b/data/templates/content.st
@@ -2,7 +2,7 @@
$if(revision)$
<h2 class="revision">Revision $revision$ (click the page title to view the current version)</h2>
$endif$
- <h1 class="pageTitle"><a href="$base$$pageUrl$">$pagetitle$</a></h1>
+ <h1 class="pageTitle"><a href="$base$$pageUrl$" accesskey="c">$pagetitle$</a></h1>
<div class="subpages"><a href="../">< parent directory</a>
<a href="$base$$pageUrl$/">> this directory</a>
</div>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This, however, would not work for switching from discussion pages (e.g. @Sandbox
) to content pages. 🙁
Overview
Implementation of #609. See more details in the commit message of the first commit.
Notes
I didn't know where to put function
accesskey
, so there are two copies: one inHandlers.hs
and one inLayout.hs
. Perhaps it should go intosrc/Network/Gitit/Util.hs
? It doesn't seem to have any code related to HTML generation at the moment.I also don't know how exactly generation of default help page works, so I've just added new section "Keyboard shortcuts" to the bottom of
data/Help.page
. I wrote conservatively little about how keyboard shortcuts work, just referring the user to MediaWiki's manual, but I'm open to expanding the help text however you see fit.Testing
I've tested every accesskey locally by running Gitit from the repository:
I couldn't build the code as is (I get
Prelude.chr: bad argument: 1644167202
at the very end ofstack build
), but applying #683 locally fixed this issue for me.