Re: [PATCH] gitweb: Don't append ';js=(0|1)' to external links
- From
Jakub Narebski <jnareb@gmail.com>
- Date
- Dec 2, 2011, 20:44 UTC
- Message-ID
- <201112022144.45531.jnareb@gmail.com>
- In-Reply-To
- <CAKD0UuyH3m0RR2=jk5apFjVMgbD5iWeztR94mE-m7q9dyYKR2Q@mail.gmail.com>
On Tue, 29 Nov 2011, Jürgen Kreileder wrote:
Show 9 quoted lines
> On Tue, Nov 29, 2011 at 20:28, Jakub Narebski <jnareb@gmail.com> wrote: > > Jürgen Kreileder <jk@blackdown.de> writes: > [...] > > Thanks for this, but I think a better solution would be to explicitly > > mark the few external links we have e.g. with 'class="external"', and > > use that to avoid adding ';js=(0|1)' to them. > > This won't work because there are more than a few external links. Think of > links added in the header or footer or via a project specific README.html.
Thanks for noticing that.
> You would have to do it the other way round: Mark all internal links.
In this case your solution is better... provided that you either check that all internal links generated by gitweb are absolute URLs in all cases (they always include $my_url), or add ';js=(0|1)' also for relative URLs (i.e. not starting with http:// or https://).
Well... the "mark external" idea would also work, provided that we rework
how ';js=(0|1)' is generated. Instead of fixing links on load, we could
add an event handler[1] which on clicking the link[2] would add
';js=(0|1)'... and there you can check if we are inside README.html etc.
by examining DOM (perhaps those externally added fragments would need to
be wrapped in div / span with "external" class, though).
[1] You assign event handler to 'html' or 'body' element, and check in
handler where you clicked; that is what we do for JavaScript
timezone stuff.[2] I am not sure if "Open in new tab" from context menu or Ctrl-Click
would trigger adding ';js=(0|1)' or not... and whether it is a bad
thing or not.> > This has the advantage that we can use different style to mark > > outgoing external links.
I think this advantage might be worth it, even without changes to javascript-detection.js
-- Jakub Narebski Poland