Remove Related Articles from desktop beta features

This change removes RelatedArticles from beta features.
It repurposes the BlacklistSkins config to be a whitelist that describes
when related pages should be shown in the footer.

To avoid enabling related pages on desktop, this depends on a config
change that makes use of the new configuration option.

Simplify browser tests to reflect the new status quo.

Bug: T146436
Bug: T160076
Depends-On: I522e0182d1c3d9261bd0561c3ec0c789b6431c7a
Change-Id: I84da1fb33a901a6365375d00d192af35422ff0b0
This commit is contained in:
jdlrobson 2017-03-24 16:14:52 -07:00 committed by Jdlrobson
parent e24c22ae13
commit dbb73c389d
9 changed files with 10 additions and 202 deletions

View file

@ -35,9 +35,6 @@
"RelatedArticles\\SidebarHooks::onSidebarBeforeOutput"
],
"GetBetaFeaturePreferences": [
"RelatedArticles\\FooterHooks::onGetBetaFeaturePreferences"
],
"MakeGlobalVariablesScript": [
"RelatedArticles\\FooterHooks::onMakeGlobalVariablesScript"
],
@ -127,8 +124,8 @@
"RelatedArticlesOnlyUseCirrusSearch": false,
"RelatedArticlesLoggingSamplingRate": 0.01,
"RelatedArticlesEnabledSamplingRate": 1,
"@RelatedArticlesFooterBlacklistedSkins": "List of skin names (e.g. 'minerva') where related articles won't be shown in the footer. If absent related articles will show in stable on Minerva or beta on all other skins.",
"RelatedArticlesFooterBlacklistedSkins": []
"@RelatedArticlesFooterWhitelistedSkins": "List of skin names (e.g. 'minerva') where related articles will be shown in the footer.",
"RelatedArticlesFooterWhitelistedSkins": [ "minerva" ]
},
"ConfigRegistry": {
"RelatedArticles": "GlobalVarConfig::newInstance"

View file

@ -4,7 +4,5 @@
},
"relatedarticles-title": "Related pages",
"relatedarticles-desc": "Adds a link to related pages on the sidebar or in the footer, if the user enables the beta feature.",
"relatedarticles-read-more-heading": "Related pages",
"relatedarticles-read-more-beta-feature-title": "Related pages",
"relatedarticles-read-more-beta-feature-description": "Suggests related pages at the bottom of a page."
"relatedarticles-read-more-heading": "Related pages"
}

View file

@ -9,7 +9,5 @@
},
"relatedarticles-title": "Title shown on the sidebar",
"relatedarticles-desc": "{{desc|name=Related Articles|url=https://www.mediawiki.org/wiki/Extension:RelatedArticles}}",
"relatedarticles-read-more-heading": "The heading of section, added at the end of the page, that lists the related pages",
"relatedarticles-read-more-beta-feature-title": "Title of the related pages feature in Special:Preferences#mw-prefsection-betafeatures.\n{{Identical|Read more}}",
"relatedarticles-read-more-beta-feature-description": "Description of the related pages feature in Special:Preferences#mw-prefsection-betafeatures"
"relatedarticles-read-more-heading": "The heading of section, added at the end of the page, that lists the related pages"
}

View file

