Skip to content

Commit

Permalink
Minor correction in MInification for RSS Feed
Browse files Browse the repository at this point in the history
  • Loading branch information
hiteshaggarwal committed Sep 27, 2020
1 parent a178fff commit b6343a0
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,18 @@ public static function run()
Framework::getDebugger()->log('Lazy Load');
$app = \JFactory::getApplication();
$template = Framework::getTemplate();
$document = Framework::getDocument();
$params = $template->getParams();
$run = $params->get('lazyload', 0);
// Stop Lazy Load for RSSFeeds
$doc = \JFactory::getDocument();
if($doc->getType() == 'feed') {
$run = false;
}
Helper::createDir(ASTROID_CACHE . '/lazy-load/' . $template->id);
if (!$run) {
return;
}

Framework::getDocument()->addScript('vendor/astroid/js/lazyload.min.js');
// Stop Lazy Load for RSSFeeds
if ($document->getType() == 'feed') $run = false;

// Stop Lazy Load
if (!$run) return;

Helper::createDir(ASTROID_CACHE . '/lazy-load/' . $template->id);
$document->addScript('vendor/astroid/js/lazyload.min.js');

if ($params->get('lazyload_components', '')) {
$run = self::selectedComponents($params->get('lazyload_components', ''), $params->get('lazyload_components_action', 'include'));
Expand Down Expand Up @@ -96,7 +95,7 @@ public static function run()
}

if (Framework::getDebugger()->debug) {
Framework::getReporter('Lazy Load Images')->add('<a href="' . $matches[1][$key] . '" target="_blank"><code>' . Framework::getDocument()->beutifyURL($matches[1][$key]) . '</code></a>');
Framework::getReporter('Lazy Load Images')->add('<a href="' . $matches[1][$key] . '" target="_blank"><code>' . $document->beutifyURL($matches[1][$key]) . '</code></a>');
}

if (!isset($imageMap[md5($matches[1][$key])])) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,9 +339,8 @@ public static function custom()
// Page level custom code
$app = \JFactory::getApplication();
$itemid = $app->input->get('Itemid', '', 'INT');
if(empty($itemid)) {
return false;
}
if (empty($itemid)) return false;

$menu = $app->getMenu();
$item = $menu->getItem($itemid);
$params = $item->getParams();
Expand Down
33 changes: 16 additions & 17 deletions astroid/astroid-framework/framework/library/astroid/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class Document
protected $minify_html = false;
protected static $_fontawesome = false;
protected static $_layout_paths = [];
protected $type = null;

public function __construct()
{
Expand All @@ -38,11 +39,18 @@ public function __construct()
$this->minify_js = $params->get('minify_js', false);
$this->minify_html = $params->get('minify_html', false);

$doc = \JFactory::getDocument();
$this->type = $doc->getType();

$template = Framework::getTemplate();
$this->addLayoutPath(JPATH_SITE . '/templates/' . $template->template . '/html/frontend/');
}

public function getType()
{
return $this->type;
}

public function addLayoutPath($path)
{
self::$_layout_paths[] = $path;
Expand Down Expand Up @@ -103,25 +111,16 @@ public function compress()
{
$app = \JFactory::getApplication();
$body = $app->getBody();

// Stop Minification for RSSFeeds and other doc types.
$doc = \JFactory::getDocument();
if($doc->getType() == 'feed') {
$this->minify_css = false;
$this->minify_js = false;
$this->minify_html = false;
}
if ($this->minify_css) {
$body = $this->minifyCSS($body);
}

if ($this->minify_js && !$this->isFrontendEditing()) {
$body = $this->minifyJS($body);
}
// Stop Minification for RSSFeeds and other doc types.
if ($this->type == 'feed') $this->minify_css = $this->minify_js = $this->minify_html = false;

if ($this->minify_html) {
$body = $this->minifyHTML($body);
}
if ($this->minify_css) $body = $this->minifyCSS($body);

if ($this->minify_js && !$this->isFrontendEditing()) $body = $this->minifyJS($body);

if ($this->minify_html) $body = $this->minifyHTML($body);

$app->setBody($body);
}

Expand Down

0 comments on commit b6343a0

Please sign in to comment.