Last modified: 2011-03-13 18:06:21 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 T27729, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 25729 - Add a {{CURRENTSKIN}} variable to wikitext
Add a {{CURRENTSKIN}} variable to wikitext
Status: RESOLVED WONTFIX
Product: MediaWiki extensions
Classification: Unclassified
ParserFunctions (Other open bugs)
unspecified
All All
: Lowest enhancement (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2010-10-31 19:17 UTC by MC10
Modified: 2011-03-13 18:06 UTC (History)
8 users (show)

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


Attachments

Description MC10 2010-10-31 19:17:10 UTC
I am asking if a #switchskin ParserFunction can be added, which basically does the following:

{{#switchskin:
  |monobook=text displayed if Monobook is used
  |vector=text displayed if Vector is used
  |#default=text displayed if any other skin is used
}}

This ParserFunction should be similar to how #switch is used, but is switched by the skin a user/IP is using. It would be useful to display different versions of CSS for different skins, as skins implement CSS differently. It can also be used to display different messages to different skin users.
Comment 1 Casey Brown 2010-10-31 19:21:24 UTC
It would probably be better to create new skin-specific magic words for things like the user's current skin and the wiki's default skin.  Then you could just use the existing ParserFunction and do something like {{#switch:{{CURRENTSKIN}}|monobook=bleh|#default=bleh2}}.
Comment 2 MC10 2010-11-01 01:49:29 UTC
That actually is a good idea. I'll open a new bug request. Can you close this for me?
Comment 3 Bawolff (Brian Wolff) 2010-11-01 11:05:06 UTC
Since they're essentially asking for the same feature (or to solve the same usecase), and everyone who's commented seems to like the magic word method, its probably fine to just rename this. (which I just did)


As an aside, this feature sounds like something that would have a (possibly negative) affect on how caching works, but I don't really know enough about how parser cache works to comment on that.
Comment 4 Roan Kattouw 2010-11-01 12:49:57 UTC
(In reply to comment #3)
> As an aside, this feature sounds like something that would have a (possibly
> negative) affect on how caching works, but I don't really know enough about how
> parser cache works to comment on that.
The parser cache code would have to be tweaked a bit such that a different version if cached for each skin if {{CURRENTSKIN}} is used on the page. I don't think that's terribly hard to do; Platonides would know, I think, CCing him. As for performance: I don't think it'd have a large impact as long as {{CURRENTSKIN}} isn't used on lots and lots of pages.
Comment 5 Platonides 2010-11-01 18:57:11 UTC
I am not convinced about the usecase for adding such parserfunction in core.

You want to give a slightly different style to a table (eg. footballer infobox) depending on the skin. Given how these things expand, this would ultimately lead to hundred of pages with skin variants.
However, there's another way to get the same effect which doesn't require splitting the cache: use a class in the infobox, then customize the styles in MediaWiki:Vector.css, MediaWiki:Monobook.css...

I don't think there will be too much use for message customization either. Take into account that internal messages can provide the skin as a parameter if needed, so only wiki instruction would need it.

However, it reduces reviewing. An addition of {{#ifeq:{{CURRENTSKIN}}|cologneblue | <profanity here> }} inside a biography would be hardly noticed unless viewing the wikitext, while still providing the vandal a way to advertise it using the useskin parameter.

Skin style customization via the skin css page, although harder for non-admins, is much safer.
Comment 6 MC10 2010-11-02 00:32:49 UTC
Actually, shouldn't those already be detected by anti-vandalism tools/bots? It doesn't exactly matter whether or not it's in a #ifeq: or not. If it's not detected by anti-vandalism tools, it may be a bit harder to remove, but it shouldn't be too difficult for someone who searches up "<profanity here>" to remove it.

It may be possible to use MediaWiki:<skin>.css, but as a non-admin, it is a bit more difficult to make changes.
Comment 7 Alex Z. 2010-11-02 00:43:13 UTC
How would this respond when there's no skin? The only situations I can think of would be action=parse in the API and action=render via index.php, though parsed system messages might also be affected. 

I agree with Platonides though, if the main use is styling, we have skin-specific CSS for this already. And when it comes to the English Wikipedia "they probably won't use it too much" is almost never a safe assumption.
Comment 8 Platonides 2010-11-02 17:19:39 UTC
> It may be possible to use MediaWiki:<skin>.css, but as a non-admin, it is a bit
> more difficult to make changes.
I am aware of such inconvenience, but despite of it, still seems a better system.


> not it's in a #ifeq: or not. If it's not
> detected by anti-vandalism tools, it may be a bit harder to remove, but it
> shouldn't be too difficult for someone who searches up "<profanity here>" to
> remove it.

Until you get that profanity included in a template included only for a few uncommon skins from a template three levels deep. Which makes me thing, including links or templates under a {{CURRENTSKIN}} branch would produce another instance 
into bug 14404.
Comment 9 MC10 2010-11-07 05:13:55 UTC
(In reply to comment #7)
> How would this respond when there's no skin? The only situations I can think of
> would be action=parse in the API and action=render via index.php, though parsed
> system messages might also be affected. 

#default should be triggered if there is no skin, since it will not match any of the test cases.
Comment 10 Platonides 2010-11-07 21:00:17 UTC
That may seem logical to you, but the fact is, it would use your default skin.
Comment 11 Daniel Friesen 2011-01-14 00:02:39 UTC
This would fragment the cache even more. Imho something like this that fragments the cache with little extra purpose should be isolated to an extension.
Comment 12 Krinkle 2011-03-08 08:49:56 UTC
Suggesting LATER or WONTFIX per the mentioned problems and complexity with parser cache and linking tables.

If the usecase is style, contact your wiki admin and ask him to add some css-classes to MediaWiki:Common.css.

The root tag of all MediaWiki-pages contains (among others) a class for the current skin.

<body class="mediawiki ltr ns-0 ns-subject page-Sandbox skin-vector">

so, something like the following should work fine if you really need something in the wiki to be skin-dependend. Add the following to MediaWiki:Vector.css

/* Make the table of contents white-on-black in Monobook! */
#toc { background-color: black; color: white; }

or if you have several different colors for different skins, it may be easier to keep them together, instead the following in MediaWiki:Common.css

/* Funky wikitables */
.mediawiki .wikitable td { background-color: black; /* default */ }
.skin-vector .wikitable td { background-color: #8da7d6 }
.skin-monobook .wikitable td { background-color: #00FF00 }

Or if you *really* need to switch the actual article contents (usecase example?) even this would work:

Template:SkinSwitch

<div class="skinswitch skinswitch-vector">{{{vector|}}}</div>
<div class="skinswitch skinswitch-monobook">{{{monobook|}}}</div>
<div class="skinswitch skinswitch-default">{{{default|}}}</div>

MediaWiki:Common.css
.skinswitch { display: none; }
.skinswitch-default { display: block; }

.skin-vector .skinswitch-default,
.skin-monobook .skinswitch-default { display: none; }

.skin-vector .skinswitch-vector,
.skin-monobook .skinswitch-monobook { display: block; }

User:Example

{{SkinSwitch
|vector=Hello fellow Vectorians,
|monobook=Howdy Monobooky,
|default=Hi there,
}}
Comment 13 Max Semenik 2011-03-08 09:05:50 UTC
Closing per Krinkle. The only use case presented is non-admin styling of templates, hovewer all popular templates on large wikis are protected anyway.

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


Navigation
Links