Rewrite offline page to use WebAssetManager
- All CSS/JS loading now uses $wa->useStyle/useScript matching index.php - Added template.offline and template.offline.min to joomla.asset.json - Font Awesome, Osaka font, themes, user overrides all via WAM Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -34,6 +34,18 @@
|
|||||||
"uri": "media/templates/site/mokocassiopeia/css/template.min.css",
|
"uri": "media/templates/site/mokocassiopeia/css/template.min.css",
|
||||||
"attributes": {"media": "all"}
|
"attributes": {"media": "all"}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "template.offline",
|
||||||
|
"type": "style",
|
||||||
|
"uri": "media/templates/site/mokocassiopeia/css/offline.css",
|
||||||
|
"attributes": {"media": "all"}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "template.offline.min",
|
||||||
|
"type": "style",
|
||||||
|
"uri": "media/templates/site/mokocassiopeia/css/offline.min.css",
|
||||||
|
"attributes": {"media": "all"}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "template.user",
|
"name": "template.user",
|
||||||
"type": "style",
|
"type": "style",
|
||||||
|
|||||||
@@ -26,56 +26,57 @@ use Joomla\CMS\Uri\Uri;
|
|||||||
|
|
||||||
$app = Factory::getApplication();
|
$app = Factory::getApplication();
|
||||||
$doc = Factory::getDocument();
|
$doc = Factory::getDocument();
|
||||||
|
$wa = $doc->getWebAssetManager();
|
||||||
$params = $this->params ?: $app->getTemplate(true)->params;
|
$params = $this->params ?: $app->getTemplate(true)->params;
|
||||||
$direction = $this->direction ?: 'ltr';
|
$direction = $this->direction ?: 'ltr';
|
||||||
|
|
||||||
/* -----------------------
|
/* -----------------------
|
||||||
Load CSS + theme palettes
|
Load assets via WebAssetManager (matches index.php pattern)
|
||||||
------------------------ */
|
------------------------ */
|
||||||
$useMin = !((int) $params->get('development_mode', 0) === 1);
|
$params_developmentmode = (bool) $params->get('developmentmode', false) || (bool) $app->get('debug', false);
|
||||||
$assetSuffix = $useMin ? '.min' : '';
|
$suffix = $params_developmentmode ? '' : '.min';
|
||||||
$base = rtrim(Uri::root(true), '/') . '/templates/' . $this->template . '/css/';
|
|
||||||
$jsBase = rtrim(Uri::root(true), '/') . '/templates/' . $this->template . '/js/';
|
|
||||||
|
|
||||||
$doc->addStyleSheet($base . 'template' . $assetSuffix . '.css', ['version' => 'auto'], ['id' => 'moko-template']);
|
// Core template CSS + offline overlay CSS
|
||||||
$doc->addStyleSheet($base . 'offline' . $assetSuffix . '.css', ['version' => 'auto'], ['id' => 'moko-offline']);
|
$wa->useStyle('template.base' . $suffix);
|
||||||
|
$wa->useStyle('template.offline' . $suffix);
|
||||||
|
|
||||||
/* Load Osaka font for site title */
|
// Osaka font
|
||||||
$doc->addStyleSheet($base . 'fonts/osaka.css', ['version' => 'auto'], ['id' => 'moko-font-osaka']);
|
$wa->useStyle('template.font.osaka');
|
||||||
|
|
||||||
/* Load Font Awesome 7 Free (local) — Kit code not supported on offline page */
|
// Font Awesome 7 Free
|
||||||
$faBase = rtrim(Uri::root(true), '/') . '/templates/' . $this->template . '/vendor/fa7free/css/';
|
$wa->useStyle('vendor.fa7free.all' . $suffix);
|
||||||
$doc->addStyleSheet($faBase . 'all' . $assetSuffix . '.css', ['version' => 'auto'], ['id' => 'moko-fa7free']);
|
|
||||||
|
|
||||||
/* Load theme palettes */
|
// Theme palettes
|
||||||
$doc->addStyleSheet($base . 'theme/light.standard' . $assetSuffix . '.css', ['version' => 'auto'], ['id' => 'moko-light-standard']);
|
$wa->useStyle('template.light.standard' . $suffix);
|
||||||
$doc->addStyleSheet($base . 'theme/dark.standard' . $assetSuffix . '.css', ['version' => 'auto'], ['id' => 'moko-dark-standard']);
|
$wa->useStyle('template.dark.standard' . $suffix);
|
||||||
|
|
||||||
/* Load custom palettes only if selected in template configuration AND files exist */
|
// Custom palettes (if selected and files exist)
|
||||||
$params_LightColorName = (string) $params->get('colorLightName', 'standard');
|
$params_LightColorName = (string) $params->get('colorLightName', 'standard');
|
||||||
$params_DarkColorName = (string) $params->get('colorDarkName', 'standard');
|
$params_DarkColorName = (string) $params->get('colorDarkName', 'standard');
|
||||||
if ($params_LightColorName === 'custom' && file_exists(JPATH_ROOT . '/media/templates/site/mokocassiopeia/css/theme/light.custom.css'))
|
if ($params_LightColorName === 'custom' && file_exists(JPATH_ROOT . '/media/templates/site/mokocassiopeia/css/theme/light.custom.css'))
|
||||||
{
|
{
|
||||||
$doc->addStyleSheet($base . 'theme/light.custom' . $assetSuffix . '.css', ['version' => 'auto'], ['id' => 'moko-light-custom']);
|
$wa->useStyle('template.light.custom' . $suffix);
|
||||||
}
|
}
|
||||||
if ($params_DarkColorName === 'custom' && file_exists(JPATH_ROOT . '/media/templates/site/mokocassiopeia/css/theme/dark.custom.css'))
|
if ($params_DarkColorName === 'custom' && file_exists(JPATH_ROOT . '/media/templates/site/mokocassiopeia/css/theme/dark.custom.css'))
|
||||||
{
|
{
|
||||||
$doc->addStyleSheet($base . 'theme/dark.custom' . $assetSuffix . '.css', ['version' => 'auto'], ['id' => 'moko-dark-custom']);
|
$wa->useStyle('template.dark.custom' . $suffix);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Load user assets last */
|
// User overrides (loaded last)
|
||||||
$doc->addStyleSheet($base . 'user' . $assetSuffix . '.css', ['version' => 'auto'], ['id' => 'moko-user']);
|
$wa->useStyle('template.user');
|
||||||
|
|
||||||
/* Bootstrap CSS/JS for accordion */
|
// Template JS (theme switcher, var-copy, etc.)
|
||||||
|
if ($params_developmentmode) {
|
||||||
|
$wa->useScript('template.js');
|
||||||
|
} else {
|
||||||
|
$wa->useScript('template.js.min');
|
||||||
|
}
|
||||||
|
$wa->useScript('user.js');
|
||||||
|
|
||||||
|
// Bootstrap (accordion)
|
||||||
HTMLHelper::_('bootstrap.loadCss', true, $doc);
|
HTMLHelper::_('bootstrap.loadCss', true, $doc);
|
||||||
HTMLHelper::_('bootstrap.framework');
|
HTMLHelper::_('bootstrap.framework');
|
||||||
|
|
||||||
/* Load template.js for theme switcher */
|
|
||||||
$doc->addScript($jsBase . 'template' . $assetSuffix . '.js', ['version' => 'auto', 'defer' => true], ['id' => 'moko-template-js']);
|
|
||||||
|
|
||||||
/* Load user.js last */
|
|
||||||
$doc->addScript($jsBase . 'user' . $assetSuffix . '.js', ['version' => 'auto', 'defer' => true], ['id' => 'moko-user-js']);
|
|
||||||
|
|
||||||
/* -----------------------
|
/* -----------------------
|
||||||
Title + Meta
|
Title + Meta
|
||||||
------------------------ */
|
------------------------ */
|
||||||
|
|||||||
Reference in New Issue
Block a user