Page MenuHomePhabricator

Add instance-specific JavaScript and CSS
Closed, DeclinedPublic

Description

Motivation: If you maintain multiple MediaWiki instances, and you want them to share SOME, but not ALL, of the content in MediaWiki:Common.js and MediaWiki:Common.css, it is a royal pain.

Suggestion: For a given MediaWiki instance with $wgSitename = Foo, create these two system messages automatically:

MediaWiki:Foo.js
MediaWiki:Foo.css

Just like common.js and common.css, these would be loaded automatically on each page view, but ONLY for the given $wgSitename.

This would let you maintain the JS and CSS for a whole set of wikis in a single place, and only the one matching $wgSitename would be used.


Version: 1.16.x
Severity: enhancement

Details

Reference
bz22552

Event Timeline

bzimport raised the priority of this task from to Lowest.Nov 21 2014, 11:00 PM
bzimport set Reference to bz22552.
bzimport added a subscriber: Unknown Object (MLST).

One could just add something along the lines of importScript("mediawiki:" +wgDBname +".js"); to mediawiki:Common.js.

I personally can't see having yet another js page as being very useful outside of a very specific setup. (but that's just my personal opinion).

I'm with you on this one. It has very little application for most installs, and there's a viable workaround. WONTFIX.

Thanks for the workaround! That will work great.

The workaround doesn't work. "wgDBname" is not unique enough: you can have any number of wikis on various servers that use "wikidb" as the database name, for example. All of ours do.

If "wgSitename" were an available JS variable, that would work. But it isn't.

Also the workaround is only for JavaScript, not CSS.

Never mind about the CSS: I see how to do it:

importStylesheet("mediawiki:" +wgDBname +".css");

But the "wikidb" comment still stands.

Use wgServer.substring(7) if your database names are the same. (or some other variable depending on your set up. if they're same server different path you can use wgScriptPath).