Skip to content

Commit

Permalink
Big push
Browse files Browse the repository at this point in the history
  • Loading branch information
C-Lodder committed May 27, 2020
1 parent 031d679 commit 27cbde0
Show file tree
Hide file tree
Showing 37 changed files with 928 additions and 160 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## WIP
- Template rendering performance improvements
- General performance improvements
- Switcher improvements
- Add various favicons
- Fix component grid position on error page
- Fix menu toggle causing JS error

## 0.0.10
- Revert some logical properties to support Chrome, Edge and Safari
- Fix some JS errors in Frontend Editing
Expand Down
2 changes: 2 additions & 0 deletions build-zip.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ template.file('template_preview.png')
template.file('template_thumbnail.png')
template.file('templateDetails.xml')
template.directory('css/')
template.directory('favicon/')
template.directory('helper/')
template.directory('html/')
template.directory('js/')
template.directory('language/')
Expand Down
3 changes: 1 addition & 2 deletions component.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
Joomla\CMS\HTML\HTMLHelper::_('stylesheet',
Joomla\CMS\Uri\Uri::root() . 'templates/lightning/css/modal.css', ['version' => 'auto']);
}

?>
<!DOCTYPE html>
<html lang="<?php echo $this->language; ?>" dir="<?php echo $this->direction; ?>">
Expand All @@ -27,7 +26,7 @@
<style><?php echo $css; ?></style>
<jdoc:include type="head" />
</head>
<body class="<?php echo $this->direction === 'rtl' ? 'rtl' : ''; ?>">
<body>
<jdoc:include type="message" />
<jdoc:include type="component" />

Expand Down
117 changes: 51 additions & 66 deletions error.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,17 @@

/** @var JDocumentError $this */

$app = Factory::getApplication();
$lang = Factory::getLanguage();

// Detecting Active Variables
$option = $app->input->getCmd('option', '');
$view = $app->input->getCmd('view', '');
$layout = $app->input->getCmd('layout', '');
$task = $app->input->getCmd('task', '');
$itemid = $app->input->getCmd('Itemid', '');
$sitename = htmlspecialchars($app->get('sitename'), ENT_QUOTES, 'UTF-8');
$menu = $app->getMenu()->getActive();
$pageclass = $menu !== null ? $menu->getParams()->get('pageclass_sfx', '') : '';
$app = Factory::getApplication();
$sitename = htmlspecialchars($app->get('sitename'), ENT_QUOTES, 'UTF-8');
$menu = $app->getMenu()->getActive();
$pageclass = $menu !== null ? $menu->getParams()->get('pageclass_sfx', '') : '';
$themeSwitcher = (boolean)$this->params->get('theme-switcher', true);

// Template params
$themeSwitcher = (boolean)$this->params->get('theme-switcher', true);
if ($themeSwitcher)
{
HTMLHelper::_('stylesheet', 'switch.css', ['version' => 'auto', 'relative' => true]);
HTMLHelper::_('script', 'switch.min.js', ['version' => 'auto', 'relative' => true]);
HTMLHelper::_('script', 'switch.min.js', ['version' => 'auto', 'relative' => true], ['type' => 'module']);
}

// Fetch CSS
Expand Down Expand Up @@ -62,15 +54,8 @@
<style><?php echo $css; ?></style>
</head>

<body class="site-grid site <?php echo $option
. ' view-' . $view
. ($layout ? ' layout-' . $layout : ' no-layout')
. ($task ? ' task-' . $task : ' no-task')
. ($itemid ? ' itemid-' . $itemid : '')
. ' ' . $pageclass;
echo ($this->direction == 'rtl' ? ' rtl' : '');
?>">
<header class="header full-width">
<body class="site-grid site <?php echo $pageclass; ?>">
<header class="grid-child container-header full-width header">
<nav class="navbar">
<div class="navbar-brand">
<a href="<?php echo $this->baseurl; ?>/">
Expand All @@ -89,53 +74,53 @@
</nav>
</header>

<div class="grid-child container-main">
<div class="container-component">
<h1><?php echo Text::_('JERROR_LAYOUT_PAGE_NOT_FOUND'); ?></h1>
<div class="card">
<jdoc:include type="message" />
<p><strong><?php echo Text::_('JERROR_LAYOUT_ERROR_HAS_OCCURRED_WHILE_PROCESSING_YOUR_REQUEST'); ?></strong></p>
<p><?php echo Text::_('JERROR_LAYOUT_NOT_ABLE_TO_VISIT'); ?></p>
<ul>
<li><?php echo Text::_('JERROR_LAYOUT_AN_OUT_OF_DATE_BOOKMARK_FAVOURITE'); ?></li>
<li><?php echo Text::_('JERROR_LAYOUT_MIS_TYPED_ADDRESS'); ?></li>
<li><?php echo Text::_('JERROR_LAYOUT_SEARCH_ENGINE_OUT_OF_DATE_LISTING'); ?></li>
<li><?php echo Text::_('JERROR_LAYOUT_YOU_HAVE_NO_ACCESS_TO_THIS_PAGE'); ?></li>
</ul>
<p><?php echo Text::_('JERROR_LAYOUT_GO_TO_THE_HOME_PAGE'); ?></p>
<p><a href="<?php echo $this->baseurl; ?>/index.php"><?php echo Text::_('JERROR_LAYOUT_HOME_PAGE'); ?></a></p>
<hr>
<p><?php echo Text::_('JERROR_LAYOUT_PLEASE_CONTACT_THE_SYSTEM_ADMINISTRATOR'); ?></p>
<blockquote>
<span class="badge badge-primary"><?php echo $this->error->getCode(); ?></span> <?php echo htmlspecialchars($this->error->getMessage(), ENT_QUOTES, 'UTF-8'); ?>
</blockquote>
<?php if ($this->debug) : ?>
<div>
<?php echo $this->renderBacktrace(); ?>
<?php // Check if there are more Exceptions and render their data as well ?>
<?php if ($this->error->getPrevious()) : ?>
<?php $loop = true; ?>
<?php // Reference $this->_error here and in the loop as setError() assigns errors to this property and we need this for the backtrace to work correctly ?>
<?php // Make the first assignment to setError() outside the loop so the loop does not skip Exceptions ?>
<?php $this->setError($this->_error->getPrevious()); ?>
<?php while ($loop === true) : ?>
<p><strong><?php echo Text::_('JERROR_LAYOUT_PREVIOUS_ERROR'); ?></strong></p>
<p><?php echo htmlspecialchars($this->_error->getMessage(), ENT_QUOTES, 'UTF-8'); ?></p>
<?php echo $this->renderBacktrace(); ?>
<?php $loop = $this->setError($this->_error->getPrevious()); ?>
<?php endwhile; ?>
<?php // Reset the main error object to the base error ?>
<?php $this->setError($this->error); ?>
<?php endif; ?>
</div>
<?php endif; ?>
</div>
<div class="grid-child container-component">
<h1><?php echo Text::_('JERROR_LAYOUT_PAGE_NOT_FOUND'); ?></h1>
<div class="card">
<jdoc:include type="message" />
<p><strong><?php echo Text::_('JERROR_LAYOUT_ERROR_HAS_OCCURRED_WHILE_PROCESSING_YOUR_REQUEST'); ?></strong></p>
<p><?php echo Text::_('JERROR_LAYOUT_NOT_ABLE_TO_VISIT'); ?></p>
<ul>
<li><?php echo Text::_('JERROR_LAYOUT_AN_OUT_OF_DATE_BOOKMARK_FAVOURITE'); ?></li>
<li><?php echo Text::_('JERROR_LAYOUT_MIS_TYPED_ADDRESS'); ?></li>
<li><?php echo Text::_('JERROR_LAYOUT_SEARCH_ENGINE_OUT_OF_DATE_LISTING'); ?></li>
<li><?php echo Text::_('JERROR_LAYOUT_YOU_HAVE_NO_ACCESS_TO_THIS_PAGE'); ?></li>
</ul>
<p><?php echo Text::_('JERROR_LAYOUT_GO_TO_THE_HOME_PAGE'); ?></p>
<p><a href="<?php echo $this->baseurl; ?>/index.php"><?php echo Text::_('JERROR_LAYOUT_HOME_PAGE'); ?></a></p>
<hr>
<p><?php echo Text::_('JERROR_LAYOUT_PLEASE_CONTACT_THE_SYSTEM_ADMINISTRATOR'); ?></p>
<blockquote>
<span class="badge badge-primary"><?php echo $this->error->getCode(); ?></span> <?php echo htmlspecialchars($this->error->getMessage(), ENT_QUOTES, 'UTF-8'); ?>
</blockquote>
<?php if ($this->debug) : ?>
<div>
<?php echo $this->renderBacktrace(); ?>
<?php // Check if there are more Exceptions and render their data as well ?>
<?php if ($this->error->getPrevious()) : ?>
<?php $loop = true; ?>
<?php // Reference $this->_error here and in the loop as setError() assigns errors to this property and we need this for the backtrace to work correctly ?>
<?php // Make the first assignment to setError() outside the loop so the loop does not skip Exceptions ?>
<?php $this->setError($this->_error->getPrevious()); ?>
<?php while ($loop === true) : ?>
<p><strong><?php echo Text::_('JERROR_LAYOUT_PREVIOUS_ERROR'); ?></strong></p>
<p><?php echo htmlspecialchars($this->_error->getMessage(), ENT_QUOTES, 'UTF-8'); ?></p>
<?php echo $this->renderBacktrace(); ?>
<?php $loop = $this->setError($this->_error->getPrevious()); ?>
<?php endwhile; ?>
<?php // Reset the main error object to the base error ?>
<?php $this->setError($this->error); ?>
<?php endif; ?>
</div>
<?php endif; ?>
</div>
</div>

