jenkins-bot has submitted this change and it was merged.
Change subject: Add the mediawiki.api.titleblacklist module
......................................................................
Add the mediawiki.api.titleblacklist module
Removed from mediawiki core in Ia5950853716.
Bug: 38244
Change-Id: I5bf7064ac6a82ed15e0589f255de4ef6c7349c4e
---
M TitleBlacklist.php
A modules/mediawiki.api.titleblacklist.js
2 files changed, 73 insertions(+), 0 deletions(-)
Approvals:
Krinkle: Looks good to me, approved
jenkins-bot: Verified
diff --git a/TitleBlacklist.php b/TitleBlacklist.php
index 20b022a..68fb677 100644
--- a/TitleBlacklist.php
+++ b/TitleBlacklist.php
@@ -77,4 +77,10 @@
$wgHooks['ArticleSaveComplete'][] = 'TitleBlacklistHooks::clearBlacklist';
$wgHooks['UserCreateForm'][] = 'TitleBlacklistHooks::addOverrideCheckbox';
+$wgResourceModules['mediawiki.api.titleblacklist'] = array(
+ 'scripts' => 'mediawiki.api.titleblacklist.js',
+ 'localBasePath' => $dir . '/modules',
+ 'remoteExtPath' => 'TitleBlacklist/modules',
+ 'dependencies' => array( 'mediawiki.api' ),
+);
// @}
diff --git a/modules/mediawiki.api.titleblacklist.js
b/modules/mediawiki.api.titleblacklist.js
new file mode 100644
index 0000000..63d1229
--- /dev/null
+++ b/modules/mediawiki.api.titleblacklist.js
@@ -0,0 +1,67 @@
+/**
+ * @class mw.Api.plugin.titleblacklist
+ */
+( function ( mw, $ ) {
+
+ $.extend( mw.Api.prototype, {
+ /**
+ * Convinience method for `action=titleblacklist`.
+ *
+ * @param {mw.Title|string} title
+ * @param {Function} [ok] Success callback (deprecated)
+ * @param {Function} [err] Error callback (deprecated)
+ * @return {jQuery.Promise}
+ * @return {Function} return.done
+ * @return {Object|boolean} return.done.result False if title
wasn't blacklisted, an object with 'reason', 'line'
+ * and 'message' properties if title was blacklisted.
+ */
+ isBlacklisted: function ( title, ok, err ) {
+ var d = $.Deferred();
+ // Backwards compatibility (< MW 1.20)
+ d.done( ok );
+ d.fail( err );
+
+ this.get( {
+ action: 'titleblacklist',
+ tbaction: 'create',
+ tbtitle: title.toString()
+ } )
+ .done( function ( data ) {
+ var result;
+
+ // this fails open (if nothing valid is
returned by the api, allows the title)
+ // also fails open when the API is not
present, which will be most of the time
+ // as this API module is part of the
TitleBlacklist extension.
+ if ( data.titleblacklist &&
data.titleblacklist.result && data.titleblacklist.result === 'blacklisted' ) {
+ if ( data.titleblacklist.reason
) {
+ result = {
+ reason:
data.titleblacklist.reason,
+ line:
data.titleblacklist.line,
+ message:
data.titleblacklist.message
+ };
+ } else {
+ mw.log(
'mw.Api.titleblacklist::isBlacklisted> no reason data for blacklisted title',
'debug' );
+ result = {
+ reason:
'Blacklisted, but no reason supplied',
+ line: 'Unknown',
+ message: null
+ };
+ }
+ d.resolve( result );
+ } else {
+ d.resolve( false );
+ }
+ } )
+ .fail( d.reject );
+
+ return d.promise();
+ }
+
+ } );
+
+ /**
+ * @class mw.Api
+ * @mixins mw.Api.plugin.titleblacklist
+ */
+
+}( mediaWiki, jQuery ) );
--
To view, visit https://gerrit.wikimedia.org/r/51962
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I5bf7064ac6a82ed15e0589f255de4ef6c7349c4e
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/TitleBlacklist
Gerrit-Branch: master
Gerrit-Owner: Alex Monk <[email protected]>
Gerrit-Reviewer: Hoo man <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits