Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix to JS to Purge in place #29

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## Version 3.0.0

* Bump major version as it requires MW 1.35+

## Version 2.0.0

* Add extension registration.
Expand Down
4 changes: 2 additions & 2 deletions extension.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Purge",
"version": "2.0.0",
"version": "3.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]",
Expand All @@ -11,7 +11,7 @@
"license-name": "GPL-2.0+",
"type": "other",
"requires": {
"MediaWiki": ">= 1.31.0"
"MediaWiki": ">= 1.35.0"
},
"MessagesDirs": {
"Purge": [
Expand Down
6 changes: 4 additions & 2 deletions i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"Ævar Arnfjörð Bjarmason\r */\r"
]
},
"purge": "Purge",
"purge": "Purge cache",
"purge-descriptionmsg": "Adds a purge tab on all normal pages allowing for quick purging of the cache",
"purge-failed": "Purge failed"
"purge-failed": "Cache Purge failed",
"tooltip-n-purge-ext": "Purge the cache for this page",
"accesskey-n-purge-ext": "~"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why have -n- in these messages?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because that’s the appropriate message key for tooltip and quick access key. -n- is needed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The -n- in other messages means 'navigation' and is used for items e.g. in the sidebar. If any shorthand should be used, it'd be -ca-, but really there's no need outside of core.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm that’s weird I said n but added another comment right after mentioning -ca- then pushed a change making them ca.

I see in some extensions not used, but in others it is.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah no worries, -ca- is good :)

}
6 changes: 4 additions & 2 deletions i18n/qqq.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
"The Evil IP address"
]
},
"purge": "Displayed as a label in the action menu.\n{{Identical|Purge}}",
"purge": "Displayed as a label in the action menu.\n{{Identical|Purge cache}}",
"purge-descriptionmsg": "{{desc|name=Purge|url=https://www.mediawiki.org/wiki/Extension:Purge}}\n\"purge\" refers to {{msg-mw|purge}}.",
"purge-failed": "Displayed when the POST request to purge did not succeed."
"purge-failed": "Displayed when the POST request to purge did not succeed.",
"tooltip-n-purge-ext": "Tooltip of the dedicated \"Purge\" action.\n{{Identical|Purge cache}}",
"accesskey-n-purge-ext": "{{doc-accesskey}}"
}
6 changes: 4 additions & 2 deletions includes/Hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ public static function onSkinTemplateNavigation( SkinTemplate &$sktemplate, arra
$sktemplate->getOutput()->addModules( 'ext.purge' );
$action = $sktemplate->getRequest()->getText( 'action' );

$links['actions']['purge'] = [
$links['actions']['purge-ext'] = [
'class' => $action === 'purge' ? 'selected' : false,
'text' => wfMessage( 'purge' )->text(),
'href' => $title->getLocalUrl( 'action=purge' )
'href' => $title->getLocalUrl( 'action=purge' ),
'title' => wfMessage( 'Tooltip-n-purge-ext' )->text(),
'accesskey' => wfMessage( 'Accesskey-n-purge-ext' )->text()
];
}

Expand Down
4 changes: 2 additions & 2 deletions resources/ext.purge.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

mw.loader.using( [ 'mediawiki.api', 'mediawiki.notify' ] ).then( function () {
mw.loader.using( [ 'mediawiki.api' ] ).then( function () {

$( "#ca-purge a" ).on( 'click', function ( e ) {
$( "#ca-purge-ext a" ).on( 'click', function ( e ) {
var postArgs = { action: 'purge', titles: mw.config.get( 'wgPageName' ) };
new mw.Api().post( postArgs ).then( function () {
location.reload();
Expand Down