mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Scribunto
synced 2024-11-24 00:05:00 +00:00
Set "TemplateSandboxEditNamespaces" in extension.json
If TemplateStyles installed, then enable it in the Module namespace by default. This change is analogous to I96d9601ff80c2d3eb052c01. Since both extensions use the ContentHandlerDefaultModelFor hook, Scribunto will check if the sanitized-css model has already been set, and if so, not override it. If the page is in NS_MODULE, it will set the content model to Scribunto, but allow further hooks to override it, in which case it is expected that TemplateStyles would set it to sanitized-css. Bug: T200914 Depends-On: I2fa9b822ee39bcc5f95a293c8c4aad4d53ede30a Change-Id: I7a9b445accde35e4a5e7d13100c646f211d21afe
This commit is contained in:
parent
3b0082e6b2
commit
4bc7abb0ac
|
@ -164,5 +164,8 @@
|
|||
"TemplateSandboxEditNamespaces": [
|
||||
828
|
||||
],
|
||||
"TemplateStylesNamespaces": [
|
||||
828
|
||||
],
|
||||
"manifest_version": 1
|
||||
}
|
||||
|
|
|
@ -261,9 +261,13 @@ class ScribuntoHooks {
|
|||
* @return bool
|
||||
*/
|
||||
public static function contentHandlerDefaultModelFor( Title $title, &$model ) {
|
||||
if ( $model === 'sanitized-css' ) {
|
||||
// Let TemplateStyles override Scribunto
|
||||
return true;
|
||||
}
|
||||
if ( $title->getNamespace() == NS_MODULE && !Scribunto::isDocPage( $title ) ) {
|
||||
$model = CONTENT_MODEL_SCRIBUNTO;
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -4,10 +4,10 @@ class ScribuntoHooksTest extends MediaWikiLangTestCase {
|
|||
|
||||
public function provideContentHandlerDefaultModelFor() {
|
||||
return [
|
||||
[ 'Module:Foo', CONTENT_MODEL_SCRIBUNTO, false ],
|
||||
[ 'Module:Foo', CONTENT_MODEL_SCRIBUNTO, true ],
|
||||
[ 'Module:Foo/doc', null, true ],
|
||||
[ 'Module:Foo/styles.css', 'sanitized-css', true, 'sanitized-css' ],
|
||||
[ 'Main Page', null, true ],
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -15,9 +15,11 @@ class ScribuntoHooksTest extends MediaWikiLangTestCase {
|
|||
* @covers ScribuntoHooks::contentHandlerDefaultModelFor
|
||||
* @dataProvider provideContentHandlerDefaultModelFor
|
||||
*/
|
||||
public function testContentHandlerDefaultModelFor( $name, $expected, $retVal ) {
|
||||
public function testContentHandlerDefaultModelFor( $name, $expected,
|
||||
$retVal, $before = null
|
||||
) {
|
||||
$title = Title::newFromText( $name );
|
||||
$model = null;
|
||||
$model = $before;
|
||||
$ret = ScribuntoHooks::contentHandlerDefaultModelFor( $title, $model );
|
||||
$this->assertSame( $retVal, $ret );
|
||||
$this->assertSame( $expected, $model );
|
||||
|
|
Loading…
Reference in a new issue