-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add extension registration This change: * adds extension.json (with backwards compatible loading from Purge.php); * fixes a possible conflict with a message name; * removes installation instructions etc. from README and points instead to the mediawiki.org page; and * removes the global variables from the navigation links hook. Bug: GH #3 * Some tweaks to @samwilson PR to prep for merge * Bumps to version b/c will need MW 1.31+ * Manifest version back to 2 and requires MW >= 1.31.0 Co-authored-by: Sam Wilson <[email protected]>
- Loading branch information
Showing
8 changed files
with
84 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,3 @@ | ||
## MediaWiki Purge Extension | ||
# MediaWiki Purge Extension | ||
|
||
Adds a Purge `&action=purge` link tab of regular articles to your MediaWiki Skin allowing quick purging of page caches. | ||
|
||
### Installation | ||
|
||
Download and upload the zip file to `/extensions` and extract. Rename directory folder `/Purge-#-#-#` to `/Purge` and add the following to `LocalSettings.php` to enable this extension. | ||
|
||
`require_once "$IP/extensions/Purge/Purge.php";` | ||
|
||
Control the ability by user group to purge content. eg `['*']` would allow anyone, `['user']` allows only users or `['sysop']` would only allow sysops. | ||
|
||
`$wgGroupPermissions['{a user group}']['purge'] = true; # delete the cache of a page` | ||
|
||
See https://www.mediawiki.org/wiki/Manual:Purge for more information about purging a page's cache. | ||
For more information, see [mediawiki.org/wiki/Extension:Purge](https://www.mediawiki.org/wiki/Extension:Purge). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{ | ||
"name": "Purge", | ||
"version": "2.0.0", | ||
"author": [ | ||
"[https://www.mediawiki.org/wiki/User:Ævar_Arnfjörð_Bjarmason Ævar Arnfjörð Bjarmason]", | ||
"[https://www.mediawiki.org/wiki/User:Hutchy68 Tom Hutchison]", | ||
"[https://www.mediawiki.org/wiki/User:Samwilson Sam Wilson]" | ||
], | ||
"url": "https://www.mediawiki.org/wiki/Extension:Purge", | ||
"descriptionmsg": "purge-descriptionmsg", | ||
"license-name": "GPL-2.0+", | ||
"type": "other", | ||
"requires": { | ||
"MediaWiki": ">= 1.31.0" | ||
}, | ||
"MessagesDirs": { | ||
"Purge": [ | ||
"i18n" | ||
] | ||
}, | ||
"ResourceModules": { | ||
"ext.purge": { | ||
"scripts": [ | ||
"resources/ext.purge.js" | ||
], | ||
"messages": [ | ||
"purge-failed" | ||
] | ||
} | ||
}, | ||
"ResourceFileModulePaths": { | ||
"localBasePath": "", | ||
"remoteExtPath": "Purge" | ||
}, | ||
"AutoloadClasses": { | ||
"MediaWiki\\Extension\\Purge\\Hooks": "includes/Hooks.php" | ||
}, | ||
"Hooks": { | ||
"SkinTemplateNavigation": "MediaWiki\\Extension\\Purge\\Hooks::onSkinTemplateNavigation" | ||
}, | ||
"manifest_version": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace MediaWiki\Extension\Purge; | ||
|
||
use SkinTemplate; | ||
|
||
class Hooks { | ||
|
||
/** | ||
* @link https://www.mediawiki.org/wiki/Manual:Hooks/SkinTemplateNavigation | ||
* @param SkinTemplate $sktemplate The skin template object. | ||
* @param array $links The existing structured navigation links. | ||
* @return bool | ||
*/ | ||
public static function onSkinTemplateNavigation( SkinTemplate &$sktemplate, array &$links ) { | ||
// Use getRelevantTitle if present so that this will work on some special pages | ||
$title = method_exists( $sktemplate, 'getRelevantTitle' ) | ||
? $sktemplate->getRelevantTitle() | ||
: $sktemplate->getTitle(); | ||
if ( $title->getNamespace() !== NS_SPECIAL && $sktemplate->getUser()->isAllowed( 'purge' ) ) { | ||
$sktemplate->getOutput()->addModules( 'ext.purge' ); | ||
$action = $sktemplate->getRequest()->getText( 'action' ); | ||
|
||
$links['actions']['purge'] = [ | ||
'class' => $action === 'purge' ? 'selected' : false, | ||
'text' => wfMessage( 'purge' )->text(), | ||
'href' => $title->getLocalUrl( 'action=purge' ) | ||
]; | ||
} | ||
|
||
return true; | ||
} | ||
} |