Asset maker functions (addJs, addCss, addRss) now use an optional build code, either *core* or a plugin code.
This commit is contained in:
parent
431285c4d4
commit
82f586c0d1
|
|
@ -1,3 +1,7 @@
|
|||
* **Build 91** (2014-05-24)
|
||||
- Components can now be dragged from the side navigation directly on to the page.
|
||||
- Asset maker functions (addJs, addCss, addRss) now use an optional build code, either *core* or a plugin code. This is converted to a version number to ensure updates are not affected by cached assets.
|
||||
|
||||
* **Build 90** (2014-05-23)
|
||||
- Class `CmsPropertyHelper` has been deprecated, will be removed year > 2014.
|
||||
- Cms Objects now support basic queries that return a collection. Eg: `Page::sortBy('title')->lists('title', 'baseFileName')`
|
||||
|
|
|
|||
|
|
@ -202,8 +202,8 @@ div.control-componentlist div.components div.layout-cell.adding > div {
|
|||
transform: translate(0, -100px) !important;
|
||||
}
|
||||
.draggable-component-item {
|
||||
opacity: 0.5;
|
||||
filter: alpha(opacity=50);
|
||||
opacity: 0.6;
|
||||
filter: alpha(opacity=60);
|
||||
}
|
||||
.draggable-component-item span.alias {
|
||||
display: none;
|
||||
|
|
|
|||
|
|
@ -213,7 +213,7 @@ div.control-componentlist {
|
|||
}
|
||||
|
||||
.draggable-component-item {
|
||||
.opacity(.5);
|
||||
.opacity(.6);
|
||||
span.alias { display: none; }
|
||||
a.remove { display: none; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,17 +76,17 @@ class Index extends Controller
|
|||
$this->handleError($ex);
|
||||
}
|
||||
|
||||
$this->addJs('/modules/cms/assets/js/october.cmspage.js');
|
||||
$this->addJs('/modules/cms/assets/js/october.dragcomponents.js');
|
||||
$this->addCss('/modules/cms/assets/css/october.components.css');
|
||||
$this->addJs('/modules/cms/assets/js/october.cmspage.js', 'core');
|
||||
$this->addJs('/modules/cms/assets/js/october.dragcomponents.js', 'core');
|
||||
$this->addCss('/modules/cms/assets/css/october.components.css', 'core');
|
||||
|
||||
// Preload Ace editor modes explicitly, because they could be changed dynamically
|
||||
// depending on a content block type
|
||||
$this->addJs('/modules/backend/formwidgets/codeeditor/assets/vendor/ace/ace.js');
|
||||
$this->addJs('/modules/backend/formwidgets/codeeditor/assets/vendor/ace/ace.js', 'core');
|
||||
|
||||
$aceModes = ['markdown', 'plain_text', 'html', 'less', 'css', 'scss', 'sass', 'javascript'];
|
||||
foreach ($aceModes as $mode)
|
||||
$this->addJs('/modules/backend/formwidgets/codeeditor/assets/vendor/ace/mode-'.$mode.'.js');
|
||||
$this->addJs('/modules/backend/formwidgets/codeeditor/assets/vendor/ace/mode-'.$mode.'.js', 'core');
|
||||
|
||||
$this->bodyClass = 'compact-container side-panel-not-fixed';
|
||||
$this->pageTitle = Lang::get('cms::lang.cms.menu_label');
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ class PluginVersion extends Model
|
|||
*/
|
||||
protected $guarded = ['*'];
|
||||
|
||||
protected static $versionCache = null;
|
||||
|
||||
/**
|
||||
* After the model is populated
|
||||
*/
|
||||
|
|
@ -31,6 +33,22 @@ class PluginVersion extends Model
|
|||
$this->{$attribute} = $info;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current version for a plugin
|
||||
* @param string $pluginCode Plugin code. Eg: Acme.Blog
|
||||
* @return string
|
||||
*/
|
||||
public static function getVersion($pluginCode)
|
||||
{
|
||||
if (self::$versionCache === null) {
|
||||
self::$versionCache = self::lists('version', 'code');
|
||||
}
|
||||
|
||||
return isset(self::$versionCache[$pluginCode])
|
||||
? self::$versionCache[$pluginCode]
|
||||
: null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,8 +1,10 @@
|
|||
<?php namespace System\Traits;
|
||||
|
||||
use HTML;
|
||||
use File;
|
||||
use Request;
|
||||
use HTML;
|
||||
use System\Models\Parameters;
|
||||
use System\Models\PluginVersion;
|
||||
use System\Classes\SystemException;
|
||||
|
||||
/**
|
||||
|
|
@ -35,14 +37,17 @@ trait AssetMaker
|
|||
{
|
||||
if ($type != null) $type = strtolower($type);
|
||||
$result = null;
|
||||
$reserved = ['build'];
|
||||
|
||||
if ($type == null || $type == 'css'){
|
||||
foreach ($this->assets['css'] as $asset) {
|
||||
|
||||
$attributes = HTML::attributes(array_merge([
|
||||
'rel' => 'stylesheet',
|
||||
'href' => $asset['path']
|
||||
], $asset['attributes']));
|
||||
'rel' => 'stylesheet',
|
||||
'href' => $this->getAssetEntryBuildPath($asset)
|
||||
],
|
||||
array_except($asset['attributes'], $reserved)
|
||||
));
|
||||
|
||||
$result .= '<link' . $attributes . '>' . PHP_EOL;
|
||||
}
|
||||
|
|
@ -52,11 +57,13 @@ trait AssetMaker
|
|||
foreach ($this->assets['rss'] as $asset) {
|
||||
|
||||
$attributes = HTML::attributes(array_merge([
|
||||
'rel' => 'alternate',
|
||||
'href' => $asset['path'],
|
||||
'title' => 'RSS',
|
||||
'type' => 'application/rss+xml'
|
||||
], $asset['attributes']));
|
||||
'rel' => 'alternate',
|
||||
'href' => $this->getAssetEntryBuildPath($asset),
|
||||
'title' => 'RSS',
|
||||
'type' => 'application/rss+xml'
|
||||
],
|
||||
array_except($asset['attributes'], $reserved)
|
||||
));
|
||||
|
||||
$result .= '<link' . $attributes . '>' . PHP_EOL;
|
||||
}
|
||||
|
|
@ -66,8 +73,10 @@ trait AssetMaker
|
|||
foreach ($this->assets['js'] as $asset) {
|
||||
|
||||
$attributes = HTML::attributes(array_merge([
|
||||
'src' => $asset['path']
|
||||
], $asset['attributes']));
|
||||
'src' => $this->getAssetEntryBuildPath($asset)
|
||||
],
|
||||
array_except($asset['attributes'], $reserved)
|
||||
));
|
||||
|
||||
$result .= '<script' . $attributes . '></script>' . PHP_EOL;
|
||||
}
|
||||
|
|
@ -90,6 +99,9 @@ trait AssetMaker
|
|||
if (isset($this->controller))
|
||||
$this->controller->addJs($jsPath, $attributes);
|
||||
|
||||
if (is_string($attributes))
|
||||
$attributes = ['build' => $attributes];
|
||||
|
||||
if (substr($jsPath, 0, 1) == '/')
|
||||
$jsPath = Request::getBaseUrl() . $jsPath;
|
||||
|
||||
|
|
@ -111,6 +123,9 @@ trait AssetMaker
|
|||
if (isset($this->controller))
|
||||
$this->controller->addCss($cssPath, $attributes);
|
||||
|
||||
if (is_string($attributes))
|
||||
$attributes = ['build' => $attributes];
|
||||
|
||||
if (substr($cssPath, 0, 1) == '/')
|
||||
$cssPath = Request::getBaseUrl() . $cssPath;
|
||||
|
||||
|
|
@ -132,6 +147,9 @@ trait AssetMaker
|
|||
if (isset($this->controller))
|
||||
$this->controller->addRss($rssPath, $attributes);
|
||||
|
||||
if (is_string($attributes))
|
||||
$attributes = ['build' => $attributes];
|
||||
|
||||
if (substr($rssPath, 0, 1) == '/')
|
||||
$rssPath = Request::getBaseUrl() . $rssPath;
|
||||
|
||||
|
|
@ -149,7 +167,7 @@ trait AssetMaker
|
|||
foreach ($this->assets as $type => $collection) {
|
||||
$assets[$type] = [];
|
||||
foreach ($collection as $asset) {
|
||||
$assets[$type][] = $asset['path'];
|
||||
$assets[$type][] = $this->getAssetEntryBuildPath($asset);
|
||||
}
|
||||
}
|
||||
return $assets;
|
||||
|
|
@ -192,4 +210,26 @@ trait AssetMaker
|
|||
return count($this->assets, COUNT_RECURSIVE) > 3;
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal helper, attaches a build code to an asset path
|
||||
* @param array $asset Stored asset array
|
||||
* @return string
|
||||
*/
|
||||
private function getAssetEntryBuildPath($asset)
|
||||
{
|
||||
$path = $asset['path'];
|
||||
if (isset($asset['attributes']['build'])) {
|
||||
$build = $asset['attributes']['build'];
|
||||
|
||||
if ($build == 'core')
|
||||
$build = 'v' . Parameters::get('system::core.build', 1);
|
||||
elseif ($pluginVersion = PluginVersion::getVersion($build))
|
||||
$build = 'v' . $pluginVersion;
|
||||
|
||||
$path .= '?' . $build;
|
||||
}
|
||||
|
||||
return $path;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue