Last modified: 2011-08-14 18:26:39 UTC
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.
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.
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.
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.
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.