Page MenuHomePhabricator

Add custom classes to interwiki links per project within a wiki family
Closed, DeclinedPublic

Description

Author: alistrius

Description:
Hello. On fr.wikibooks we would like to differentiate the external links depending of the project they refeer to. Currently all the wikimedia internal links use the "exitw" class, so the only way to detect if they lead to wikipedia, wikisource... is to use a javascript for parse the href attribute.

it should be useful if wikipedia links have a "link-wikipedia" class, wikisource a "link-wikisource" class, etc.


Version: unspecified
Severity: enhancement

Details

Reference
bz14549

Event Timeline

bzimport raised the priority of this task from to Lowest.Nov 21 2014, 10:10 PM
bzimport added a project: MediaWiki-Parser.
bzimport set Reference to bz14549.
bzimport added a subscriber: Unknown Object (MLST).
bzimport created this task.Jun 15 2008, 6:01 PM

Actually it can be done with CSS3, supported by a number of the latest browsers.

a.exitw[href*=wikimedia.org]

or whatever ^= or *= you need to match the href. It doesn't need JS, CSS will work fine. It's already used for all the special icons like the mailto e-mail icon.

alistrius wrote:

but could it be implemented in the software anyway ? *= don't looks enough reliable to me. for example if the link is [[s:all about wikimedia.org]] the result could be quite unpredictable.

ayg wrote:

a.exitw[href^=http://meta.wikimedia.org/] or similar would work, except that the language code comes before the second-level domain name, so you'd have to list all languages individually. Thanks for being backwards, DNS. :(

Not sure this deserves yet another collection of classes.

alistrius wrote:

and it's not about hardwriting a "collection of classes" but more about generating classes dynamicly from the "sitematrix".

You can use a.exitw[href*=".wikipedia.org/wiki/"] selector. That's not perfect, but since having a couple of classes per project ([[s:Foo]] and [[wikisource:Foo]]) isn't much better, I think you better stick with it.