Merge "Remove the BetaFeatures integration"

This commit is contained in:
jenkins-bot 2019-05-08 21:52:39 +00:00 committed by Gerrit Code Review
commit d0c446c9b8
9 changed files with 13 additions and 133 deletions

View file

@ -2,18 +2,4 @@
$cfg = require __DIR__ . '/../vendor/mediawiki/mediawiki-phan-config/src/config.php'; $cfg = require __DIR__ . '/../vendor/mediawiki/mediawiki-phan-config/src/config.php';
$cfg['directory_list'] = array_merge(
$cfg['directory_list'],
[
'../../extensions/BetaFeatures',
]
);
$cfg['exclude_analysis_directory_list'] = array_merge(
$cfg['exclude_analysis_directory_list'],
[
'../../extensions/BetaFeatures',
]
);
return $cfg; return $cfg;

View file

@ -86,12 +86,6 @@ $wgMediaViewerDimensionLoggingSamplingFactor = false;
*/ */
$wgMediaViewerActionLoggingSamplingFactorMap = false; $wgMediaViewerActionLoggingSamplingFactorMap = false;
/**
* If set, Media Viewer will try to use BetaFeatures. False if unset.
* @var bool
*/
$wgMediaViewerIsInBeta = false;
/** /**
* When this is enabled, MediaViewer will try to guess image URLs instead of making an * When this is enabled, MediaViewer will try to guess image URLs instead of making an
* imageinfo API to get them from the server. This speeds up image loading, but will * imageinfo API to get them from the server. This speeds up image loading, but will
@ -106,8 +100,7 @@ $wgMediaViewerIsInBeta = false;
$wgMediaViewerUseThumbnailGuessing = false; $wgMediaViewerUseThumbnailGuessing = false;
/** /**
* If trueish, and $wgMediaViewerIsInBeta is unset, * If true, Media Viewer will be turned on by default.
* Media Viewer will be turned on by default.
* @var bool * @var bool
*/ */
$wgMediaViewerEnableByDefault = true; $wgMediaViewerEnableByDefault = true;

View file

@ -462,9 +462,6 @@
"GetPreferences": [ "GetPreferences": [
"MultimediaViewerHooks::getPreferences" "MultimediaViewerHooks::getPreferences"
], ],
"GetBetaFeaturePreferences": [
"MultimediaViewerHooks::getBetaPreferences"
],
"BeforePageDisplay": [ "BeforePageDisplay": [
"MultimediaViewerHooks::getModulesForArticle" "MultimediaViewerHooks::getModulesForArticle"
], ],
@ -497,7 +494,6 @@
"MediaViewerAttributionLoggingSamplingFactor": false, "MediaViewerAttributionLoggingSamplingFactor": false,
"MediaViewerDimensionLoggingSamplingFactor": false, "MediaViewerDimensionLoggingSamplingFactor": false,
"MediaViewerActionLoggingSamplingFactorMap": false, "MediaViewerActionLoggingSamplingFactorMap": false,
"MediaViewerIsInBeta": false,
"MediaViewerUseThumbnailGuessing": false, "MediaViewerUseThumbnailGuessing": false,
"MediaViewerEnableByDefault": true, "MediaViewerEnableByDefault": true,
"MediaViewerEnableByDefaultForAnonymous": null, "MediaViewerEnableByDefaultForAnonymous": null,

View file

@ -5,8 +5,6 @@
] ]
}, },
"multimediaviewer-desc": "Expand thumbnails in a larger size in a fullscreen interface", "multimediaviewer-desc": "Expand thumbnails in a larger size in a fullscreen interface",
"multimediaviewer-pref": "Media Viewer",
"multimediaviewer-pref-desc": "Improve your multimedia viewing experience with this new tool. It displays images in larger size on pages that have thumbnails. Images are shown in a nicer fullscreen interface overlay, and can also be viewed in full-size.",
"multimediaviewer-optin-pref": "Enable <span class=\"plainlinks\">[https://www.mediawiki.org/wiki/Special:MyLanguage/Extension:Media_Viewer/About Media Viewer]</span>", "multimediaviewer-optin-pref": "Enable <span class=\"plainlinks\">[https://www.mediawiki.org/wiki/Special:MyLanguage/Extension:Media_Viewer/About Media Viewer]</span>",
"multimediaviewer-file-page": "Go to corresponding file page", "multimediaviewer-file-page": "Go to corresponding file page",
"multimediaviewer-repository-local": "More details", "multimediaviewer-repository-local": "More details",

View file

@ -16,9 +16,7 @@
] ]
}, },
"multimediaviewer-desc": "{{desc|name=Multimedia Viewer|url=https://www.mediawiki.org/wiki/Extension:MultimediaViewer}}", "multimediaviewer-desc": "{{desc|name=Multimedia Viewer|url=https://www.mediawiki.org/wiki/Extension:MultimediaViewer}}",
"multimediaviewer-pref": "Preference title", "multimediaviewer-optin-pref": "Label for preference to enable the Media Viewer.",
"multimediaviewer-pref-desc": "Description of preference",
"multimediaviewer-optin-pref": "Label for non-beta preference.",
"multimediaviewer-file-page": "Text for a link to the file page for an image.", "multimediaviewer-file-page": "Text for a link to the file page for an image.",
"multimediaviewer-repository-local": "Link to repository where the image is locally hosted.\nSee also:\n* {{msg-mw|multimediaviewer-repository}}", "multimediaviewer-repository-local": "Link to repository where the image is locally hosted.\nSee also:\n* {{msg-mw|multimediaviewer-repository}}",
"multimediaviewer-datetime-created": "Used in JavaScript code. Parameters:\n* $1 - time and date\nSee also:\n* {{msg-mw|Multimediaviewer-datetime-uploaded}}\n\nNote that the date comes from the description page and can have various forms (e.g. \"2000-01-01\", \"1st January 2000\", \"1492\", \"16th century\"...)\n\nAlso, this might refer to the date when the picture was taken, or the date when the depcited work was made - the usage is not consistent. You should choose a translation that works in all cases.\n{{Identical|Created}}", "multimediaviewer-datetime-created": "Used in JavaScript code. Parameters:\n* $1 - time and date\nSee also:\n* {{msg-mw|Multimediaviewer-datetime-uploaded}}\n\nNote that the date comes from the description page and can have various forms (e.g. \"2000-01-01\", \"1st January 2000\", \"1492\", \"16th century\"...)\n\nAlso, this might refer to the date when the picture was taken, or the date when the depcited work was made - the usage is not consistent. You should choose a translation that works in all cases.\n{{Identical|Created}}",

View file

