diff --git a/cache/lastCache.txt b/cache/lastCache.txt index 14c6c84..8fde579 100644 --- a/cache/lastCache.txt +++ b/cache/lastCache.txt @@ -1 +1 @@ -1550398193 \ No newline at end of file +1550594676 \ No newline at end of file diff --git a/composer.lock b/composer.lock index f49d70c..964698d 100644 --- a/composer.lock +++ b/composer.lock @@ -652,16 +652,16 @@ }, { "name": "symfony/event-dispatcher", - "version": "v3.4.21", + "version": "v3.4.22", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "d1cdd46c53c264a2bd42505bd0e8ce21423bd0e2" + "reference": "ed5be1663fa66623b3a7004d5d51a14c4045399b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/d1cdd46c53c264a2bd42505bd0e8ce21423bd0e2", - "reference": "d1cdd46c53c264a2bd42505bd0e8ce21423bd0e2", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/ed5be1663fa66623b3a7004d5d51a14c4045399b", + "reference": "ed5be1663fa66623b3a7004d5d51a14c4045399b", "shasum": "" }, "require": { @@ -711,7 +711,7 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "https://symfony.com", - "time": "2019-01-01T18:08:36+00:00" + "time": "2019-01-16T13:27:11+00:00" }, { "name": "symfony/polyfill-ctype", diff --git a/system/Plugins.php b/system/Plugins.php index 9594760..c33f51f 100644 --- a/system/Plugins.php +++ b/system/Plugins.php @@ -3,7 +3,7 @@ namespace Typemill; class Plugins -{ +{ public function load() { $pluginFolder = $this->scanPluginFolder(); diff --git a/system/Settings.php b/system/Settings.php index 169ee9a..1f6ff43 100644 --- a/system/Settings.php +++ b/system/Settings.php @@ -8,7 +8,7 @@ class Settings { $settings = self::getDefaultSettings(); $userSettings = self::getUserSettings(); - + $imgSettings = isset($settings['images']) ? $settings['images'] : []; if($userSettings) @@ -47,7 +47,7 @@ class Settings 'contentFolder' => 'content', 'cache' => true, 'cachePath' => $rootPath . 'cache', - 'version' => '1.2.10', + 'version' => '1.2.11', 'setup' => true, 'welcome' => true, 'images' => ['live' => ['width' => 820], 'mlibrary' => ['width' => 50, 'height' => 50]], @@ -75,11 +75,15 @@ class Settings } public static function createSettings($settings) - { + { $yaml = new Models\WriteYaml(); /* write settings to yaml */ - $yaml->updateYaml('settings', 'settings.yaml', $settings); + if($yaml->updateYaml('settings', 'settings.yaml', $settings)) + { + return true; + } + return false; } public static function updateSettings($settings) @@ -96,6 +100,7 @@ class Settings } } + /* public static function removePluginSettings($pluginName) { $userSettings = self::getUserSettings(); @@ -104,10 +109,10 @@ class Settings { $yaml = new Models\WriteYaml(); - /* delete the plugin from settings */ + # delete the plugin from settings unset($userSettings['plugins'][$pluginName]); - /* write settings to yaml */ + # write settings to yaml $yaml->updateYaml('settings', 'settings.yaml', $userSettings); } @@ -130,11 +135,12 @@ class Settings $userSettings['plugins'][$pluginName]['active'] = false; - /* write settings to yaml */ + # write settings to yaml $yaml->updateYaml('settings', 'settings.yaml', $userSettings); return $userSettings; } return false; } + */ } \ No newline at end of file diff --git a/system/author/auth/welcome.twig b/system/author/auth/welcome.twig index c0b78c7..9b2c429 100644 --- a/system/author/auth/welcome.twig +++ b/system/author/auth/welcome.twig @@ -11,7 +11,7 @@

Hurra!

Your account has been created and you are logged in now.

Next step: Visit the author panel and setup your new website. You can configure the system, choose themes and add plugins.

-

New:Markdown is cool but editing tables is a nightmare. But not with Typemill, because we added a visual table editor recently. Try it!

+

New: Markdown is cool. But editing tables with markdown is a nightmare! With Typemill it becomes easy again, because we recently added a visual table editor. Enjoy!!

Get help: If you have any questions, please consult the docs or open a new issue on github.

Configure your website diff --git a/system/author/layouts/layout.twig b/system/author/layouts/layout.twig index 8d73e0d..fcbb746 100644 --- a/system/author/layouts/layout.twig +++ b/system/author/layouts/layout.twig @@ -35,7 +35,7 @@ - - + + \ No newline at end of file diff --git a/system/author/layouts/layoutAuth.twig b/system/author/layouts/layoutAuth.twig index c79b228..5675c2d 100644 --- a/system/author/layouts/layoutAuth.twig +++ b/system/author/layouts/layoutAuth.twig @@ -29,6 +29,6 @@ {% block content %}{% endblock %} - + \ No newline at end of file diff --git a/system/author/layouts/layoutBlox.twig b/system/author/layouts/layoutBlox.twig index 7391b74..24c54eb 100644 --- a/system/author/layouts/layoutBlox.twig +++ b/system/author/layouts/layoutBlox.twig @@ -19,7 +19,7 @@ - + @@ -36,14 +36,14 @@ - - - - - - - - - + + + + + + + + + \ No newline at end of file diff --git a/system/author/layouts/layoutEditor.twig b/system/author/layouts/layoutEditor.twig index de4533b..019f7f0 100644 --- a/system/author/layouts/layoutEditor.twig +++ b/system/author/layouts/layoutEditor.twig @@ -19,7 +19,7 @@ - + @@ -36,13 +36,13 @@ - - - - - - - - + + + + + + + + \ No newline at end of file diff --git a/system/system.php b/system/system.php index a8bac0e..5b5c098 100644 --- a/system/system.php +++ b/system/system.php @@ -29,43 +29,38 @@ $app = new \Slim\App($settings); $container = $app->getContainer(); /************************ -* LOAD PLUGINS * +* LOAD & UPDATE PLUGINS * ************************/ $plugins = new Typemill\Plugins(); $pluginNames = $plugins->load(); -$pluginSettings['plugins'] = array(); - -$routes = $middleware = array(); +$pluginSettings = $routes = $middleware = array(); foreach($pluginNames as $pluginName) { $className = $pluginName['className']; $name = $pluginName['name']; - - /* if plugin is not in user settings yet */ - if(!isset($settings['settings']['plugins'][$name])) - { - /* then read the plugin default settings and write them to the users setting.yaml */ - $updateSettingsYaml = Typemill\settings::addPluginSettings($name); - /* if default settings are written successfully to user settings, update the pluginSettings */ - if($updateSettingsYaml) - { - $pluginSettings['plugins'][$name] = $updateSettingsYaml; - } - /* if not, then settingsYaml does not exist, so set plugin to false for further use */ - else - { - $pluginSettings['plugins'][$name] = false; - } - /* get settings from di-container and update them with the new plugin Settings */ - $DIsettings = $container->get('settings'); - $DIsettings->replace($pluginSettings); + # check if plugin is in the settings already + if(isset($settings['settings']['plugins'][$name])) + { + # if so, add the settings to temporary plugin settings + $pluginSettings[$name] = $settings['settings']['plugins'][$name]; + + # and delete them from original settings + unset($settings['settings']['plugins'][$name]); } - - /* if the plugin is activated, add routes/middleware and add plugin as event subscriber */ - if(isset($settings['settings']['plugins'][$name]['active']) && $settings['settings']['plugins'][$name]['active'] != false) + else + { + # if not, it is a new plugin. Add it and set active to false + $pluginSettings[$name] = ['active' => false]; + + # and set flag to refresh the settings + $refreshSettings = true; + } + + # if the plugin is activated, add routes/middleware and add plugin as event subscriber + if($pluginSettings[$name]['active']) { $routes = $plugins->getNewRoutes($className, $routes); $middleware = $plugins->getNewMiddleware($className, $middleware); @@ -74,13 +69,29 @@ foreach($pluginNames as $pluginName) } } -/* dispatch the event onPluginsLoaded */ +# if plugins in settings are not empty, then a plugin has been removed +if(!empty($settings['settings']['plugins'])){ $refreshSettings = true; } + +# update the settings in all cases +$settings['settings']['plugins'] = $pluginSettings; + +# if plugins have been added or removed +if(isset($refreshSettings)) +{ + # update the settings in the container + $container->get('settings')->replace($settings['settings']); + + # update stored settings file + $refreshSettings = Typemill\settings::updateSettings($settings['settings']); +} + +# dispatch the event onPluginsLoaded $dispatcher->dispatch('onPluginsLoaded', new OnPluginsLoaded($pluginNames)); -/* dispatch settings event and get all setting-updates from plugins */ -/* TODO, how to update the settings with a plugin? You cannot replace the full settings in the container, so you have to add settings in the container directly */ +# dispatch settings event and get all setting-updates from plugins $dispatcher->dispatch('onSettingsLoaded', new OnSettingsLoaded($settings))->getData(); + /****************************** * ADD DISPATCHER TO CONTAINER * ******************************/ @@ -90,6 +101,7 @@ $container['dispatcher'] = function($container) use ($dispatcher) return $dispatcher; }; + /******************************** * ADD ASSET-FUNCTION FOR TWIG * ********************************/ diff --git a/themes/typemill/page.twig b/themes/typemill/page.twig index 503f9d4..468587f 100644 --- a/themes/typemill/page.twig +++ b/themes/typemill/page.twig @@ -23,7 +23,7 @@ {% endif %} {% if settings.themes.typemill.gitPosition.top %} - + {% endif %} {% endif %} @@ -48,7 +48,7 @@ {% endif %} {% if settings.themes.typemill.gitPosition.bottom %} - + {% endif %} {% endif %}