mirror of
https://github.com/gantry/gantry5.git
synced 2026-08-19 01:15:04 -05:00
Grav: Fixed CSS/JS pipelines, though you need to set js_minify: false (#2001)
This commit is contained in:
+4
-1
@@ -24,7 +24,10 @@
|
||||
- Fixed checkboxes next to the setting enablers in Content tab getting unchecked after refresh (#1986)
|
||||
- Fixed `Missing argument 2 for modify_gantry5_locale()`
|
||||
- Fixed external scripts and CSS with query parameters being broken (#1975)
|
||||
|
||||
4. [Grav](#grav)
|
||||
3. [](#bugfix)
|
||||
- Fixed CSS/JS pipelines, though you need to set `js_minify: false` (#2001)
|
||||
|
||||
# 5.4.12
|
||||
## 04/26/2017
|
||||
|
||||
|
||||
@@ -58,6 +58,8 @@
|
||||
{{ gantry.document.getHtml('body_bottom')|join("\n ")|raw }}
|
||||
{% endset -%}
|
||||
|
||||
{%- do gantry.document.addScript(url('gantry-assets://js/main.js'), 11, 'footer') -%}
|
||||
|
||||
{# Head and footer needs to come last because of any of the above blocks may have CSS or JavaScript in them #}
|
||||
|
||||
{%- set page_head %}
|
||||
@@ -93,7 +95,6 @@
|
||||
{{ page_bottom|raw }}
|
||||
</div>
|
||||
{{ body_bottom|raw }}
|
||||
<script type="text/javascript" src="{{ url('gantry-assets://js/main.js') }}"></script>
|
||||
{{ page_footer|raw }}
|
||||
{{ gantry.config.page.body.body_bottom|raw }}
|
||||
</body>
|
||||
|
||||
@@ -2,5 +2,4 @@
|
||||
|
||||
{% block page_footer %}
|
||||
{{ assets.js('bottom')|raw }}
|
||||
{{ parent() }}
|
||||
{% endblock %}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
namespace Gantry\Framework;
|
||||
|
||||
use Gantry\Component\Content\Document\HtmlDocument;
|
||||
use Grav\Common\Assets;
|
||||
use Grav\Common\Config\Config;
|
||||
use Grav\Common\Grav;
|
||||
use Grav\Common\Language\Language;
|
||||
@@ -22,6 +23,7 @@ class Document extends HtmlDocument
|
||||
static::registerFrameworks();
|
||||
static::registerStyles();
|
||||
static::registerScripts('head');
|
||||
static::registerScripts('footer');
|
||||
}
|
||||
|
||||
public static function rootUri()
|
||||
@@ -62,15 +64,22 @@ class Document extends HtmlDocument
|
||||
{
|
||||
$grav = Grav::instance();
|
||||
|
||||
/** @var Assets $assets */
|
||||
$assets = $grav['assets'];
|
||||
|
||||
$styles = static::$stack[0]->getStyles();
|
||||
|
||||
foreach ($styles as $style) {
|
||||
switch ($style[':type']) {
|
||||
case 'file':
|
||||
$grav['assets']->addCss(static::getRelativeUrl($style['href'], $grav['config']->get('system.assets.css_pipeline')), 90 + $style[':priority']);
|
||||
$assets->addCss(
|
||||
static::getRelativeUrl($style['href'], $grav['config']->get('system.assets.css_pipeline')),
|
||||
90 + $style[':priority'],
|
||||
true,
|
||||
'head');
|
||||
break;
|
||||
case 'inline':
|
||||
$grav['assets']->addInlineCss($style['content'], 90 + $style[':priority']);
|
||||
$assets->addInlineCss($style['content'], 90 + $style[':priority'], 'head');
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -80,22 +89,28 @@ class Document extends HtmlDocument
|
||||
{
|
||||
$grav = Grav::instance();
|
||||
|
||||
/** @var Assets $assets */
|
||||
$assets = $grav['assets'];
|
||||
|
||||
$scripts = static::$stack[0]->getScripts($group);
|
||||
$group = $group === 'footer' ? 'bottom' : $group;
|
||||
|
||||
foreach ($scripts as $script) {
|
||||
switch ($script[':type']) {
|
||||
case 'file':
|
||||
$grav['assets']->AddJs(static::getRelativeUrl($script['src'], $grav['config']->get('system.assets.js_pipeline')), [
|
||||
'priority' => 90 + $script[':priority'],
|
||||
'loading' => ($script['async'] ? 'async' : ($script['defer'] ? 'defer' : '')),
|
||||
'group' => $group,
|
||||
]);
|
||||
$assets->AddJs(
|
||||
static::getRelativeUrl($script['src'], $grav['config']->get('system.assets.js_pipeline')),
|
||||
90 + $script[':priority'],
|
||||
true,
|
||||
$script['async'] ? 'async' : ($script['defer'] ? 'defer' : ''),
|
||||
$group
|
||||
);
|
||||
break;
|
||||
case 'inline':
|
||||
$grav['assets']->AddInlineJs($script['content'], [
|
||||
'priority' => 90 + $script[':priority'],
|
||||
'group' => $group,
|
||||
]);
|
||||
$assets->AddInlineJs($script['content'],
|
||||
90 + $script[':priority'],
|
||||
$group
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user