@ -1,48 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="264" height="162" viewBox="0 0 264 162" id="svg2">
<defs id="defs78">
<clipPath id="jagged-edge">
<path id="path4215" d="M0 0v152l12 10 12-10 12 10 12-10 12 10 12-10 12 10 12-10 12 10 12-10 12 10 12-10 12 10 12-10 12 10 12-10 12 10 12-10 12 10 12-10 12 10 12-10V0z"/>
</clipPath>
</defs>
<g id="screenshot" clip-path="url(#jagged-edge)">
<path fill="#fff" d="M263.5 162.25l-263-.5V.5h263z" id="background"/>
<path fill="#e5e5e5" d="M252 162.496V29H48v133.496z" id="article"/>
<path fill="#e5e5e5" d="M11 22c0-7.732 6.268-14 14-14s14 6.268 14 14-6.268 14-14 14-14-6.268-14-14z" id="logo"/>
<path fill="#e5e5e5" d="M38 163.807V58H13v105.807h25z" id="sidebar"/>
<g fill="#e5e5e5" id="personal-tools">
<path id="path4223" d="M233 5h26v6h-26V5zm-24 0h22v6h-22zm-24 0h22v6h-22zm-23 0h13v6h-13zm15 0h6v6h-6zm-23 0h6v6h-6z"/>
</g>
<g fill="#e5e5e5" id="search">
<path d="M258 16v4h-92v-4h92m1-1h-94v6h94v-6z" id="path5717"/>
<path d="M168 17h2v2h-2z" id="icon"/>
</g>
<path fill="#e5e5e5" d="M38 45v-5H13v5h25z" id="sitename"/>
<path fill="#e5e5e5" id="border" d="M0 0v162h264V0zm1 1h262v150.533l-11 9.166-12-10-12 10-12-10-12 10-12-10-12 10-12-10-12 10-12-10-12 10-12-10-12 10-12-10-12 10-12-10-12 10-12-10-12 10-12-10-12 10-11-9.168z"/>
<g id="read-more-cards">
<g id="card" transform="translate(63 125)">
<g id="g4871">
<path id="Rectangle-7" fill="#36c" d="M0 0h54v13H0z" transform="translate(-2)"/>
<path id="Rectangle-4" fill="#fff" fill-opacity=".498" d="M2 2h8v9H2z" transform="translate(-2)"/>
<path id="Rectangle-5" fill="#fff" fill-opacity=".498" d="M12 2h36v3H12z" transform="translate(-2)"/>
<path id="Rectangle-5-Copy" fill="#fff" fill-opacity=".498" d="M12 7h25v3H12z" transform="translate(-2)"/>
</g>
<use height="100%" width="100%" transform="translate(60)" id="use4877" xlink:href="#g4871"/>
<use height="100%" width="100%" transform="translate(120)" id="use4881" xlink:href="#g4871"/>
</g>
</g>
<path id="title" fill="#d8d8d8" d="M56 42h45v7H56z"/>
<g id="para" fill="#d8d8d8">
<path id="Rectangle-15-Copy" d="M0 0h140v3H0z" transform="matrix(1.3357 0 0 1 56 60)"/>
<path id="Rectangle-15-Copy-2" d="M0 7h140v3H0z" transform="matrix(1.3357 0 0 1 56 60)"/>
<path id="Rectangle-15-Copy-3" d="M0 14h140v3H0z" transform="matrix(1.3357 0 0 1 56 60)"/>
<path id="Rectangle-15-Copy-4" d="M0 21h66v3H0z" transform="matrix(1.3357 0 0 1 56 60)"/>
</g>
<g id="g72" fill="#d8d8d8">
<path id="rect74" d="M0 0h140v3H0z" transform="matrix(1.3357 0 0 1 56 91)"/>
<path id="rect76" d="M0 7h140v3H0z" transform="matrix(1.3357 0 0 1 56 91)"/>
<path id="rect78" d="M0 14h140v3H0z" transform="matrix(1.3357 0 0 1 56 91)"/>
<path id="rect80" d="M0 21h36v3H0z" transform="matrix(1.3357 0 0 1 56 91)"/>
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 3.3 KiB

View file

