diff --git a/CHANGELOG.md b/CHANGELOG.md index bc4b899ab..134047ee2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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')` diff --git a/modules/cms/assets/css/october.components.css b/modules/cms/assets/css/october.components.css index 8382aafcc..e0a46ace6 100644 --- a/modules/cms/assets/css/october.components.css +++ b/modules/cms/assets/css/october.components.css @@ -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; diff --git a/modules/cms/assets/less/october.components.less b/modules/cms/assets/less/october.components.less index 3f911ddc4..2e4bfdd0a 100644 --- a/modules/cms/assets/less/october.components.less +++ b/modules/cms/assets/less/october.components.less @@ -213,7 +213,7 @@ div.control-componentlist { } .draggable-component-item { - .opacity(.5); + .opacity(.6); span.alias { display: none; } a.remove { display: none; } } diff --git a/modules/cms/controllers/Index.php b/modules/cms/controllers/Index.php index 82a85edbf..91e895dfd 100644 --- a/modules/cms/controllers/Index.php +++ b/modules/cms/controllers/Index.php @@ -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'); diff --git a/modules/system/models/PluginVersion.php b/modules/system/models/PluginVersion.php index b4fd7d795..7da6df771 100644 --- a/modules/system/models/PluginVersion.php +++ b/modules/system/models/PluginVersion.php @@ -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; + } + } \ No newline at end of file diff --git a/modules/system/traits/AssetMaker.php b/modules/system/traits/AssetMaker.php index 27e6aba32..ae155faeb 100644 --- a/modules/system/traits/AssetMaker.php +++ b/modules/system/traits/AssetMaker.php @@ -1,8 +1,10 @@ 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 .= '' . 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 .= '' . 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 .= '' . 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; + } + }