<?php if ($this->countModules('footer')) : ?>
<footer class="grid-child container-footer footer">
<jdoc:include type="modules" name="footer" style="none" />
<footer class="grid-child container-footer full-width footer">
<div class="container">
<jdoc:include type="modules" name="footer" style="none" />
</div>
</footer>
<?php endif; ?>

Expand Down
Binary file removed favicon.ico
Binary file not shown.
Binary file added favicon/android-chrome-192x192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added favicon/android-chrome-512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added favicon/apple-touch-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions favicon/browserconfig.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<browserconfig>
<msapplication>
<tile>
<square150x150logo src="/mstile-150x150.png"/>
<TileColor>#ffffff</TileColor>
</tile>
</msapplication>
</browserconfig>
Binary file added favicon/favicon-16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added favicon/favicon-32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added favicon/favicon.ico
Binary file not shown.
Binary file added favicon/mstile-144x144.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added favicon/mstile-150x150.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added favicon/mstile-310x150.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added favicon/mstile-310x310.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added favicon/mstile-70x70.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions favicon/safari-pinned-tab.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions favicon/site.webmanifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "",
"short_name": "",
"icons": [
{
"src": "/android-chrome-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "/android-chrome-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
],
"theme_color": "#ffffff",
"background_color": "#ffffff",
"display": "standalone"
}
142 changes: 142 additions & 0 deletions helper/metas.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
<?php
namespace Joomla\CMS\Document\Renderer\Html;

\defined('JPATH_PLATFORM') || die;

use Joomla\CMS\Document\DocumentRenderer;
use Joomla\CMS\Factory;
use Joomla\CMS\Helper\TagsHelper;
use Joomla\CMS\WebAsset\WebAssetAttachBehaviorInterface;
use Joomla\Utilities\ArrayHelper;

class metasRenderer extends DocumentRenderer
{
/**
* Renders the document metas and returns the results as a string
*
* @param string $head (unused)
* @param array $params Associative array of values
* @param string $content The script
*
* @return string The output of the script
*
* @since 4.0.0
*/
public function render($head, $params = [], $content = null)
{
// Convert the tagids to titles
if (isset($this->_doc->_metaTags['name']['tags']))
{
$tagsHelper = new TagsHelper;
$this->_doc->_metaTags['name']['tags'] = implode(', ', $tagsHelper->getTagNames($this->_doc->_metaTags['name']['tags']));
}

/** @var \Joomla\CMS\Application\CMSApplication $app */
$wa = $this->_doc->getWebAssetManager();
$wc = $this->_doc->getScriptOptions('webcomponents');

// Check for AttachBehavior and web components
foreach ($wa->getAssets('script', true) as $asset)
{
if ($asset instanceof WebAssetAttachBehaviorInterface)
{
$asset->onAttachCallback($this->_doc);
}

if ($asset->getOption('webcomponent'))
{
$wc[] = $asset->getUri();
}
}

if ($wc)
{
$this->_doc->addScriptOptions('webcomponents', array_unique($wc));
}

// Trigger the onBeforeCompileHead event
Factory::getApplication()->triggerEvent('onBeforeCompileHead');

// Add Script Options as inline asset
$scriptOptions = $this->_doc->getScriptOptions();

if ($scriptOptions)
{
$prettyPrint = (JDEBUG && \defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : false);
$jsonOptions = json_encode($scriptOptions, $prettyPrint);
$jsonOptions = $jsonOptions ? $jsonOptions : '{}';

$wa->addInlineScript(
$jsonOptions,
['name' => 'joomla.script.options', 'position' => 'before'],
['type' => 'application/json', 'class' => 'joomla-script-options new'],
['core']
);
}

// Lock the AssetManager
$wa->lock();

$buffer = '';

// Generate charset when using HTML5 (should happen first)
$buffer .= '<meta charset="' . $this->_doc->getCharset() . '">';

// Generate base tag (need to happen early)
$base = $this->_doc->getBase();

if (!empty($base))
{
$buffer .= '<base href="' . $base . '">';
}

// Generate META tags (needs to happen as early as possible in the head)
foreach ($this->_doc->_metaTags as $type => $tag)
{
foreach ($tag as $name => $contents)
{
if ($type !== 'http-equiv' && !empty($contents))
{
$buffer .= '<meta ' . $type . '="' . $name . '" content="'
. htmlspecialchars($contents, ENT_COMPAT, 'UTF-8') . '">';
}
}
}

// Don't add empty descriptions
$documentDescription = $this->_doc->getDescription();

if ($documentDescription)
{
$buffer .= '<meta name="description" content="' . htmlspecialchars($documentDescription, ENT_COMPAT, 'UTF-8') . '">';
}

// Don't add empty generators
$generator = $this->_doc->getGenerator();

if ($generator)
{
$buffer .= '<meta name="generator" content="' . htmlspecialchars($generator, ENT_COMPAT, 'UTF-8') . '">';
}

$buffer .= '<title>' . htmlspecialchars($this->_doc->getTitle(), ENT_COMPAT, 'UTF-8') . '</title>';

// Generate link declarations
foreach ($this->_doc->_links as $link => $linkAtrr)
{
$buffer .= '<link href="' . $link . '" ' . $linkAtrr['relType'] . '="' . $linkAtrr['relation'] . '"';

if (\is_array($linkAtrr['attribs']))
{
if ($temp = ArrayHelper::toString($linkAtrr['attribs']))
{
$buffer .= ' ' . $temp;
}
}

$buffer .= '>';
}

return ltrim($buffer);
}
}
Loading

0 comments on commit 27cbde0

Please sign in to comment.