diff --git a/includes/TimelessFileModule.php b/includes/TimelessFileModule.php deleted file mode 100644 index 9536fd2..0000000 --- a/includes/TimelessFileModule.php +++ /dev/null @@ -1,46 +0,0 @@ -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/includes/TimelessVariablesModule.php b/includes/TimelessVariablesModule.php new file mode 100644 index 0000000..e516e20 --- /dev/null +++ b/includes/TimelessVariablesModule.php @@ -0,0 +1,50 @@ +getConfig(); + + // Backdrop image + $backdrop = $config->get( 'TimelessBackdropImage' ); + + if ( $backdrop === 'cat.svg' ) { + // expand default + $backdrop = 'images/cat.svg'; + } + + $vars = array_merge( + $vars, + [ + 'backdrop-image' => "url($backdrop)", + // 'logo-image' => '' + // 'wordmark-image' => '' + // +width cutoffs ... + ] + ); + + return $vars; + } + + /** + * 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 e94d75c..40e8a68 100644 --- a/resources/screen-common.less +++ b/resources/screen-common.less @@ -196,7 +196,8 @@ body { background: @base80; border-bottom: solid 4px @green; - // Background image (default cat) set via TimelessFileModule + // Background image (default cat) + background-image: @backdrop-image; background-repeat: no-repeat; background-position: center 10em; } diff --git a/skin.json b/skin.json index fdb371e..a8e2454 100644 --- a/skin.json +++ b/skin.json @@ -24,7 +24,7 @@ "ResourceModules": { "skins.timeless": { "targets": [ "desktop", "mobile" ], - "class": "TimelessFileModule", + "class": "TimelessVariablesModule", "styles": { "resources/libraries/normalise.css": { "media": "screen" @@ -97,7 +97,7 @@ "AutoloadClasses": { "SkinTimeless": "includes/SkinTimeless.php", "TimelessTemplate": "includes/TimelessTemplate.php", - "TimelessFileModule": "includes/TimelessFileModule.php" + "TimelessVariablesModule": "includes/TimelessVariablesModule.php" }, "manifest_version": 1 }