mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/Vector.git
synced 2024-11-28 09:30:17 +00:00
Merge "Add print logo"
This commit is contained in:
commit
cf999f4e17
26
README.md
Normal file
26
README.md
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
Vector Skin
|
||||||
|
========================
|
||||||
|
|
||||||
|
Configuration options
|
||||||
|
---------------------
|
||||||
|
|
||||||
|
### $wgVectorPrintLogo
|
||||||
|
|
||||||
|
Logo used in print styles. Keys are `url`, `width`, and `height` (in
|
||||||
|
pixels). Note that this solution only works correctly if the image
|
||||||
|
pointed to by `url` is an SVG that does not specify width and height
|
||||||
|
attributes, or its width and height match the corresponding variables
|
||||||
|
below. Alternatively, a PNG or other type of image can be used, but
|
||||||
|
its dimensions also need to match the corresponding variable below.
|
||||||
|
That in turn may result in blurry images, though.
|
||||||
|
|
||||||
|
Example configuration:
|
||||||
|
|
||||||
|
$wgVectorPrintLogo = [
|
||||||
|
'url' => 'https://en.wikipedia.org/static/images/mobile/copyright/wikipedia-wordmark-en.svg',
|
||||||
|
'width' => 174,
|
||||||
|
'height' => 27
|
||||||
|
];
|
||||||
|
|
||||||
|
* Type: `Array`
|
||||||
|
* Default: `false`
|
55
ResourceLoaderLessModule.php
Normal file
55
ResourceLoaderLessModule.php
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
<?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 ConfigFactory;
|
||||||
|
use CSSMin;
|
||||||
|
use MediaWiki\MediaWikiServices;
|
||||||
|
use ResourceLoaderContext;
|
||||||
|
use ResourceLoaderFileModule;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ResourceLoader module for print styles.
|
||||||
|
*/
|
||||||
|
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 );
|
||||||
|
$config = MediaWikiServices::getInstance()->getConfigFactory()->makeConfig( 'vector' );
|
||||||
|
$printLogo = $config->get( 'VectorPrintLogo' );
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
16
print.less
16
print.less
|
@ -40,6 +40,22 @@
|
||||||
line-height: 28pt;
|
line-height: 28pt;
|
||||||
margin-bottom: 20px;
|
margin-bottom: 20px;
|
||||||
padding-bottom: 5px;
|
padding-bottom: 5px;
|
||||||
|
|
||||||
|
// 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';
|
||||||
|
line-height: 0; // line-height is needed for correctly displaying the size of the content box.
|
||||||
|
margin-bottom: 10px;
|
||||||
|
width: ~'@{printLogoWidth}px';
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Headings
|
// Headings
|
||||||
|
|
|
@ -27,7 +27,8 @@
|
||||||
"AutoloadClasses": {
|
"AutoloadClasses": {
|
||||||
"VectorHooks": "Hooks.php",
|
"VectorHooks": "Hooks.php",
|
||||||
"SkinVector": "SkinVector.php",
|
"SkinVector": "SkinVector.php",
|
||||||
"VectorTemplate": "VectorTemplate.php"
|
"VectorTemplate": "VectorTemplate.php",
|
||||||
|
"Vector\\ResourceLoaderLessModule": "ResourceLoaderLessModule.php"
|
||||||
},
|
},
|
||||||
"Hooks": {
|
"Hooks": {
|
||||||
"BeforePageDisplayMobile": [
|
"BeforePageDisplayMobile": [
|
||||||
|
@ -49,6 +50,7 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"skins.vector.styles.experimental.print": {
|
"skins.vector.styles.experimental.print": {
|
||||||
|
"class": "Vector\\ResourceLoaderLessModule",
|
||||||
"targets": [ "desktop", "mobile" ],
|
"targets": [ "desktop", "mobile" ],
|
||||||
"position": "top",
|
"position": "top",
|
||||||
"styles": [
|
"styles": [
|
||||||
|
@ -110,7 +112,8 @@
|
||||||
"VectorUseIconWatch": true,
|
"VectorUseIconWatch": true,
|
||||||
"@VectorExperimentalPrintStyles": "Temporary config variable to feature flag new print styles (T154965)",
|
"@VectorExperimentalPrintStyles": "Temporary config variable to feature flag new print styles (T154965)",
|
||||||
"VectorExperimentalPrintStyles": false,
|
"VectorExperimentalPrintStyles": false,
|
||||||
"VectorResponsive": false
|
"VectorResponsive": false,
|
||||||
|
"VectorPrintLogo": false
|
||||||
},
|
},
|
||||||
"manifest_version": 1
|
"manifest_version": 1
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue