mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Popups
synced 2024-09-23 10:21:11 +00:00
Talk about "exclusions" instead of "blacklists"
AVoid the term if possible, in all internal code. The only remaining use of the word is in the public $wgPopupsPageBlacklist config variable. Change-Id: Ib238731270f473ad44fcff13df617a70433f2452
This commit is contained in:
parent
48f3a8f720
commit
092e2a4959
|
@ -88,7 +88,7 @@
|
|||
"value": 0
|
||||
},
|
||||
"PopupsPageBlacklist": {
|
||||
"description": "Blacklisted pages are subject to the HTML cache policy of the wiki. A purge on a blacklisted page maybe needed to see the effect of this configuration variable. Every blacklisted page should be defined by a canonical name, eg: Special:Userlogin",
|
||||
"description": "List of pages that should not show Popups. Includes subpages. These pages are subject to the HTML cache policy of the wiki. A purge on these pages maybe needed to see the effect of this configuration variable. Every excluded page should be defined by a canonical name, eg: Special:Userlogin",
|
||||
"value": [
|
||||
"Special:Userlogin",
|
||||
"Special:CreateAccount"
|
||||
|
|
|
@ -167,22 +167,21 @@ class PopupsContext {
|
|||
/**
|
||||
* Whether popups code should be shipped to $title
|
||||
*
|
||||
* For example, if 'Special:UserLogin' is blacklisted, and the user is on 'Special:UserLogin',
|
||||
* then the title is considered blacklisted.
|
||||
* For example, if 'Special:UserLogin' is excluded, and the user is on 'Special:UserLogin',
|
||||
* then the title is considered excluded.
|
||||
*
|
||||
* A title is also considered blacklisted if its root matches one of the page names
|
||||
* from the config variable. For example, if 'User:A' is blacklisted, and the
|
||||
* title is 'User:A/b', then this title is considered blacklisted.
|
||||
* A title is also considered excluded if its root matches one of the page names
|
||||
* from the config variable. For example, if 'User:A' is excluded, and the
|
||||
* title is 'User:A/b', then this title is considered excluded.
|
||||
*
|
||||
* Language specific blacklisted titles affect all languages. For example, if "Main_Page" is
|
||||
* blacklisted, "Bosh_Sahifa" (which is "Main_Page" in Uzbek) is considered blacklisted
|
||||
* too.
|
||||
* Language specific excluded titles affect all languages. For example, if "Main_Page" is
|
||||
* excluded, "Bosh_Sahifa" (which is "Main_Page" in Uzbek) is considered excluded too.
|
||||
*
|
||||
* @param Title $title title being tested
|
||||
* @return bool
|
||||
*/
|
||||
public function isTitleBlacklisted( $title ) {
|
||||
$blacklistedPages = $this->config->get( 'PopupsPageBlacklist' );
|
||||
public function isTitleExcluded( $title ) {
|
||||
$excludedPages = $this->config->get( 'PopupsPageBlacklist' );
|
||||
$canonicalTitle = $title->getRootTitle();
|
||||
|
||||
if ( $title->isSpecialPage() ) {
|
||||
|
@ -195,10 +194,10 @@ class PopupsContext {
|
|||
}
|
||||
}
|
||||
|
||||
foreach ( $blacklistedPages as $page ) {
|
||||
$blacklistedTitle = Title::newFromText( $page );
|
||||
foreach ( $excludedPages as $page ) {
|
||||
$excludedTitle = Title::newFromText( $page );
|
||||
|
||||
if ( $canonicalTitle->equals( $blacklistedTitle ) ) {
|
||||
if ( $canonicalTitle->equals( $excludedTitle ) ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@ class PopupsHooks {
|
|||
public static function onBeforePageDisplay( OutputPage $out, Skin $skin ) {
|
||||
/** @var PopupsContext $context */
|
||||
$context = MediaWikiServices::getInstance()->getService( 'Popups.Context' );
|
||||
if ( $context->isTitleBlacklisted( $out->getTitle() ) ) {
|
||||
if ( $context->isTitleExcluded( $out->getTitle() ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
BIN
resources/dist/index.js.map.json
vendored
BIN
resources/dist/index.js.map.json
vendored
Binary file not shown.
|
@ -25,7 +25,7 @@ import createMediaWikiPopupsObject from './integrations/mwpopups';
|
|||
import getPageviewTracker, { getSendBeacon } from './getPageviewTracker';
|
||||
import { previewTypes, getPreviewType } from './preview/model';
|
||||
|
||||
const BLACKLISTED_LINKS = [
|
||||
const EXCLUDED_LINK_SELECTORS = [
|
||||
'.extiw',
|
||||
'.image',
|
||||
'.new',
|
||||
|
@ -222,8 +222,8 @@ function registerChangeListeners(
|
|||
|
||||
const selectors = [];
|
||||
if ( mw.user.isAnon() || mw.user.options.get( 'popups' ) === '1' ) {
|
||||
const invalidLinksSelector = BLACKLISTED_LINKS.join( ', ' );
|
||||
selectors.push( `#mw-content-text a[href][title]:not(${invalidLinksSelector})` );
|
||||
const excludedLinksSelector = EXCLUDED_LINK_SELECTORS.join( ', ' );
|
||||
selectors.push( `#mw-content-text a[href][title]:not(${excludedLinksSelector})` );
|
||||
}
|
||||
// TODO: Replace with mw.user.options.get( 'popupsreferencepreviews' ) === '1' when not in Beta
|
||||
// any more, and the temporary feature flag is not needed any more.
|
||||
|
|
|
@ -197,51 +197,51 @@ class PopupsContextTest extends MediaWikiTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @covers ::isTitleBlacklisted
|
||||
* @dataProvider provideTestIsTitleBLacklisted
|
||||
* @param string[] $blacklist
|
||||
* @covers ::isTitleExcluded
|
||||
* @dataProvider provideTestIsTitleExcluded
|
||||
* @param string[] $excludedPages
|
||||
* @param Title $title
|
||||
* @param bool $expected
|
||||
*/
|
||||
public function testIsTitleBlacklisted( array $blacklist, Title $title, $expected ) {
|
||||
$this->setMwGlobals( [ 'wgPopupsPageBlacklist' => $blacklist ] );
|
||||
public function testIsTitleExcluded( array $excludedPages, Title $title, $expected ) {
|
||||
$this->setMwGlobals( [ 'wgPopupsPageBlacklist' => $excludedPages ] );
|
||||
$context = $this->getContext();
|
||||
$this->assertSame( $expected,
|
||||
$context->isTitleBlacklisted( $title ),
|
||||
'The title is' . ( $expected ? ' ' : ' not ' ) . 'blacklisted.' );
|
||||
$context->isTitleExcluded( $title ),
|
||||
'The title is' . ( $expected ? ' ' : ' not ' ) . 'excluded.' );
|
||||
}
|
||||
|
||||
public function provideTestIsTitleBlacklisted() {
|
||||
$blacklist = [ 'Special:Userlogin', 'Special:CreateAccount', 'User:A' ];
|
||||
public function provideTestIsTitleExcluded() {
|
||||
$excludedPages = [ 'Special:Userlogin', 'Special:CreateAccount', 'User:A' ];
|
||||
return [
|
||||
[ $blacklist, Title::newFromText( 'Main_Page' ), false ],
|
||||
[ $blacklist, Title::newFromText( 'Special:CreateAccount' ), true ],
|
||||
[ $blacklist, Title::newFromText( 'User:A' ), true ],
|
||||
[ $blacklist, Title::newFromText( 'User:A/B' ), true ],
|
||||
[ $blacklist, Title::newFromText( 'User:B' ), false ],
|
||||
[ $blacklist, Title::newFromText( 'User:B/A' ), false ],
|
||||
[ $excludedPages, Title::newFromText( 'Main_Page' ), false ],
|
||||
[ $excludedPages, Title::newFromText( 'Special:CreateAccount' ), true ],
|
||||
[ $excludedPages, Title::newFromText( 'User:A' ), true ],
|
||||
[ $excludedPages, Title::newFromText( 'User:A/B' ), true ],
|
||||
[ $excludedPages, Title::newFromText( 'User:B' ), false ],
|
||||
[ $excludedPages, Title::newFromText( 'User:B/A' ), false ],
|
||||
// test canonical name handling
|
||||
[ $blacklist, Title::newFromText( 'Special:UserLogin' ), true ],
|
||||
[ $excludedPages, Title::newFromText( 'Special:UserLogin' ), true ],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if special page in different language is blacklisted
|
||||
* Test if special page in different language is excluded
|
||||
*
|
||||
* @covers ::isTitleBlacklisted
|
||||
* @covers ::isTitleExcluded
|
||||
*/
|
||||
public function testIsTranslatedTitleBlacklisted() {
|
||||
public function testIsTranslatedTitleExcluded() {
|
||||
$page = 'Specjalna:Preferencje';
|
||||
$blacklist = [ 'Special:Preferences' ];
|
||||
$excludedPages = [ 'Special:Preferences' ];
|
||||
|
||||
$this->setMwGlobals( [
|
||||
'wgPopupsPageBlacklist' => $blacklist,
|
||||
'wgPopupsPageBlacklist' => $excludedPages,
|
||||
'wgLanguageCode' => 'pl'
|
||||
] );
|
||||
$context = $this->getContext();
|
||||
$this->assertTrue(
|
||||
$context->isTitleBlacklisted( Title::newFromText( $page ) ),
|
||||
'The title is blacklisted.' );
|
||||
$context->isTitleExcluded( Title::newFromText( $page ) ),
|
||||
'The title is excluded.' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -185,7 +185,7 @@ class PopupsHooksTest extends MediaWikiTestCase {
|
|||
->method( 'areDependenciesMet' )
|
||||
->will( $this->returnValue( false ) );
|
||||
$contextMock->expects( $this->once() )
|
||||
->method( 'isTitleBlacklisted' )
|
||||
->method( 'isTitleExcluded' )
|
||||
->will( $this->returnValue( false ) );
|
||||
$contextMock->expects( $this->once() )
|
||||
->method( 'getLogger' )
|
||||
|
@ -199,9 +199,9 @@ class PopupsHooksTest extends MediaWikiTestCase {
|
|||
return [
|
||||
[ false, false, false ],
|
||||
[ true, true, false ],
|
||||
// Code not sent if title blacklisted
|
||||
// Code not sent if title is excluded
|
||||
[ true, false, true ],
|
||||
// Code not sent if title blacklisted
|
||||
// Code not sent if title is excluded
|
||||
[ false, false, true ]
|
||||
];
|
||||
}
|
||||
|
@ -211,7 +211,7 @@ class PopupsHooksTest extends MediaWikiTestCase {
|
|||
* @dataProvider providerOnBeforePageDisplay
|
||||
*/
|
||||
public function testOnBeforePageDisplay( $shouldSendModuleToUser,
|
||||
$isCodeLoaded, $isTitleBlacklisted ) {
|
||||
$isCodeLoaded, $isTitleExcluded ) {
|
||||
$skinMock = $this->createMock( Skin::class );
|
||||
|
||||
$outPageMock = $this->createMock( OutputPage::class );
|
||||
|
@ -223,7 +223,7 @@ class PopupsHooksTest extends MediaWikiTestCase {
|
|||
|
||||
$contextMock = $this->createMock( PopupsContext::class );
|
||||
|
||||
if ( !$isTitleBlacklisted ) {
|
||||
if ( !$isTitleExcluded ) {
|
||||
$contextMock->expects( $this->once() )
|
||||
->method( 'areDependenciesMet' )
|
||||
->will( $this->returnValue( true ) );
|
||||
|
@ -234,8 +234,8 @@ class PopupsHooksTest extends MediaWikiTestCase {
|
|||
->will( $this->returnValue( $shouldSendModuleToUser ) );
|
||||
|
||||
$contextMock->expects( $this->once() )
|
||||
->method( 'isTitleBlacklisted' )
|
||||
->will( $this->returnValue( $isTitleBlacklisted ) );
|
||||
->method( 'isTitleExcluded' )
|
||||
->will( $this->returnValue( $isTitleExcluded ) );
|
||||
|
||||
$this->setService( 'Popups.Context', $contextMock );
|
||||
PopupsHooks::onBeforePageDisplay( $outPageMock, $skinMock );
|
||||
|
|
Loading…
Reference in a new issue