Last modified: 2013-03-28 22:18:53 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T40598, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 38598 - Add HTML5 data attribute with wikititle for all links
Add HTML5 data attribute with wikititle for all links
Status: NEW
Product: MediaWiki
Classification: Unclassified
Interface (Other open bugs)
1.20.x
All All
: Low enhancement with 1 vote (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks: html5
  Show dependency treegraph
 
Reported: 2012-07-23 13:29 UTC by Fomafix
Modified: 2013-03-28 22:18 UTC (History)
4 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Fomafix 2012-07-23 13:29:46 UTC
Add HTML5 data attribute with wikititle, namespace and redirect target for all links on HTML5 enabled wikis. Suggested attribute names:

* data-mw-title for Wikititle
* data-mw-ns for namespace number
* data-mw-target for redirect target

Examples:

[[Wikimedia Commons]]
[[Wikipedia Commons]]
[[]]
[[Does not exist]]
[[Wikipedia:Sandbox]]

<a href="/wiki/Wikimedia_Commons"
   title="Wikimedia Commons"
   data-mw-title="Wikimedia Commons"
   data-mw-ns="0"
>Wikimedia Commons</a>
<a href="/wiki/Wikipedia_Commons"
   title="Wikipedia Commons"
   class="mw-redirect"
   data-mw-title="Wikipedia Commons"
   data-mw-ns="0"
   data-mw-target="Wikimedia Commons"
>Wikipedia Commons</a>
<a href="/wiki/%E2%82%AC"
   title="€"
   class="mw-redirect"
   data-mw-title="€"
   data-mw-ns="0"
   data-mw-target="Euro sign"
>€</a>
<a href="/w/index.php?title=Does_not_exist&amp;action=edit&amp;redlink=1"
   class="new"
   title="Does not exist (page does not exist)"
   data-mw-title="Does not exist"
   data-mw-ns="0"
>Does not exist</a>
<a href="/wiki/Wikipedia:Sandbox"
   title="Wikipedia:Sandbox"
   data-mw-title="Sandbox"
   data-mw-ns="4"
>Wikimedia Commons</a>
Comment 1 TMg 2012-07-24 01:16:18 UTC
Why do you need to *repeat* the title? It's already there.

Why do you need the namespace? It's already in the title. Why can't you use wgNamespaceIds to convert the namespace name to a number?

Also, there is an API to request everything you need. Why can't you use the API?
Comment 2 Steef 2012-07-24 09:19:17 UTC
The title is used to show the user a tooltip and gets modified from some userscripts, like HotCat. So if we add an data-Tag, it is useful to add the namespace-number. Of course you can extract namespace and pagename from the title or from the URL, but both can get easily changed at some point in the future or even modified before the script is running.

The API needs some parameters to be called, to get infos for a page you need at least the title, so you can't use it to request this information. Additionally, it is another request to the server that isn't necessary.

User:PerfektesChaos summarized this on dewiki too: //de.wikipedia.org/w/index.php?diff=105941306&oldid=105924999
Comment 3 Krinkle 2012-07-24 20:30:30 UTC
(In reply to comment #1)
> Why do you need to *repeat* the title? It's already there.
> 
> Why do you need the namespace? It's already in the title. Why can't you use
> wgNamespaceIds to convert the namespace name to a number?
> 
> Also, there is an API to request everything you need. Why can't you use the
> API?

See also mw.Title, which does all of that for you.

e.g. 
> var t = new mw.Title( 'Image: foo_bar quux.jpg ');
> t.getMain()
>< "Foo_bar_quux.jpeg"
> t.getNamespaceId()
>< 6
> t.getNamespacePrefix()
>< "File:"
> // etc..

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links