Adds "$wgPopupsTextExtractsIntroOnly" option to control "intro" parameters for TextExtracts API request

Change-Id: I84f91ab0752bbd4a5b1ee159b7cbe1388f942f24
This commit is contained in:
Vedmaka 2020-11-26 16:09:57 +03:00 committed by jdlrobson
parent d1d0b2a704
commit ff2ba9ebf5
7 changed files with 10 additions and 4 deletions

View file

@ -113,6 +113,10 @@
"Special:MostLinkedFiles", "Special:MostLinkedFiles",
"Special:Book" "Special:Book"
] ]
},
"PopupsTextExtractsIntroOnly": {
"description": "Whether we should extract intro text only or full page text. This is only applicable when using PopupsGateway=mwApiPlain.",
"value": true
} }
}, },
"ResourceModules": { "ResourceModules": {

View file

@ -134,6 +134,7 @@ class PopupsHooks {
$vars['wgPopupsEventLogging'] = $config->get( 'PopupsEventLogging' ); $vars['wgPopupsEventLogging'] = $config->get( 'PopupsEventLogging' );
$vars['wgPopupsRestGatewayEndpoint'] = $config->get( 'PopupsRestGatewayEndpoint' ); $vars['wgPopupsRestGatewayEndpoint'] = $config->get( 'PopupsRestGatewayEndpoint' );
$vars['wgPopupsStatsvSamplingRate'] = $config->get( 'PopupsStatsvSamplingRate' ); $vars['wgPopupsStatsvSamplingRate'] = $config->get( 'PopupsStatsvSamplingRate' );
$vars['wgPopupsTextExtractsIntroOnly'] = $config->get( 'PopupsTextExtractsIntroOnly' );
} }
/** /**

View file

@ -67,7 +67,7 @@
"bundlesize": [ "bundlesize": [
{ {
"path": "resources/dist/index.js", "path": "resources/dist/index.js",
"maxSize": "13.6kB" "maxSize": "13.61kB"
} }
] ]
} }

Binary file not shown.

Binary file not shown.

View file

@ -37,7 +37,7 @@ export default function createMediaWikiApiGateway( api, config ) {
prop: 'info|extracts|pageimages|revisions|info', prop: 'info|extracts|pageimages|revisions|info',
formatversion: 2, formatversion: 2,
redirects: true, redirects: true,
exintro: true, exintro: mw.config.get( 'wgPopupsTextExtractsIntroOnly', true ),
exchars: config.EXTRACT_LENGTH, exchars: config.EXTRACT_LENGTH,
// There is an added geometric limit on .mwe-popups-extract // There is an added geometric limit on .mwe-popups-extract

View file

@ -153,11 +153,12 @@ class PopupsHooksTest extends MediaWikiTestCase {
'wgPopupsRestGatewayEndpoint' => '/api', 'wgPopupsRestGatewayEndpoint' => '/api',
'wgPopupsVirtualPageViews' => true, 'wgPopupsVirtualPageViews' => true,
'wgPopupsGateway' => 'mwApiPlain', 'wgPopupsGateway' => 'mwApiPlain',
'wgPopupsStatsvSamplingRate' => 0 'wgPopupsStatsvSamplingRate' => 0,
'wgPopupsTextExtractsIntroOnly' => true,
]; ];
$this->setMwGlobals( $config ); $this->setMwGlobals( $config );
PopupsHooks::onResourceLoaderGetConfigVars( $vars, '' ); PopupsHooks::onResourceLoaderGetConfigVars( $vars, '' );
$this->assertCount( 6, $vars, 'A configuration is retrieved.' ); $this->assertCount( 7, $vars, 'A configuration is retrieved.' );
foreach ( $config as $key => $value ) { foreach ( $config as $key => $value ) {
$this->assertSame( $this->assertSame(