Drop usage of mediawiki.skinning.interface module in favor of SkinModule

Thanks to the dependent change, the print logo is now provided
in core so we can remove the custom Vector ResourceLoader module

ResourceLoaderLessModule is replaced with a ResourceLoaderSkinModule
and gains the features capability replacing the need for
'mediawiki.skinning.interface' making use of the changes added in
6845912bcf1.

Note that for cached HTML both 'mediawiki.skinning.interface'
and skins.vector.styles will be loaded. We can avoid this
by renaming skins.vector.styles if necessary (but I'm not
sure if we'd want to do that)

Bug: T232140
Depends-On: I00899c16c0325f36b671baf17e88c2b5187b3526
Change-Id: I569e0d800e147eabc7852567acd140108613f074
This commit is contained in:
jdlrobson 2019-11-12 11:09:26 -08:00
parent 1f53b4c99b
commit 2dbe4d7af1
4 changed files with 3 additions and 99 deletions

View File

@ -1,64 +0,0 @@
<?php
/**
* ResourceLoader module for print styles.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* http://www.gnu.org/copyleft/gpl.html
*
* @file
*/
namespace Vector;
use ConfigException;
use CSSMin;
use MediaWiki\MediaWikiServices;
use ResourceLoaderContext;
use ResourceLoaderFileModule;
/**
* ResourceLoader module for print styles.
*
* This class is also used when rendering styles for the MediaWiki installer.
* Do not rely on any of the normal global state, services, etc., and make sure
* to test the installer after making any changes here.
*/
class ResourceLoaderLessModule extends ResourceLoaderFileModule {
/**
* Get language-specific LESS variables for this module.
*
* @param ResourceLoaderContext $context
* @return array
*/
protected function getLessVars( ResourceLoaderContext $context ) {
$lessVars = parent::getLessVars( $context );
try {
$config = MediaWikiServices::getInstance()->getConfigFactory()->makeConfig( 'vector' );
$printLogo = $config->get( 'VectorPrintLogo' );
} catch ( ConfigException $e ) {
// Config is not available when running in the context of the MediaWiki installer. (T183640)
$printLogo = false;
}
if ( $printLogo ) {
$lessVars[ 'printLogo' ] = true;
$lessVars[ 'printLogoUrl' ] = CSSMin::buildUrlValue( $printLogo['url'] );
$lessVars[ 'printLogoWidth' ] = intval( $printLogo['width'] );
$lessVars[ 'printLogoHeight' ] = intval( $printLogo['height'] );
} else {
$lessVars[ 'printLogo' ] = false;
}
return $lessVars;
}
}

View File

@ -64,7 +64,6 @@ class SkinVector extends SkinTemplate {
public function getDefaultModules() {
$modules = parent::getDefaultModules();
// add vector skin styles and vector module
$modules['styles']['skin'][] = 'mediawiki.skinning.interface';
$modules['styles']['skin'][] = 'skins.vector.styles';
$modules['core'][] = 'skins.vector.js';

View File

@ -6,29 +6,6 @@
@border-color-base: @wmui-color-base0;
@border-color-footer: #eee;
// We have to render the wordmark image before the print dialog is invoked, otherwise the image
// won't render in the printed file. Use a little hack to render the image outside the viewport
// and bring it in the viewport in print view.
.firstHeading {
// We could also use a CSS background to display the logo.
// The problem is that the logo won't be printed unless the user prints the background too.
// Note. This specification does not fully define the interaction of :before and :after with
// replaced elements (such as IMG in HTML). This will be defined in more detail in a future
// specification. See https://www.w3.org/TR/CSS2/generate.html#before-after-content
& when( @printLogo = 1 ) {
&:before {
content: @printLogoUrl;
display: block;
height: ~'@{printLogoHeight}px';
left: -9999px;
line-height: 0; // line-height is needed for correctly displaying the size of the content box.
margin-bottom: 20px;
position: absolute;
width: ~'@{printLogoWidth}px';
}
}
}
@media print {
/* These styles retain the existing typography in screen.less
@ -79,14 +56,6 @@
line-height: 28pt;
margin-bottom: 20px;
padding-bottom: 5px;
// Bring back the wordmark to the viewport (see above how it's rendered outside the viewport).
& when( @printLogo = 1 ) {
&:before {
left: auto;
position: relative;
}
}
}
// Headings

View File

@ -24,8 +24,7 @@
"AutoloadClasses": {
"Vector\\Hooks": "includes/Hooks.php",
"SkinVector": "includes/SkinVector.php",
"VectorTemplate": "includes/VectorTemplate.php",
"Vector\\ResourceLoaderLessModule": "includes/ResourceLoaderLessModule.php"
"VectorTemplate": "includes/VectorTemplate.php"
},
"Hooks": {
"BeforePageDisplayMobile": "Vector\\Hooks::onBeforePageDisplayMobile"
@ -33,7 +32,8 @@
"@note": "When modifying skins.vector.styles definition, make sure the installer still works",
"ResourceModules": {
"skins.vector.styles": {
"class": "Vector\\ResourceLoaderLessModule",
"class": "ResourceLoaderSkinModule",
"features": [ "elements", "content", "interface", "logo" ],
"targets": [
"desktop",
"mobile"