jenkins-bot has submitted this change and it was merged.
Change subject: ORES extension as a beta feature
......................................................................
ORES extension as a beta feature
Beta icons are designed by May Galloway (User:MGalloway_(WMF))
and put in the bug page.
Bug: T125762
Change-Id: Ibc890cf4a80d78c381ed04362e00f31df8e8eaeb
---
M extension.json
M i18n/en.json
M i18n/qqq.json
A images/ORES-beta-features-ltr.png
A images/ORES-beta-features-rtl.png
M includes/Hooks.php
6 files changed, 65 insertions(+), 0 deletions(-)
Approvals:
Ladsgroup: Looks good to me, approved
jenkins-bot: Verified
diff --git a/extension.json b/extension.json
index 9eae0a2..17833cd 100644
--- a/extension.json
+++ b/extension.json
@@ -31,6 +31,9 @@
"EnhancedChangesListModifyLineData": [
"ORES\\Hooks::onEnhancedChangesListModifyLineData"
],
+ "GetBetaFeaturePreferences": [
+ "ORES\\Hooks::onGetBetaFeaturePreferences"
+ ],
"GetPreferences": [
"ORES\\Hooks::onGetPreferences"
],
diff --git a/i18n/en.json b/i18n/en.json
index e64bdad..5d9fce9 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -2,6 +2,8 @@
"@metadata": {
"authors": []
},
+ "ores-beta-feature-description": "ORES is an AI-based tool that
highlights probably damaging edits in recent changes and watchlist",
+ "ores-beta-feature-message": "ORES",
"ores-desc": "Expose automated revision scores in the interface",
"ores-damaging-filter": "$1 good edits",
"ores-damaging-hard": "Hard (more strict)",
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 12e0784..6bbc69b 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -5,6 +5,8 @@
"Purodha"
]
},
+ "ores-beta-feature-description": "Description of ORES in beta features
page.",
+ "ores-beta-feature-message": "Title of ORES section in beta features
page.",
"ores-desc": "Extension summary.",
"ores-damaging-filter": "Label to toggle filtering on ORES data.
Parameters:\n* $1 - Action to be performed by toggling. Can be either 'show' or
'hide'.",
"ores-damaging-hard": "Name of \"Hard\" threshold\n\nBasically, when
you set a threshold too soft, you give it a high number, so less edits will be
flagged for review but the chance of them being vandalism is higher. On the
other hand, when you set it too hard, it flags more edits. So you might catch
all vandalism, but proportion of vandalism would be less, and you see more
false positives (edits that are flagged for review but are completely okay).",
diff --git a/images/ORES-beta-features-ltr.png
b/images/ORES-beta-features-ltr.png
new file mode 100644
index 0000000..2444900
--- /dev/null
+++ b/images/ORES-beta-features-ltr.png
Binary files differ
diff --git a/images/ORES-beta-features-rtl.png
b/images/ORES-beta-features-rtl.png
new file mode 100644
index 0000000..644e4f2
--- /dev/null
+++ b/images/ORES-beta-features-rtl.png
Binary files differ
diff --git a/includes/Hooks.php b/includes/Hooks.php
index ed0c924..8408fc1 100644
--- a/includes/Hooks.php
+++ b/includes/Hooks.php
@@ -2,6 +2,7 @@
namespace ORES;
+use BetaFeatures;
use ChangesList;
use ChangesListSpecialPage;
use DatabaseUpdater;
@@ -55,6 +56,10 @@
* @param $filters
*/
public static function onChangesListSpecialPageFilters(
ChangesListSpecialPage $clsp, &$filters ) {
+ if ( self::oresEnabled( $clsp->getUser() ) === false ) {
+ return true;
+ }
+
$filters['hidenondamaging'] = array(
'msg' => 'ores-damaging-filter',
'default' => false,
@@ -78,6 +83,10 @@
$name, array &$tables, array &$fields, array &$conds,
array &$query_options, array &$join_conds, FormOptions $opts
) {
+ if ( self::oresEnabled() === false ) {
+ return true;
+ }
+
$threshold = self::getThreshold();
$tables[] = 'ores_classification';
@@ -117,6 +126,10 @@
public static function onEnhancedChangesListModifyLineData(
EnhancedChangesList $ecl, array &$data,
array $block, RCCacheEntry $rcObj
) {
+ if ( self::oresEnabled( $ecl->getUser() ) === false ) {
+ return true;
+ }
+
self::processRecentChangesList( $rcObj, $data );
return true;
@@ -132,6 +145,9 @@
public static function onEnhancedChangesListModifyBlockLineData(
EnhancedChangesList $ecl,
array &$data, RCCacheEntry $rcObj
) {
+ if ( self::oresEnabled( $ecl->getUser() ) === false ) {
+ return true;
+ }
self::processRecentChangesList( $rcObj, $data );
@@ -152,6 +168,10 @@
public static function onOldChangesListRecentChangesLine( ChangesList
&$changesList, &$s,
$rc, &$classes = array()
) {
+ if ( self::oresEnabled( $changesList->getUser() ) === false ) {
+ return true;
+ }
+
$damaging = self::getScoreRecentChangesList( $rc );
if ( $damaging ) {
$separator = ' <span class="mw-changeslist-separator">.
.</span> ';
@@ -216,6 +236,9 @@
public static function onGetPreferences( $user, &$preferences ) {
global $wgOresDamagingThresholds;
+ if ( self::oresEnabled( $user ) === false ) {
+ return true;
+ }
$options = array();
foreach ( $wgOresDamagingThresholds as $case => $value ) {
$text = wfMessage( 'ores-damaging-' . $case )->parse();
@@ -235,7 +258,42 @@
* Add CSS styles to output page
*/
public static function onBeforePageDisplay( OutputPage &$out, Skin
&$skin ) {
+ if ( self::oresEnabled( $out->getUser() ) === false ) {
+ return true;
+ }
$out->addModuleStyles( 'ext.ores.styles' );
return true;
}
+
+ /**
+ * Make a beta feature
+ */
+ public static function onGetBetaFeaturePreferences( $user, &$prefs ) {
+ global $wgExtensionAssetsPath;
+
+ $prefs['ores-enabled'] = array(
+ 'label-message' => 'ores-beta-feature-message',
+ 'desc-message' => 'ores-beta-feature-description',
+ 'screenshot' => array(
+ 'ltr' =>
"$wgExtensionAssetsPath/ORES/images/ORES-beta-features-ltr.png",
+ 'rtl' =>
"$wgExtensionAssetsPath/ORES/images/ORES-beta-features-rtl.png",
+ ),
+ 'info-link' =>
'https://www.mediawiki.org/wiki/Extension:ORES',
+ 'discussion-link' =>
'https://www.mediawiki.org/wiki/Extension_talk:ORES',
+ );
+ }
+
+ /**
+ * Check whether the user enabled ores as a beta feature
+ */
+ public static function oresEnabled( $user ) {
+ if ( $user === null ) {
+ global $wgUser;
+ $user = $wgUser;
+ }
+ if ( BetaFeatures::isFeatureEnabled( $user, 'ores-enabled' ) ) {
+ return true;
+ }
+ return false;
+ }
}
--
To view, visit https://gerrit.wikimedia.org/r/268345
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ibc890cf4a80d78c381ed04362e00f31df8e8eaeb
Gerrit-PatchSet: 6
Gerrit-Project: mediawiki/extensions/ORES
Gerrit-Branch: master
Gerrit-Owner: Ladsgroup <[email protected]>
Gerrit-Reviewer: Ladsgroup <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits