diff --git a/includes/TimelessFileModule.php b/includes/TimelessFileModule.php new file mode 100644 index 0000000..9536fd2 --- /dev/null +++ b/includes/TimelessFileModule.php @@ -0,0 +1,46 @@ +getConfig(); + $background = $config->get( 'TimelessBackdropImage' ); + if ( $background === 'cat.svg' ) { + // expand default + $background = $config->get( 'StylePath' ) . '/Timeless/resources/images/cat.svg'; + } + + $background = OutputPage::transformResourcePath( $config, $background ); + $styles = parent::getStyles( $context ); + + $styles['all'][] = '#mw-content-container { background-image: ' . + CSSMin::buildUrlValue( $background ) . + '; }'; + + return $styles; + } + + /** + * Register the config var with the caching stuff so it properly updates the cache + * + * @param ResourceLoaderContext $context + * @return array + */ + public function getDefinitionSummary( ResourceLoaderContext $context ) { + $summary = parent::getDefinitionSummary( $context ); + $summary[] = [ + 'TimelessBackdropImage' => $this->getConfig()->get( 'TimelessBackdropImage' ) + ]; + return $summary; + } +} diff --git a/resources/screen-common.less b/resources/screen-common.less index 18a161a..33b9d64 100644 --- a/resources/screen-common.less +++ b/resources/screen-common.less @@ -26,10 +26,6 @@ body { z-index: 0; } -#mw-content-container { - background: @background2; -} - .mw-body { word-wrap: break-word; } @@ -217,7 +213,12 @@ body { /* Content */ #mw-content-container { + background: @background2; border-bottom: solid 4px @green; + + // Background image (default cat) set via TimelessFileModule + background-repeat: no-repeat; + background-position: center 10em; } #mw-page-header-links { diff --git a/resources/screen-desktop.less b/resources/screen-desktop.less index c204ad0..5e89b2f 100644 --- a/resources/screen-desktop.less +++ b/resources/screen-desktop.less @@ -13,12 +13,6 @@ margin: auto; } -#mw-content-container { - .background-image( 'images/cat.svg' ); - background-repeat: no-repeat; - background-position: center 15em; -} - /* Header */ #mw-header-container { diff --git a/skin.json b/skin.json index 5520906..d842460 100644 --- a/skin.json +++ b/skin.json @@ -18,10 +18,13 @@ "i18n" ] }, + "config": { + "TimelessBackdropImage": "cat.svg" + }, "ResourceModules": { "skins.timeless": { "targets": [ "desktop", "mobile" ], - "class": "ResourceLoaderSkinModule", + "class": "TimelessFileModule", "styles": { "resources/libraries/normalise.css": { "media": "screen" @@ -55,6 +58,7 @@ }, "skins.timeless.misc": { "targets": [ "desktop", "mobile" ], + "class": "ResourceLoaderSkinModule", "styles": [ "resources/screen-misc.less" ] @@ -90,7 +94,8 @@ }, "AutoloadClasses": { "SkinTimeless": "includes/SkinTimeless.php", - "TimelessTemplate": "includes/TimelessTemplate.php" + "TimelessTemplate": "includes/TimelessTemplate.php", + "TimelessFileModule": "includes/TimelessFileModule.php" }, "manifest_version": 1 }