@ -1,48 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="264" height="162" viewBox="0 0 264 162" id="svg2">
<defs id="defs78">
<clipPath id="jagged-edge">
<path id="path4215" d="M0 0v152l12 10 12-10 12 10 12-10 12 10 12-10 12 10 12-10 12 10 12-10 12 10 12-10 12 10 12-10 12 10 12-10 12 10 12-10 12 10 12-10 12 10 12-10V0z"/>
</clipPath>
</defs>
<g transform="matrix(-1 0 0 1 264 0)" id="screenshot" clip-path="url(#jagged-edge)">
<path d="M263.5 162.25l-263-.5V.5h263z" id="background" fill="#fff"/>
<path d="M252 162.496V29H48v133.496z" id="article" fill="#e5e5e5"/>
<path d="M11 22c0-7.732 6.268-14 14-14s14 6.268 14 14-6.268 14-14 14-14-6.268-14-14z" id="logo" fill="#e5e5e5"/>
<path d="M38 163.807V58H13v105.807h25z" id="sidebar" fill="#e5e5e5"/>
<g id="personal-tools" fill="#e5e5e5">
<path id="path4223" d="M233 5h26v6h-26V5zm-24 0h22v6h-22zm-24 0h22v6h-22zm-23 0h13v6h-13zm15 0h6v6h-6zm-23 0h6v6h-6z"/>
</g>
<g id="search" fill="#e5e5e5">
<path d="M258 16v4h-92v-4h92m1-1h-94v6h94v-6z" id="path5717"/>
<path d="M168 17h2v2h-2z" id="icon"/>
</g>
<path d="M38 45v-5H13v5h25z" id="sitename" fill="#e5e5e5"/>
<path id="border" d="M0 0v162h264V0zm1 1h262v150.533l-11 9.166-12-10-12 10-12-10-12 10-12-10-12 10-12-10-12 10-12-10-12 10-12-10-12 10-12-10-12 10-12-10-12 10-12-10-12 10-12-10-12 10-11-9.168z" fill="#e5e5e5"/>
<g id="read-more-cards">
<g id="card" transform="translate(63 125)">
<g id="g4871">
<path id="Rectangle-7" fill="#36c" d="M0 0h54v13H0z" transform="translate(-2)"/>
<path id="Rectangle-4" fill="#fff" fill-opacity=".498" d="M2 2h8v9H2z" transform="translate(-2)"/>
<path id="Rectangle-5" fill="#fff" fill-opacity=".498" d="M12 2h36v3H12z" transform="translate(-2)"/>
<path id="Rectangle-5-Copy" fill="#fff" fill-opacity=".498" d="M12 7h25v3H12z" transform="translate(-2)"/>
</g>
<use height="100%" width="100%" transform="translate(60)" id="use4877" xlink:href="#g4871"/>
<use height="100%" width="100%" transform="translate(120)" id="use4881" xlink:href="#g4871"/>
</g>
</g>
<path id="title" fill="#d8d8d8" d="M56 42h45v7H56z"/>
<g id="para" fill="#d8d8d8">
<path id="Rectangle-15-Copy" d="M0 0h140v3H0z" transform="matrix(1.3357 0 0 1 56 60)"/>
<path id="Rectangle-15-Copy-2" d="M0 7h140v3H0z" transform="matrix(1.3357 0 0 1 56 60)"/>
<path id="Rectangle-15-Copy-3" d="M0 14h140v3H0z" transform="matrix(1.3357 0 0 1 56 60)"/>
<path id="Rectangle-15-Copy-4" d="M0 21h66v3H0z" transform="matrix(1.3357 0 0 1 56 60)"/>
</g>
<g id="g72" fill="#d8d8d8">
<path id="rect74" d="M0 0h140v3H0z" transform="matrix(1.3357 0 0 1 56 91)"/>
<path id="rect76" d="M0 7h140v3H0z" transform="matrix(1.3357 0 0 1 56 91)"/>
<path id="rect78" d="M0 14h140v3H0z" transform="matrix(1.3357 0 0 1 56 91)"/>
<path id="rect80" d="M0 21h36v3H0z" transform="matrix(1.3357 0 0 1 56 91)"/>
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 3.3 KiB

View file

