Extension:TemplateStylesUnlimited
Release status: stable |
|
|---|---|
| Implementation | Parser extension |
| Description | Disables TemplateStyles sanitization, but restricts it to the MediaWiki namespace. |
| Author(s) | KockaAdmiralac talk |
| Compatibility policy | For every MediaWiki release that is a Long Term Support release there is a corresponding branch in the extension. |
| PHP | 8.2+ |
| Licence | GNU General Public License 2.0 or later |
| Download | GitHub:
Note: |
| Example | Undertale Wiki |
The TemplateStylesUnlimited extension modifies TemplateStyles behavior to remove any CSS sanitization, instead achieving security by restricting the Sanitized CSS content model to the MediaWiki namespace, such that only interface administrators can create them.
The advantage of this approach is that wiki administrators get the ability to granularly load styles without being restricted by TemplateStyles's sanitization. The disadvantage is that regular users lose the ability to write CSS stylesheets for content pages.
Installation
[edit ]- Install TemplateStyles first.
- Download and place the file(s) in a directory called
TemplateStylesUnlimitedin yourextensions/folder. - Add the following code at the bottom of your LocalSettings.php file:
wfLoadExtension( 'TemplateStylesUnlimited' );
- If you had any template style pages before, run
maintenance/run TemplateStylesUnlimited:FixContentModelsto fix their content models, otherwise you would be exposing yourself to security risks. - Yes Done – Navigate to
Special:Versionon your wiki to verify that the extension is successfully installed.
Configuration
[edit ]This extension offers no configuration options. However, you may be interested in configuring the following TemplateStyles options:
// .css subpages in the Template namespace should no longer attempt to default to the Sanitized CSS content model. $wgTemplateStylesNamespaces = []; // Since template style editing is restricted to interface administrators, you don't need to impose a styleshet limit on them. $wgTemplateStylesMaxStylesheetSize = null; // The default namespace for template styles should be the MediaWiki namespace. // However, you might still want to use the full CSS page names because of T424243. $wgTemplateStylesDefaultNamespace = 8;
Usage
[edit ]When you have TemplateStylesUnlimited installed, you can use TemplateStyles in the same way as before , with a few notable differences:
- You can use any CSS with no restrictions.
- CSS rules are no longer scoped to the page content and can affect other site elements.
- Your template style pages have to be in the MediaWiki namespace, e.g.
MediaWiki:Ambox.css. - After creating your template style page, you have to change its content model to Sanitized CSS in order for it to be loadable through
<templatestyles>. To do that, click on "Page information", then in the "Page content model" row select "change". - You will have to specify the full CSS page name in the
srcattribute.
See also
[edit ]- Extension:TemplateStylesExtender , which extends TemplateStyles's sanitization capabilities instead of entirely unrestricting them.