background
When printing an article, a URL is included in the footer (inside .printfooter) at the bottom of the page.
For printed content, URLs in multiple languages can get quite lengthy. If a user were to enter the url manually from printed content, it would take quite a bit of time.
acceptance criteria
- Replace displayed URL for articles with short url
example:
For the article https://hi.wikipedia.org/wiki/%E0%A4%AD%E0%A5%82%E0%A4%B8%E0%A5%8D%E0%A4%A5%E0%A4%BF%E0%A4%B0_%E0%A4%89%E0%A4%AA%E0%A4%97%E0%A5%8D%E0%A4%B0%E0%A4%B9_%E0%A4%AA%E0%A5%8D%E0%A4%B0%E0%A4%95%E0%A5%8D%E0%A4%B7%E0%A5%87%E0%A4%AA%E0%A4%A3_%E0%A4%AF%E0%A4%BE%E0%A4%A8_%E0%A4%B8%E0%A4%82%E0%A4%B8%E0%A5%8D%E0%A4%95%E0%A4%B0%E0%A4%A3_3, display https://hi.wikipedia.org/s/anp3 versus https://hi.wikipedia.org/w/index.php?title=भू थर_उप ह_ ेपण_यान_स ं करण_3&oldid=3506997" से लया गया (current version in print styles)
Developer notes
- The URL in question is generated by Skin::printSource
- Short URLs are provided by extension Extension:ShortUrl
- The ShortUrl extension will need to communicate with Skin::printSource and replace the URL before it is outputted
Strawman proposals
Using GetCanonicalURL hook
There already exists a GetCanonicalURL hook called inside Title::getCanonicalURL. This is used in various places and a short url is probably not best used in this way.
Rely on JavaScript
Will not work without JS.
It also relies on $wgShortUrlReadOnly being enabled - which adds an element #t-shorturl containing the URL to the page HTML
New Hook
- We' add a hook to Skin::printSource e.g. Hook::run('getSkinPrintUrl')
- The hook can only be run once. If the hook is used more than once, then it's a race condition - whoever uses it last wins
- The hook when executed will return the value of the print url
- ShortUrl will use this hook
Config variable
Example: https://gerrit.wikimedia.org/r/376581
- We could also use a config variable that specifies the name of a static function that returns the title
- The static function is passed the $title
- ShortUrl can be configured to use this.
Other
..?