Polybuildr has uploaded a new change for review. https://gerrit.wikimedia.org/r/222918
Change subject: Display reason(s) for a page being marked as spam on special page ...................................................................... Display reason(s) for a page being marked as spam on special page Change-Id: Ie490df94f7ea67d4e66ae7c2ceed8f246bef918f --- M SmiteSpam.php M api/SmiteSpamApiQuery.php M i18n/en.json M i18n/qqq.json M includes/SmiteSpamAnalyzer.php M includes/SmiteSpamWikiPage.php M includes/checkers/SmiteSpamExternalLinksChecker.php M includes/checkers/SmiteSpamRepeatedExternalLinksChecker.php M includes/checkers/SmiteSpamWikitextChecker.php M static/js/ext.smitespam.retriever.js 10 files changed, 39 insertions(+), 5 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/SmiteSpam refs/changes/18/222918/1 diff --git a/SmiteSpam.php b/SmiteSpam.php index 289ff15..bb1a4da 100644 --- a/SmiteSpam.php +++ b/SmiteSpam.php @@ -48,6 +48,7 @@ 'powersearch-toggleall', 'powersearch-togglenone', 'smitespam-select', + 'smitespam-issues', ), ); diff --git a/api/SmiteSpamApiQuery.php b/api/SmiteSpamApiQuery.php index f421195..41243d7 100644 --- a/api/SmiteSpamApiQuery.php +++ b/api/SmiteSpamApiQuery.php @@ -78,7 +78,8 @@ 'creator' => $creator, 'spam-probability-value' => $page->spamProbability, 'spam-probability-text' => $spamProbability, - 'preview' => $previewText + 'preview' => $previewText, + 'issues' => implode( ", ", $page->spamReasons ), ); } diff --git a/i18n/en.json b/i18n/en.json index 41cac73..403a158 100644 --- a/i18n/en.json +++ b/i18n/en.json @@ -21,5 +21,9 @@ "smitespam-probability-medium": "Medium", "smitespam-probability-high": "High", "smitespam-probability-very-high": "Very high", - "smitespam-select": "Select: " + "smitespam-select": "Select: ", + "smitespam-externallinkschecker-msg": "Too many external links", + "smitespam-repeatedexternallinkschecker-msg": "Repeated external links", + "smitespam-wikitextchecker-msg": "Too little wikitext", + "smitespam-issues": "Issues" } diff --git a/i18n/qqq.json b/i18n/qqq.json index b17e47f..baf515c 100644 --- a/i18n/qqq.json +++ b/i18n/qqq.json @@ -23,5 +23,9 @@ "smitespam-probability-medium": "Medium probability\n{{Identical|Medium}}", "smitespam-probability-high": "High probability\n{{Identical|High}}", "smitespam-probability-very-high": "Very high probability", - "smitespam-select": "Followed by two links: {{msg-mw|Powersearch-toggleall}} and {{msg-mw|Powersearch-togglenone}} which respectively selects all pages and de-selects all pages\n{{Identical|Select}}" + "smitespam-select": "Followed by two links: {{msg-mw|Powersearch-toggleall}} and {{msg-mw|Powersearch-togglenone}} which respectively selects all pages and de-selects all pages\n{{Identical|Select}}", + "smitespam-externallinkschecker-msg": "Reason for being marked as spam by ExternalLinksChecker", + "smitespam-repeatedexternallinkschecker-msg": "Reason for being marked as spam by RepeatedExternalLinksChecker", + "smitespam-wikitextchecker-msg": "Reason for being marked as spam by WikitextChecker", + "smitespam-issues": "Title of a table column listing issues with a page" } diff --git a/includes/SmiteSpamAnalyzer.php b/includes/SmiteSpamAnalyzer.php index 908c9ed..691924d 100644 --- a/includes/SmiteSpamAnalyzer.php +++ b/includes/SmiteSpamAnalyzer.php @@ -83,6 +83,9 @@ $checker = 'SmiteSpam' . $checker . 'Checker'; $check = new $checker; $checkvalue = $check->getValue( $page ); + if ( $checkvalue > 1 ) { + $page->spamReasons[] = $check->getReasonMessage(); + } if ( $checkvalue !== false ) { $value += $checkvalue * $weight; $checkersUsed++; diff --git a/includes/SmiteSpamWikiPage.php b/includes/SmiteSpamWikiPage.php index 1d2014a..0f3cf32 100644 --- a/includes/SmiteSpamWikiPage.php +++ b/includes/SmiteSpamWikiPage.php @@ -16,6 +16,12 @@ public $spamProbability; /** + * An array of strings representing the reasons that the page was marked as spam + * @var array + */ + public $spamReasons; + + /** * @param int $pageID */ public function __construct( $pageID ) { @@ -25,6 +31,7 @@ } parent::__construct( $title ); $this->metadata = array(); + $this->spamReasons = array(); } /** diff --git a/includes/checkers/SmiteSpamExternalLinksChecker.php b/includes/checkers/SmiteSpamExternalLinksChecker.php index 9c189b4..aa25b7d 100644 --- a/includes/checkers/SmiteSpamExternalLinksChecker.php +++ b/includes/checkers/SmiteSpamExternalLinksChecker.php @@ -36,4 +36,8 @@ return 3; } } + + public function getReasonMessage() { + return wfMessage( 'smitespam-externallinkschecker-msg' )->text(); + } } diff --git a/includes/checkers/SmiteSpamRepeatedExternalLinksChecker.php b/includes/checkers/SmiteSpamRepeatedExternalLinksChecker.php index 710c5e3..006c4ee 100644 --- a/includes/checkers/SmiteSpamRepeatedExternalLinksChecker.php +++ b/includes/checkers/SmiteSpamRepeatedExternalLinksChecker.php @@ -42,4 +42,8 @@ return 3; } } + + public function getReasonMessage() { + return wfMessage( 'smitespam-repeatedexternallinkschecker-msg' )->text(); + } } diff --git a/includes/checkers/SmiteSpamWikitextChecker.php b/includes/checkers/SmiteSpamWikitextChecker.php index 6b048ac..f29ec0b 100644 --- a/includes/checkers/SmiteSpamWikitextChecker.php +++ b/includes/checkers/SmiteSpamWikitextChecker.php @@ -28,4 +28,8 @@ return 0; } } + + public function getReasonMessage() { + return wfMessage( 'smitespam-wikitextchecker-msg' )->text(); + } } diff --git a/static/js/ext.smitespam.retriever.js b/static/js/ext.smitespam.retriever.js index 9aa246d..4c62650 100644 --- a/static/js/ext.smitespam.retriever.js +++ b/static/js/ext.smitespam.retriever.js @@ -238,6 +238,7 @@ '<th>' + mw.msg( 'smitespam-page' ) + '</th>' + '<th>' + mw.msg( 'smitespam-probability' ) + '</th>' + '<th>' + mw.msg( 'smitespam-preview-text' ) + '</th>' + + '<th>' + mw.msg( 'smitespam-issues' ) + '</th>' + '<th>' + mw.msg( 'smitespam-delete' ) + '</th>' + '</tr>' ); for ( var j = 0; j < group.length; j++ ) { @@ -246,6 +247,7 @@ $( '<td></td>' ).html( page.link ).appendTo( $row ); $( '<td></td>' ).text( page['spam-probability-text'] ).appendTo( $row ); $( '<td></td>' ).text( page.preview ).appendTo( $row ); + $( '<td></td>' ).text( page.issues ).appendTo( $row ); if ( $.inArray( page.id.toString(), pagination.data.pagesDeleted ) !== -1 ) { $( '<td></td>' ).text( mw.msg( 'smitespam-delete-page-success-msg' ) ).appendTo( $row ); } else if ( $.inArray( page.id.toString(), pagination.data.failedToDeletePages ) !== -1 ) { @@ -287,12 +289,12 @@ if ( 'delete' in data ) { pagination.data.pagesDeleted.push( pageID ); if ( row.length ) { - row.find( 'td' ).eq( 3 ).text( mw.msg( 'smitespam-delete-page-success-msg' ) ); + row.find( 'td' ).eq( 4 ).text( mw.msg( 'smitespam-delete-page-success-msg' ) ); } } else if ( 'error' in data ) { pagination.data.failedToDeletePages.push( pageID ); if ( row.length ) { - row.find( 'td' ).eq( 3 ).text( mw.msg( 'smitespam-delete-page-failure-msg' ) ); + row.find( 'td' ).eq( 4 ).text( mw.msg( 'smitespam-delete-page-failure-msg' ) ); } } deleteIndex++; -- To view, visit https://gerrit.wikimedia.org/r/222918 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie490df94f7ea67d4e66ae7c2ceed8f246bef918f Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/SmiteSpam Gerrit-Branch: master Gerrit-Owner: Polybuildr <v.a.ghai...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits