Skip to content

Commit

Permalink
Favicon updates
Browse files Browse the repository at this point in the history
  • Loading branch information
C-Lodder committed Feb 17, 2022
1 parent 71711e5 commit 6f0911c
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 11 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Changelog

## WIP
- Add ability to override favicon
- Favicon now displays on error and offline pages
- Force `color-scheme` for dark mode

## 1.3.0
Expand Down
10 changes: 10 additions & 0 deletions error.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Layout\FileLayout;
use Joomla\CMS\Uri\Uri;

/** @var Joomla\CMS\Document\HtmlDocument $this */
Expand All @@ -23,6 +24,9 @@
$themeSwitcher = (boolean)$this->params->get('theme-switcher', 1);
$fontAwesome = (boolean)$this->params->get('font-awesome-thats-actually-rather-shit', 1);
$googleFont = $this->params->get('google-font', '');
$faviconPath = (boolean)$this->params->get('favicon-override', 0)
? JPATH_ROOT
: 'templates/' . $this->template . '/favicon';

// Template params
if ($themeSwitcher)
Expand Down Expand Up @@ -73,6 +77,12 @@
}

$this->setMetaData('viewport', 'width=device-width, initial-scale=1');
$this->setMetaData('theme-color', '#ffffff');

$imageLayout = new FileLayout('lightning.favicon');
$imageLayout->render([
'path' => 'templates/' . $this->template . '/favicon',
]);
?>
<!DOCTYPE html>
<html lang="<?php echo $this->language; ?>" dir="<?php echo $this->direction; ?>">
Expand Down
22 changes: 22 additions & 0 deletions html/layouts/lightning/favicon.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
defined('_JEXEC') or die;

use Joomla\CMS\Factory;

extract($displayData);

$doc = Factory::getApplication()->getDocument();

/**
* @var string $path
*/

$doc->setMetaData('msapplication-config', $path . '/browserconfig.xml');
$doc->setMetaData('msapplication-TileColor', '#ffffff');

$doc->addHeadLink($path . '/apple-touch-icon.png', 'apple-touch-icon', 'rel', ['sizes' => '180x180']);
$doc->addHeadLink($path . '/favicon-32x32.png', 'icon', 'rel', ['sizes' => '32x32']);
$doc->addHeadLink($path . '/favicon-16x16.png', 'icon', 'rel', ['sizes' => '16x16']);
$doc->addHeadLink($path . '/site.webmanifest.json', 'manifest');
$doc->addHeadLink($path . '/safari-pinned-tab.svg', 'mask-icon', 'rel', ['color' => '#006bd6']);
$doc->addHeadLink($path . '/favicon.ico', 'shortcut icon');
20 changes: 9 additions & 11 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Layout\FileLayout;
use Joomla\CMS\Uri\Uri;

/** @var Joomla\CMS\Document\HtmlDocument $this */
Expand All @@ -23,6 +24,9 @@
$hideComponent = (boolean)$this->params->get('hide-component', 0);
$fontAwesome = (boolean)$this->params->get('font-awesome-thats-actually-rather-shit', 1);
$googleFont = $this->params->get('google-font', '');
$faviconPath = (boolean)$this->params->get('favicon-override', 0)
? JPATH_ROOT
: 'templates/' . $this->template . '/favicon';

// Load switcher CSS
if ($themeSwitcher)
Expand Down Expand Up @@ -84,19 +88,13 @@
$hasSidebar .= ' has-sidebar-right';
}

$faviconPath = 'templates/' . $this->template . '/favicon';

$this->setMetaData('viewport', 'width=device-width, initial-scale=1');
$this->setMetaData('theme-color', '#ffffff');
$this->setMetaData('msapplication-config', $faviconPath . '/browserconfig.xml');
$this->setMetaData('msapplication-TileColor', '#ffffff');

$this->addHeadLink($faviconPath . '/apple-touch-icon.png', 'apple-touch-icon', 'rel', ['sizes' => '180x180']);
$this->addHeadLink($faviconPath . '/favicon-32x32.png', 'icon', 'rel', ['sizes' => '32x32']);
$this->addHeadLink($faviconPath . '/favicon-16x16.png', 'icon', 'rel', ['sizes' => '16x16']);
$this->addHeadLink($faviconPath . '/site.webmanifest.json', 'manifest');
$this->addHeadLink($faviconPath . '/safari-pinned-tab.svg', 'mask-icon', 'rel', ['color' => '#006bd6']);
$this->addHeadLink($faviconPath . '/favicon.ico', 'shortcut icon');

$imageLayout = new FileLayout('lightning.favicon');
$imageLayout->render([
'path' => 'templates/' . $this->template . '/favicon',
]);

$menu = $this->getBuffer('modules', 'menu', $attribs = ['style' => 'none']);
$search = $this->getBuffer('modules', 'search', $attribs = ['style' => 'none']);
Expand Down
3 changes: 3 additions & 0 deletions language/en-GB/en-GB.tpl_lightning.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
TPL_LIGHTNING_XML_DESCRIPTION="Lightning is a blazingly fast Joomla 4 template, using the HiQ CSS framework."

; Parameters
TPL_LIGHTNING_FAVICON_OVERRIDE="Override Favicon"
TPL_LIGHTNING_FAVICON_OVERRIDE_DESC="If you wish to override the default favicon, enable this option and upload your favicon files to the ROOT of your Joomla installation"

TPL_LIGHTNING_FIELDSET_ABOUT="About"
TPL_LIGHTNING_FIELDSET_ABOUT_VERSION="Version"
TPL_LIGHTNING_FIELDSET_ABOUT_REPORT_BUG="Report a bug"
Expand Down
3 changes: 3 additions & 0 deletions language/fr-FR/fr-FR.tpl_lightning.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
TPL_LIGHTNING_XML_DESCRIPTION="Lightning est un template pour Joomla 4 rapide comme l'éclair, utilisant l'infrastructure logicielle HiQ CSS."

; Parameters
TPL_LIGHTNING_FAVICON_OVERRIDE="Override Favicon"
TPL_LIGHTNING_FAVICON_OVERRIDE_DESC="If you wish to override the default favicon, enable this option and upload your favicon files to the ROOT of your Joomla installation"

TPL_LIGHTNING_FIELDSET_ABOUT="A propos"
TPL_LIGHTNING_FIELDSET_ABOUT_VERSION="Version"
TPL_LIGHTNING_FIELDSET_ABOUT_REPORT_BUG="Signaler une anomalie"
Expand Down
12 changes: 12 additions & 0 deletions offline.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Joomla\CMS\Helper\AuthenticationHelper;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Layout\FileLayout;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Uri\Uri;

Expand All @@ -26,6 +27,9 @@
$themeSwitcher = (boolean)$this->params->get('theme-switcher', 1);
$fontAwesome = (boolean)$this->params->get('font-awesome-thats-actually-rather-shit', 1);
$googleFont = $this->params->get('google-font', '');
$faviconPath = (boolean)$this->params->get('favicon-override', 0)
? JPATH_ROOT
: 'templates/' . $this->template . '/favicon';

// Load switcher CSS
if ($themeSwitcher)
Expand Down Expand Up @@ -75,6 +79,14 @@
{
$logo = '<span title="' . $sitename . '">' . htmlspecialchars($this->params->get('siteTitle'), ENT_COMPAT, 'UTF-8') . '</span>';
}

$this->setMetaData('viewport', 'width=device-width, initial-scale=1');
$this->setMetaData('theme-color', '#ffffff');

$imageLayout = new FileLayout('lightning.favicon');
$imageLayout->render([
'path' => 'templates/' . $this->template . '/favicon',
]);
?>
<!DOCTYPE html>
<html lang="<?php echo $this->language; ?>" dir="<?php echo $this->direction; ?>">
Expand Down
12 changes: 12 additions & 0 deletions templateDetails.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,18 @@
default=""
label="TPL_LIGHTNING_GOOGLE_FONTS"
/>

<field
name="favicon-override"
type="radio"
layout="joomla.form.field.radio.switcher"
default="0"
label="TPL_LIGHTNING_FAVICON_OVERRIDE"
description="TPL_LIGHTNING_FAVICON_OVERRIDE_DESC"
>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
</fieldset>

<fieldset name="logo" label="TPL_LIGHTNING_FIELDSET_LOGO">
Expand Down

0 comments on commit 6f0911c

Please sign in to comment.