Ensure core compatibility with Parsoid external link attributes support
* Export nofollow and target settings in siteinfo API so that Parsoid's developer mode of ApiSiteConfig works. * Implement SiteConfig::getNoFollowConfig and SiteConfig::getExternalLinkTarget, which are defined as abstract in the parent class in Parsoid. Bug: T186241 Change-Id: I6a1f12335be19509d4c5a17e2cae96ecdb677103
This commit is contained in:
parent
48e067edf3
commit
61c14054f5
3 changed files with 45 additions and 1 deletions
|
|
@ -379,6 +379,11 @@ class ApiQuerySiteinfo extends ApiQueryBase {
|
|||
|
||||
$data['categorycollation'] = $config->get( MainConfigNames::CategoryCollation );
|
||||
|
||||
$data['nofollowlinks'] = $config->get( MainConfigNames::NoFollowLinks );
|
||||
$data['nofollownsexceptions'] = $config->get( MainConfigNames::NoFollowNsExceptions );
|
||||
$data['nofollowdomainexceptions'] = $config->get( MainConfigNames::NoFollowDomainExceptions );
|
||||
$data['externallinktarget'] = $config->get( MainConfigNames::ExternalLinkTarget );
|
||||
|
||||
$this->getHookRunner()->onAPIQuerySiteInfoGeneralInfo( $this, $data );
|
||||
|
||||
return $this->getResult()->addValue( 'query', $property, $data );
|
||||
|
|
|
|||
|
|
@ -86,6 +86,10 @@ class SiteConfig extends ISiteConfig {
|
|||
MainConfigNames::LocalTZoffset,
|
||||
MainConfigNames::ThumbLimits,
|
||||
MainConfigNames::MaxTemplateDepth,
|
||||
MainConfigNames::NoFollowLinks,
|
||||
MainConfigNames::NoFollowNsExceptions,
|
||||
MainConfigNames::NoFollowDomainExceptions,
|
||||
MainConfigNames::ExternalLinkTarget,
|
||||
];
|
||||
|
||||
/** @var ServiceOptions */
|
||||
|
|
@ -724,4 +728,18 @@ class SiteConfig extends ISiteConfig {
|
|||
protected function getProtocols(): array {
|
||||
return $this->config->get( MainConfigNames::UrlProtocols );
|
||||
}
|
||||
|
||||
/** @return array */
|
||||
public function getNoFollowConfig(): array {
|
||||
return [
|
||||
'nofollow' => $this->config->get( MainConfigNames::NoFollowLinks ),
|
||||
'nsexceptions' => $this->config->get( MainConfigNames::NoFollowNsExceptions ),
|
||||
'domainexceptions' => $this->config->get( MainConfigNames::NoFollowDomainExceptions )
|
||||
];
|
||||
}
|
||||
|
||||
/** @return string|false */
|
||||
public function getExternalLinkTarget() {
|
||||
return $this->config->get( MainConfigNames::ExternalLinkTarget );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,11 @@ class SiteConfigTest extends MediaWikiUnitTestCase {
|
|||
'LocalTZoffset' => null,
|
||||
'ThumbLimits' => [ 4242 ],
|
||||
'MaxTemplateDepth' => 42,
|
||||
'LegalTitleChars' => 'abc'
|
||||
'LegalTitleChars' => 'abc',
|
||||
'NoFollowLinks' => true,
|
||||
'NoFollowNsExceptions' => [ 5 ],
|
||||
'NoFollowDomainExceptions' => [ 'www.mediawiki.org' ],
|
||||
'ExternalLinkTarget' => false,
|
||||
];
|
||||
|
||||
private function createMockOrOverride( string $class, array $overrides ) {
|
||||
|
|
@ -177,6 +181,21 @@ class SiteConfigTest extends MediaWikiUnitTestCase {
|
|||
'getProtocols',
|
||||
[ 'blabla' ]
|
||||
];
|
||||
yield 'getNoFollowConfig' => [
|
||||
[],
|
||||
'getNoFollowConfig',
|
||||
[ 'nofollow' => true, 'nsexceptions' => [ 5 ], 'domainexceptions' => [ 'www.mediawiki.org' ] ]
|
||||
];
|
||||
yield 'getExternalLinkTargetEmpty' => [
|
||||
[],
|
||||
'getExternalLinkTarget',
|
||||
false
|
||||
];
|
||||
yield 'getExternalLinkTargetString' => [
|
||||
[ 'ExternalLinkTarget' => "_blank" ],
|
||||
'getExternalLinkTarget',
|
||||
"_blank"
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -192,6 +211,8 @@ class SiteConfigTest extends MediaWikiUnitTestCase {
|
|||
* @covers \MediaWiki\Parser\Parsoid\Config\SiteConfig::getMaxTemplateDepth
|
||||
* @covers \MediaWiki\Parser\Parsoid\Config\SiteConfig::legalTitleChars
|
||||
* @covers \MediaWiki\Parser\Parsoid\Config\SiteConfig::getProtocols
|
||||
* @covers \MediaWiki\Parser\Parsoid\Config\SiteConfig::getNoFollowConfig
|
||||
* @covers \MediaWiki\Parser\Parsoid\Config\SiteConfig::getExternalLinkTarget
|
||||
* @dataProvider provideConfigParameterPassed
|
||||
* @param array $settings
|
||||
* @param string $method
|
||||
|
|
|
|||
Loading…
Reference in a new issue