Jump to content

User:Jdlrobson/Themes in MediaWiki

From mediawiki.org

Vector is the most popular MediaWiki skin. As a result most MediaWiki instances look identical in style to Wikipedia. There have been various attempts to make skins "theme-able" so that this is not the case. Examples include Extension:Theme (which allowed theming of Vector and MonoBook), Skin:Bluelib (which allow skins to operate with slightly different colors) and OOUI (which has Apex and Wikimedia themes). Another obvious application of themes is to support dark mode.

Goals

[edit]
  • We want the MediaWiki installer to look different from a production wiki
  • We want a single variables file shared by Vector 2022 and Minerva.
  • We want a default Minerva and Vector 2022 install to look different
  • It should be possible to substitute the variables file with a dark mode version.

How would a site configure a theme?

[edit]

It is my belief that themes should operate by defining a theme inside LocalSettings.php. The configured theme would apply to all skins. In future, it could also be influenced by a user preference (although this is out of scope for now).

Configuration might look a little like:

$wgDefaultSkin = 'vector';
// A theme would be defined by setting a registered theme name.
 $wgSkinTheme = 'default'
// $wgSkinTheme = 'wikimedia';
// $wgSkinTheme = 'dark';
// $wgSkinTheme = 'apex';
  • The default theme would be called "default" and would be setup by the installer. The default skin would not use Wikimedia colors.
  • On Wikimedia servers, we'd use the "wikimedia" skin.
  • If the skin theme defined in LocalSettings.php doesn't exist the default theme would be used.
  • A theme would work on all skins that make use of skin variables.
  • A skin can tag itself as not supporting themes. In which case, the SkinTheme configuration option would not have any effect.

How would this work behind the scenes?

[edit]

A theme would be installed in a similar way to skins and extensions. To install a theme, a folder would be installed inside the resources/src/mediawiki.less/ folder (in future this could be the themes/ folder). This folder would contain a mediawiki.skin.defaults file. The default MediaWiki install would have a wikimedia and default theme.

Currently, a skin can define a mediawiki.skin.variables file that extends a mediawiki.skin.defaults file. The location of the mediawiki.skin.defaults file is currently inside resources/src/mediawiki.less/, but with the proposed change, the directory searched will be influewnced by the wgSkinTheme variable.

A proof of concept demonstrating this approach is shown here: https://gerrit.wikimedia.org/r/c/mediawiki/core/+/821309


Anything else to note?

[edit]

It's important to note, that since Wikimedia code is open source, a 3rd party would still be able to use Wikimedia branded theme, unless the theme was made private, which would likely go against our values, but hopefully with a variety of well supported skins, we'd be discouraging it's usage/.