@ -28,8 +28,6 @@ class FooterHooks {
->makeConfig( 'RelatedArticles' );
$vars['wgRelatedArticles'] = $out->getProperty( 'RelatedArticles' );
$vars['wgRelatedArticlesBetaFeatureEnabled'] =
self::isUserOptedIntoBetaFeature( $out->getUser() );
$vars['wgRelatedArticlesUseCirrusSearch'] = $config->get( 'RelatedArticlesUseCirrusSearch' );
$vars['wgRelatedArticlesOnlyUseCirrusSearch'] =
$config->get( 'RelatedArticlesOnlyUseCirrusSearch' );
@ -66,22 +64,11 @@ class FooterHooks {
return $type === 'revision' || $diff || $oldId || $isSpecialMobileDiff;
}
/**
* Did the user opt into the ReadMore beta feature?
*
* @param User $user
* @return bool
*/
private static function isUserOptedIntoBetaFeature( User $user ) {
return class_exists( 'BetaFeatures' ) && BetaFeatures::isFeatureEnabled( $user, 'read-more' );
}
/**
* Is ReadMore allowed on skin?
*
* The feature is allowed on all skins as long as they are not blacklisted
* in the configuration variable `RelatedArticlesFooterBlacklistedSkins`.
* On desktop, the beta feature needs to be enabled by the user as well.
* The feature is allowed on all skins as long as they are whitelisted
* in the configuration variable `RelatedArticlesFooterWhitelistedSkins`.
*
* @param User $user
* @param Skin $skin
@ -90,19 +77,9 @@ class FooterHooks {
private static function isReadMoreAllowedOnSkin( User $user, Skin $skin ) {
$config = MediaWikiServices::getInstance()->getConfigFactory()
->makeConfig( 'RelatedArticles' );
$blacklistedSkins = $config->get( 'RelatedArticlesFooterBlacklistedSkins' );
$skins = $config->get( 'RelatedArticlesFooterWhitelistedSkins' );
$skinName = $skin->getSkinName();
$isBlacklistedSkin = in_array( $skinName, $blacklistedSkins );
if ( !$isBlacklistedSkin ) {
// Minerva has its own beta mode and doesn't use the BetaFeatures extension.
if ( $skinName === 'minerva' ) {
return true;
}
return !class_exists( 'BetaFeatures' ) || self::isUserOptedIntoBetaFeature( $user );
}
return false;
return in_array( $skinName, $skins );
}
/**
@ -224,40 +201,4 @@ class FooterHooks {
return true;
}
/**
* GetBetaFeaturePreferences hook handler
* The beta feature is for showing ReadMore, not for showing related
* articles in the sidebar.
* @see https://www.mediawiki.org/wiki/Manual:Hooks/GetBetaFeaturePreferences
*
* @param User $user
* @param array $preferences
*
* @return bool
*/
public static function onGetBetaFeaturePreferences( User $user, array &$preferences ) {
$config = MediaWikiServices::getInstance()->getConfigFactory()
->makeConfig( 'RelatedArticles' );
$showReadMore = $config->get( 'RelatedArticlesShowInFooter' );
if ( $showReadMore ) {
$wgExtensionAssetsPath = $config->get( 'ExtensionAssetsPath' );
$preferences['read-more'] = [
'label-message' => 'relatedarticles-read-more-beta-feature-title',
'desc-message' => 'relatedarticles-read-more-beta-feature-description',
'screenshot' => [
'ltr' => "$wgExtensionAssetsPath/RelatedArticles/images/BetaFeatures/wb-readmore-beta-ltr.svg",
'rtl' => "$wgExtensionAssetsPath/RelatedArticles/images/BetaFeatures/wb-readmore-beta-rtl.svg",
],
'info-link' => 'https://www.mediawiki.org/wiki/Reading/Web/Projects/Read_more',
'discussion-link' => 'https://www.mediawiki.org/wiki/Talk:Reading/Web/Projects/Read_more',
];
}
return true;
}
}

View file

@ -29,10 +29,6 @@
var bucket,
samplingRate = mw.config.get( 'wgRelatedArticlesEnabledSamplingRate', 1 );
if ( mw.config.get( 'wgRelatedArticlesBetaFeatureEnabled' ) ) {
return true;
}
bucket = mw.experiments.getBucket( {
name: 'ext.relatedArticles.visibility',
enabled: true,

View file

@ -5,5 +5,3 @@ $wgRelatedArticlesShowInFooter = true;
$wgRelatedArticlesShowInSidebar = true;
$wgRelatedArticlesUseCirrusSearch = true;
$wgRelatedArticlesOnlyUseCirrusSearch = false;
$wgMFEnableBeta = true;
$wgRelatedArticlesFooterBlacklistedSkins = [ 'minerva' ];

View file

@ -10,32 +10,8 @@ Feature: ReadMore
And page has fully loaded with ReadMore code
Then I must see ReadMore
@integration
Scenario: ReadMore is not present in minerva stable in default install
Given I am using the mobile site
And I am on the "Related Articles 1" page
And page has fully loaded without ReadMore code
Then I must not see ReadMore
@en.m.wikipedia.beta.wmflabs.org @integration @extension-mobilefrontend
Scenario: ReadMore is present in minerva beta in default installs and beta cluster
Given I am using the mobile site
And I am in mobile beta mode
And I am on the "Related Articles 1" page
And page has fully loaded with ReadMore code
Then I must see ReadMore
And ReadMore must have three cards
@en.wikipedia.beta.wmflabs.org @integration
Scenario: ReadMore is not present when disabled as a BetaFeature
Scenario: ReadMore is not present on Vector
Given I am on the "Related Articles 1" page
And page has fully loaded without ReadMore code
Then I must not see ReadMore
@en.wikipedia.beta.wmflabs.org @extension-betafeatures @integration
Scenario: ReadMore is present when enabled as a BetaFeature
Given I am logged in
And ReadMore is enabled as a beta feature
And I am on the "Related Articles 1" page
And page has fully loaded with ReadMore code
Then I must see ReadMore
Then I must not see ReadMore