@ -50,13 +50,9 @@ class MultimediaViewerHooks {
* @return bool * @return bool
*/ */
protected static function shouldHandleClicks( $user ) { protected static function shouldHandleClicks( $user ) {
global $wgMediaViewerIsInBeta, $wgMediaViewerEnableByDefaultForAnonymous, global $wgMediaViewerEnableByDefaultForAnonymous,
$wgMediaViewerEnableByDefault; $wgMediaViewerEnableByDefault;
if ( $wgMediaViewerIsInBeta && ExtensionRegistry::getInstance()->isLoaded( 'BetaFeatures' ) ) {
return BetaFeatures::isFeatureEnabled( $user, 'multimedia-viewer' );
}
if ( $wgMediaViewerEnableByDefaultForAnonymous === null ) { if ( $wgMediaViewerEnableByDefaultForAnonymous === null ) {
$enableByDefaultForAnons = $wgMediaViewerEnableByDefault; $enableByDefaultForAnons = $wgMediaViewerEnableByDefault;
} else { } else {
@ -85,7 +81,7 @@ class MultimediaViewerHooks {
/** /**
* Handler for BeforePageDisplay hook * Handler for BeforePageDisplay hook
* Add JavaScript to the page when an image is on it * Add JavaScript to the page when an image is on it
* and the user has enabled the feature if BetaFeatures is installed * and the user has enabled the feature
* @param OutputPage &$out * @param OutputPage &$out
* @param Skin &$skin * @param Skin &$skin
* @return bool * @return bool
@ -127,51 +123,16 @@ class MultimediaViewerHooks {
} }
/** /**
* Add a beta preference to gate the feature * Adds a default-enabled preference to gate the feature
* @param User $user * @param User $user
* @param array &$prefs * @param array &$prefs
* @return true
*/
public static function getBetaPreferences( $user, &$prefs ) {
global $wgExtensionAssetsPath, $wgMediaViewerIsInBeta;
if ( !$wgMediaViewerIsInBeta ) {
return true;
}
$prefs['multimedia-viewer'] = [
'label-message' => 'multimediaviewer-pref',
'desc-message' => 'multimediaviewer-pref-desc',
'info-link' => self::$infoLink,
'discussion-link' => self::$discussionLink,
'help-link' => self::$helpLink,
'screenshot' => [
'ltr' => "$wgExtensionAssetsPath/MultimediaViewer/viewer-ltr.svg",
'rtl' => "$wgExtensionAssetsPath/MultimediaViewer/viewer-rtl.svg",
],
];
return true;
}
/**
* Adds a default-enabled preference to gate the feature on non-beta sites
* @param User $user
* @param array &$prefs
* @return true
*/ */
public static function getPreferences( $user, &$prefs ) { public static function getPreferences( $user, &$prefs ) {
global $wgMediaViewerIsInBeta; $prefs['multimediaviewer-enable'] = [
'type' => 'toggle',
if ( !$wgMediaViewerIsInBeta ) { 'label-message' => 'multimediaviewer-optin-pref',
$prefs['multimediaviewer-enable'] = [ 'section' => 'rendering/files',
'type' => 'toggle', ];
'label-message' => 'multimediaviewer-optin-pref',
'section' => 'rendering/files',
];
}
return true;
} }
/** /**
@ -186,7 +147,7 @@ class MultimediaViewerHooks {
$wgMediaViewerDurationLoggingLoggedinSamplingFactor, $wgMediaViewerDurationLoggingLoggedinSamplingFactor,
$wgMediaViewerAttributionLoggingSamplingFactor, $wgMediaViewerAttributionLoggingSamplingFactor,
$wgMediaViewerDimensionLoggingSamplingFactor, $wgMediaViewerDimensionLoggingSamplingFactor,
$wgMediaViewerIsInBeta, $wgMediaViewerUseThumbnailGuessing, $wgMediaViewerExtensions, $wgMediaViewerUseThumbnailGuessing, $wgMediaViewerExtensions,
$wgMediaViewerImageQueryParameter, $wgMediaViewerRecordVirtualViewBeaconURI; $wgMediaViewerImageQueryParameter, $wgMediaViewerRecordVirtualViewBeaconURI;
$vars['wgMultimediaViewer'] = [ $vars['wgMultimediaViewer'] = [
@ -206,7 +167,6 @@ class MultimediaViewerHooks {
'extensions' => $wgMediaViewerExtensions, 'extensions' => $wgMediaViewerExtensions,
]; ];
$vars['wgMediaViewer'] = true; $vars['wgMediaViewer'] = true;
$vars['wgMediaViewerIsInBeta'] = $wgMediaViewerIsInBeta;
return true; return true;
} }
@ -221,7 +181,7 @@ class MultimediaViewerHooks {
$user = $out->getUser(); $user = $out->getUser();
$vars['wgMediaViewerOnClick'] = self::shouldHandleClicks( $user ); $vars['wgMediaViewerOnClick'] = self::shouldHandleClicks( $user );
// needed because of bug 69942; could be different for anon and logged-in // needed because of T71942; could be different for anon and logged-in
$vars['wgMediaViewerEnabledByDefault'] = $vars['wgMediaViewerEnabledByDefault'] =
!empty( $defaultUserOptions['multimediaviewer-enable'] ); !empty( $defaultUserOptions['multimediaviewer-enable'] );
} }

View file

@ -189,17 +189,14 @@
} ); } );
QUnit.test( 'About links', function ( assert ) { QUnit.test( 'About links', function ( assert ) {
var $qf = $( '#qunit-fixture' ), var $qf = $( '#qunit-fixture' );
oldWgMediaViewerIsInBeta = mw.config.get( 'wgMediaViewerIsInBeta' );
this.sandbox.stub( mw.user, 'isAnon' ); this.sandbox.stub( mw.user, 'isAnon' );
mw.config.set( 'wgMediaViewerIsInBeta', false );
// eslint-disable-next-line no-new // eslint-disable-next-line no-new
new mw.mmv.ui.MetadataPanel( $qf.empty(), $( '<div>' ).appendTo( $qf ), mw.storage, new mw.mmv.Config( {}, mw.config, mw.user, new mw.Api(), mw.storage ) ); new mw.mmv.ui.MetadataPanel( $qf.empty(), $( '<div>' ).appendTo( $qf ), mw.storage, new mw.mmv.Config( {}, mw.config, mw.user, new mw.Api(), mw.storage ) );
assert.strictEqual( $qf.find( '.mw-mmv-about-link' ).length, 1, 'About link is created.' ); assert.strictEqual( $qf.find( '.mw-mmv-about-link' ).length, 1, 'About link is created.' );
assert.strictEqual( $qf.find( '.mw-mmv-discuss-link' ).length, 1, 'Discuss link is created.' ); assert.strictEqual( $qf.find( '.mw-mmv-discuss-link' ).length, 1, 'Discuss link is created.' );
assert.strictEqual( $qf.find( '.mw-mmv-help-link' ).length, 1, 'Help link is created.' ); assert.strictEqual( $qf.find( '.mw-mmv-help-link' ).length, 1, 'Help link is created.' );
mw.config.set( 'wgMediaViewerIsInBeta', oldWgMediaViewerIsInBeta );
} ); } );
}() ); }() );

View file

@ -1,24 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="264" height="162" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 264 162">
<defs>
<path id="a" fill="#eaecf0" d="M0 5h22v6H0z"/>
</defs>
<path fill="#fff" d="M24.833 151.362l-11.467 9.995L.5 151.749V.5h263v151.749l-9 6.705V42.5h-39v112.6l-4.393-3.731-7.607 5.33V42.5h-155v110.849l-9.751 8.031"/>
<path fill="#eaecf0" d="M263 1v150.998l-8 5.96V42h-40v112.019l-3.274-2.779-.589-.499-.633.44-6.504 4.557V42H48v111.099l-9.257 7.661-13.295-9.569-.644-.465-.598.521-10.864 9.47L1 151.499V1h262m1-1H0v152l13.391 10 11.473-10 13.891 10L49 153.6V43h154v114.66l8.078-5.66 4.922 4.18V43h38v116.95l10-7.45V0z"/>
<path fill="#eaecf0" d="M203 157.66V43H49v110.6l2.145-1.6L63.7 162l13.809-10 14.229 10 12.972-10 12.973 10 13.811-10 12.136 10 13.391-10 14.229 10 12.972-10 12.974 10 5.804-4.34zM11 36c0-7.732 6.268-14 14-14s14 6.268 14 14-6.268 14-14 14-14-6.268-14-14zm243 123.95V43h-38v113.18l7.551 5.82 13.811-10 13.891 10 2.747-2.05zM38 107V72H13v35h25zM232.51 5h26v6h-26V5z"/>
<use x="208.51" xlink:href="#a"/>
<path fill="#eaecf0" d="M142 6v4H50V6h92m1-1H49v6h94V5z"/>
<use x="184.51" xlink:href="#a"/>
<use width="13" x="161.51" xlink:href="#a"/>
<use width="6" x="176.51" xlink:href="#a"/>
<use width="6" x="153.51" xlink:href="#a"/>
<use width="32" x="9" xlink:href="#a"/>
<path fill="#eaecf0" stroke="#eaecf0" d="M2 14.5h260"/>
<path fill="#a2a9b1" d="M221 73h24v1h-24v-1z"/>
<use width="2" height="2" x="52" y="2"/>
<path fill="#eaecf0" d="M38 59v-5H13v5h25z"/>
<path fill="#8acdff" d="M250 47h-30v24h30V47zm-20.268 11h1.08l6.69 6.596 3.634-2.172 5.477 4.557V67h-23.959l7.078-9z"/>
<path fill="#fff" d="M54 15h155v128H54V15z"/>
<path fill="#36c" d="M204 24H60v112h144V24zm-97.679 50h5.184l32.129 34.005 17.446-10.42 26.28 21.317V119H72.343l33.978-45z"/>
<path fill="#fff" d="M191.795 34.937L187.955 31H198v10.067l-3.948-4.221-6.478 6.494L191.21 47H182V36.933l3.637 4.046 6.158-6.042z"/>
</svg>

Before

Width:  |  Height:  |  Size: 2 KiB

View file

@ -1,24 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="264" height="162" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 264 162">
<defs>
<path id="a" fill="#eaecf0" d="M0 5h22v6H0z"/>
</defs>
<path fill="#fff" d="M250.634 161.357l12.866-9.608V.5H.5v151.749l9 6.705V42.5h39v112.6l4.393-3.731 7.607 5.33V42.5h155v110.849l9.751 8.031 13.916-10.018"/>
<path fill="#eaecf0" d="M1 1v150.998l8 5.96V42h40v112.019l3.274-2.779.589-.499.633.44L60 155.738V42h156v111.099l9.257 7.661 13.295-9.569.644-.465.598.521 10.864 9.47L263 151.499V1H1M0 0h264v152l-13.391 10-11.473-10-13.891 10L215 153.6V43H61v114.66L52.922 152 48 156.18V43H10v116.95L0 152.5V0z"/>
<path fill="#eaecf0" d="M61 157.66V43h154v110.6l-2.145-1.6-12.555 10-13.809-10-14.229 10-12.972-10-12.973 10-13.811-10-12.136 10-13.391-10-14.229 10-12.972-10-12.974 10L61 157.66zM253 36c0-7.732-6.268-14-14-14s-14 6.268-14 14 6.268 14 14 14 14-6.268 14-14zM10 159.95V43h38v113.18L40.449 162l-13.811-10-13.891 10L10 159.95zM226 107V72h25v35h-25zM31.49 5h-26v6h26V5z"/>
<use width="264" height="162" x="208.50999" xlink:href="#a" transform="matrix(-1 0 0 1 264 0)"/>
<path fill="#eaecf0" d="M122 6v4h92V6h-92m-1-1h94v6h-94V5z"/>
<use width="264" height="162" x="184.50999" xlink:href="#a" transform="matrix(-1 0 0 1 264 0)"/>
<use width="13" height="162" x="161.50999" xlink:href="#a" transform="matrix(-1 0 0 1 264 0)"/>
<use width="6" height="162" x="176.50999" xlink:href="#a" transform="matrix(-1 0 0 1 264 0)"/>
<use width="6" height="162" x="153.50999" xlink:href="#a" transform="matrix(-1 0 0 1 264 0)"/>
<use width="32" height="162" x="9" xlink:href="#a" transform="matrix(-1 0 0 1 264 0)"/>
<path fill="#eaecf0" stroke="#eaecf0" d="M262 14.5H2"/>
<path fill="#a2a9b1" d="M43 73H19v1h24v-1z"/>
<use width="2" height="2" x="52" y="2" transform="matrix(-1 0 0 1 264 0)"/>
<path fill="#eaecf0" d="M226 59v-5h25v5h-25z"/>
<path fill="#8acdff" d="M14 47h30v24H14V47zm20.268 11h-1.08l-6.69 6.596-3.634-2.172-5.477 4.557V67h23.959l-7.078-9z"/>
<path fill="#fff" d="M210 15H55v128h155V15z"/>
<path fill="#36c" d="M60 24h144v112H60V24zm97.679 50h-5.184l-32.129 34.005-17.446-10.42-26.28 21.317V119h115.017l-33.978-45z"/>
<path fill="#fff" d="M72.205 34.937L76.045 31H66v10.067l3.948-4.221 6.478 6.494L72.79 47H82V36.933l-3.637 4.046-6.158-6.042z"/>
</svg>

Before

Width:  |  Height:  |  Size: 2.3 KiB