Jump to content

User:Sohom Datta/protection indicators

From mediawiki.org
MediaWiki can now display a page indicator automatically while a page is protected. This feature is disabled by default. It can be enabled by community request .

Starting with 1.43.0-wmf.11, protection indicators that are small lock icons on the top of a page might show up when a page is protected depending on if the wiki is configured in a specific way.

Preparing for the change

[edit]

If your wiki already uses templates to show lock icons above protected pages before this change, the templates will need to be updated to work with this change. If your wiki does not have protection templates, feel free to skip this section

MediaWiki now expects the following output from the protection templates to be able to override the default icons.

<indicator name="protect-sysop">[[File:Foo.svg|20px]]</indicator>

Each protection template must emit a page status indicator with a name following the convention protect-<protectionlevel> where protectionlevel is the group a user must be a part of to be able to edit the page.

If a page is cascade-protected, the name of the icon will be protect-<protectionlevel>-cascade

Customizing protection indicators

[edit]

If your wiki wants to customize the indicator icons without using templates, this can be done by adding a few lines of CSS to the wiki's Common.css.

#mw-indicator-protection-sysop > a.mw-protection-indicator-icon--lock {
    background-color: rgba(0,0,0,0);
    mask-image: none !important;
    background-image: url('https://upload.wikimedia.org/wikipedia/en/thumb/4/44/Full-protection-shackle.svg/30px-Full-protection-shackle.svg.png');
    background-repeat: no-repeat;
    background-size: contain;
}

This code will replace the default icon for fully protected pages (pages that can only be edited by sysops) with the icon at File:Full-protection-shackle.svg. If you want to change the icon of a different protection level, you can do that by changing the first line like so #mw-indicator-protection-<protectionlevel> > a.mw-protection-indicator-icon--lock {

Additionally, the icon by default will link to Help:Protection on mediawiki however, this link can be customized per wiki per protection level by setting the associated help message (for full protection the message would be MediaWiki:protection-sysop-helppage).