From e152cfd10faa9a8366ecac2d0e08178a88703549 Mon Sep 17 00:00:00 2001 From: Djamil Legato Date: Sat, 12 Dec 2015 17:47:19 -0800 Subject: [PATCH 01/23] Forcing travis VM to western most date and echo a Travis date to catch it on log --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 578da9f7fe..c458c24efa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -40,8 +40,10 @@ env: - TRAVIS_TAG=$(curl --fail --user ${GH_API_USER} -s https://api.github.com/repos/getgrav/grav/releases/latest | grep tag_name | head -n 1 | cut -d '"' -f 4) before_install: + - export TZ=Pacific/Honolulu - composer self-update - go get github.com/aktau/github-release + - echo "Travis Date: `date`" - git clone --quiet --depth=50 --branch=master https://${BB_TOKEN}bitbucket.org/rockettheme/grav-devtools.git $RT_DEVTOOLS &>/dev/null; - if [ ! -z "$TRAVIS_TAG" ]; then cd "${RT_DEVTOOLS}"; From ec7dbbdc8b1d6e51cb493600664d2cd6d090e50b Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Mon, 14 Dec 2015 18:13:14 -0700 Subject: [PATCH 02/23] Added 7z format to standard file types #521 --- system/config/media.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/system/config/media.yaml b/system/config/media.yaml index 8581ba4bd2..a2e82d86bc 100644 --- a/system/config/media.yaml +++ b/system/config/media.yaml @@ -168,6 +168,10 @@ zip: type: file thumb: media/thumb-zip.png mime: application/zip +7z: + type: file + thumb: media/thumb-7zip.png + mime: application/x-7z-compressed gz: type: file thumb: media/thumb-gz.png From d8a993bc86c6ac07fc4f080306cc782c756526df Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Mon, 14 Dec 2015 18:30:55 -0700 Subject: [PATCH 03/23] Properly convert comma to spaces for multiple attributes #518 --- system/src/Grav/Common/Markdown/ParsedownGravTrait.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/src/Grav/Common/Markdown/ParsedownGravTrait.php b/system/src/Grav/Common/Markdown/ParsedownGravTrait.php index 5c075dcb55..f15a20a21e 100644 --- a/system/src/Grav/Common/Markdown/ParsedownGravTrait.php +++ b/system/src/Grav/Common/Markdown/ParsedownGravTrait.php @@ -230,7 +230,7 @@ protected function inlineLink($excerpt) if ($attrib == 'classes') { $attrib = 'class'; } - $excerpt['element']['attributes'][$attrib] = $value; + $excerpt['element']['attributes'][$attrib] = str_replace(',', ' ', $value); unset($actions[$key]); } } From 0e8e27877e1219117a862d5bcb6c1ac485fbbacb Mon Sep 17 00:00:00 2001 From: Flavio Copes Date: Tue, 15 Dec 2015 11:52:27 +0100 Subject: [PATCH 04/23] Fix https://github.com/getgrav/grav-plugin-admin/issues/335, when looping the `fields` param in a `list` field, first check it exists --- system/src/Grav/Common/Data/Blueprint.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/system/src/Grav/Common/Data/Blueprint.php b/system/src/Grav/Common/Data/Blueprint.php index 8be6a8ea85..68de5de81d 100644 --- a/system/src/Grav/Common/Data/Blueprint.php +++ b/system/src/Grav/Common/Data/Blueprint.php @@ -338,8 +338,10 @@ protected function parseFormFields(array &$fields, $params, $prefix, array &$cur if ($field['type'] === 'list') { // we loop through list to get the actual field - foreach($field['fields'] as $subName => &$subField) { - $this->parseFormField($subField); + if (isset($field['fields']) && $field['fields']) { + foreach($field['fields'] as $subName => &$subField) { + $this->parseFormField($subField); + } } } else { $this->parseFormField($field); From 451baff26ee28612f49fc9d46a349f8205bc2cfa Mon Sep 17 00:00:00 2001 From: Flavio Copes Date: Wed, 16 Dec 2015 15:16:14 +0100 Subject: [PATCH 05/23] filterFile if the file field allows multiple items returns an array, otherwise a string --- system/src/Grav/Common/Data/Validation.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/system/src/Grav/Common/Data/Validation.php b/system/src/Grav/Common/Data/Validation.php index 9e62802b17..4a3bd2b163 100644 --- a/system/src/Grav/Common/Data/Validation.php +++ b/system/src/Grav/Common/Data/Validation.php @@ -283,7 +283,11 @@ public static function typeFile($value, array $params, array $field) protected static function filterFile($value, array $params, array $field) { - return (array) $value; + if ($field['multiple'] == true) { + return (array) $value; + } + + return reset($value); } /** From 5f8c7f41ecd3464c4678a91c2ac8d576b16bfe83 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Wed, 16 Dec 2015 19:50:10 -0700 Subject: [PATCH 06/23] Add ability to extend markdown --- .../Common/Markdown/ParsedownGravTrait.php | 33 +++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/system/src/Grav/Common/Markdown/ParsedownGravTrait.php b/system/src/Grav/Common/Markdown/ParsedownGravTrait.php index f15a20a21e..7278e6f081 100644 --- a/system/src/Grav/Common/Markdown/ParsedownGravTrait.php +++ b/system/src/Grav/Common/Markdown/ParsedownGravTrait.php @@ -3,6 +3,7 @@ use Grav\Common\GravTrait; use Grav\Common\Uri; +use RocketTheme\Toolbox\Event\Event; /** * A trait to add some custom processing to the identifyLink() method in Parsedown and ParsedownExtra @@ -26,8 +27,10 @@ trait ParsedownGravTrait */ protected function init($page, $defaults) { + $grav = self::getGrav(); + $this->page = $page; - $this->pages = self::getGrav()['pages']; + $this->pages = $grav['pages']; $this->BlockTypes['{'] [] = "TwigTag"; $this->base_url = rtrim(self::getGrav()['base_url'] . self::getGrav()['pages']->base(), '/'); $this->pages_dir = self::getGrav()['locator']->findResource('page://'); @@ -41,8 +44,24 @@ protected function init($page, $defaults) $this->setUrlsLinked($defaults['auto_url_links']); $this->setMarkupEscaped($defaults['escape_markup']); $this->setSpecialChars($defaults['special_chars']); + + $grav->fireEvent('onMarkdownInitialized', new Event(['markdown' => $this])); + + } + + public function addBlockType($type, $tag) + { + $this->BlockTypes[$type] []= $tag; + $this->inlineMarkerList .= $type; } + public function addInlineType($type, $tag) + { + $this->InlineTypes[$type] []= $tag; + $this->inlineMarkerList .= $type; + } + + /** * Make the element function publicly accessible, Medium uses this to render from Twig * @@ -73,7 +92,7 @@ function setSpecialChars($special_chars) */ protected function blockTwigTag($Line) { - if (preg_match('/[{%|{{|{#].*[#}|}}|%}]/', $Line['body'], $matches)) { + if (preg_match('/(?:{{|{%|{#)(.*)(?:}}|%}|#})/', $Line['body'], $matches)) { $Block = array( 'markup' => $Line['body'], ); @@ -255,4 +274,14 @@ protected function inlineLink($excerpt) return $excerpt; } + + // For extending this class via plugins + public function __call($method, $args) + { + if (isset($this->$method) === true) { + $func = $this->$method; + return call_user_func_array($func, $args); + } + } + } From 0142e7627035afa8fb29c50350db5ece681e13f3 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Wed, 16 Dec 2015 21:51:38 -0700 Subject: [PATCH 07/23] cleanup --- .../src/Grav/Common/Markdown/ParsedownGravTrait.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/system/src/Grav/Common/Markdown/ParsedownGravTrait.php b/system/src/Grav/Common/Markdown/ParsedownGravTrait.php index 7278e6f081..2051c4258a 100644 --- a/system/src/Grav/Common/Markdown/ParsedownGravTrait.php +++ b/system/src/Grav/Common/Markdown/ParsedownGravTrait.php @@ -49,12 +49,23 @@ protected function init($page, $defaults) } + /** + * Be able to define a new Block type or override an existing one + * + * @param $type + * @param $tag + */ public function addBlockType($type, $tag) { $this->BlockTypes[$type] []= $tag; - $this->inlineMarkerList .= $type; } + /** + * Be able to define a new Inline type or override an existing one + * + * @param $type + * @param $tag + */ public function addInlineType($type, $tag) { $this->InlineTypes[$type] []= $tag; From 1cecd094230755345c2f94fe7f5a0e2578fd1ffd Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Thu, 17 Dec 2015 10:35:22 -0700 Subject: [PATCH 08/23] requires changes in parsedown --- .../Common/Markdown/ParsedownGravTrait.php | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/system/src/Grav/Common/Markdown/ParsedownGravTrait.php b/system/src/Grav/Common/Markdown/ParsedownGravTrait.php index 2051c4258a..b4d4ff2f7f 100644 --- a/system/src/Grav/Common/Markdown/ParsedownGravTrait.php +++ b/system/src/Grav/Common/Markdown/ParsedownGravTrait.php @@ -16,9 +16,11 @@ trait ParsedownGravTrait protected $base_url; protected $pages_dir; protected $special_chars; - protected $twig_link_regex = '/\!*\[(?:.*)\]\((\{([\{%#])\s*(.*?)\s*(?:\2|\})\})\)/'; + public $completeable_blocks = []; + public $continueable_blocks = []; + /** * Initialization function to setup key variables needed by the MarkdownGravLinkTrait * @@ -55,9 +57,17 @@ protected function init($page, $defaults) * @param $type * @param $tag */ - public function addBlockType($type, $tag) + public function addBlockType($type, $tag, $continueable = false, $completeable = false) { $this->BlockTypes[$type] []= $tag; + + if ($continueable) { + $this->continueable_blocks[] = $tag; + } + + if ($completeable) { + $this->completeable_blocks[] = $tag; + } } /** @@ -72,6 +82,18 @@ public function addInlineType($type, $tag) $this->inlineMarkerList .= $type; } + protected function isBlockContinueable($Type) + { + $continueable = in_array($Type, $this->continueable_blocks) || method_exists($this, 'block'.$Type.'Continue'); + return $continueable; + } + + protected function isBlockCompleteable($Type) + { + $completeable = in_array($Type, $this->completeable_blocks) || method_exists($this, 'block'.$Type.'Complete'); + return $completeable; + } + /** * Make the element function publicly accessible, Medium uses this to render from Twig @@ -295,4 +317,6 @@ public function __call($method, $args) } } + + } From f29b141d696fdfc34ac9367f865acb704b47ac1b Mon Sep 17 00:00:00 2001 From: mufac Date: Thu, 17 Dec 2015 16:14:48 -0600 Subject: [PATCH 09/23] Prevent error if no collections present If there are no collections you can get a "Invalid argument supplied for foreach()" without an empty default. --- system/src/Grav/Common/Assets.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/src/Grav/Common/Assets.php b/system/src/Grav/Common/Assets.php index be6b81f7af..7145bcfc7e 100644 --- a/system/src/Grav/Common/Assets.php +++ b/system/src/Grav/Common/Assets.php @@ -186,7 +186,7 @@ public function init() $this->base_url = $base_url . '/'; // Register any preconfigured collections - foreach ($config->get('system.assets.collections') as $name => $collection) { + foreach ($config->get('system.assets.collections', []) as $name => $collection) { $this->registerCollection($name, (array)$collection); } } From fb4abc5f5f1907662cb773cc82ac88209182e1d4 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Thu, 17 Dec 2015 17:52:20 -0700 Subject: [PATCH 10/23] Use Grav's version of Parsedown until PR is accepted (crossing fingers) --- composer.json | 7 +++++++ composer.lock | 33 ++++++++++++++++++++++----------- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/composer.json b/composer.json index 302cabfdc4..ba3c6e3175 100644 --- a/composer.json +++ b/composer.json @@ -8,6 +8,7 @@ "require": { "php": ">=5.4.0", "twig/twig": "~1.23", + "erusev/parsedown": "dev-master as 1.6.0", "erusev/parsedown-extra": "~0.7", "symfony/yaml": "~2.8", "symfony/console": "~2.8", @@ -25,6 +26,12 @@ "rockettheme/toolbox": "~1.2", "maximebf/debugbar": "~1.10" }, + "repositories": [ + { + "type": "vcs", + "url": "https://github.com/getgrav/parsedown" + } + ], "autoload": { "psr-4": { "Grav\\": "system/src/Grav" diff --git a/composer.lock b/composer.lock index 3483fa781b..d0dca3cddd 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "09fcc6b4528be7d9c8af68a66e85f0b2", - "content-hash": "69bee250cbc5160401d50cc47c8d6aba", + "hash": "82d333365d7424d73da22f99a2daa42c", + "content-hash": "6d876da7dbe11934a98374e67d15550c", "packages": [ { "name": "doctrine/cache", @@ -130,16 +130,16 @@ }, { "name": "erusev/parsedown", - "version": "1.6.0", + "version": "dev-master", "source": { "type": "git", - "url": "https://github.com/erusev/parsedown.git", - "reference": "3ebbd730b5c2cf5ce78bc1bf64071407fc6674b7" + "url": "https://github.com/getgrav/parsedown.git", + "reference": "10a7ff776c3f16b1b3aa41c176c48150fc091065" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/erusev/parsedown/zipball/3ebbd730b5c2cf5ce78bc1bf64071407fc6674b7", - "reference": "3ebbd730b5c2cf5ce78bc1bf64071407fc6674b7", + "url": "https://api.github.com/repos/getgrav/parsedown/zipball/10a7ff776c3f16b1b3aa41c176c48150fc091065", + "reference": "10a7ff776c3f16b1b3aa41c176c48150fc091065", "shasum": "" }, "type": "library", @@ -148,7 +148,6 @@ "Parsedown": "" } }, - "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -165,7 +164,10 @@ "markdown", "parser" ], - "time": "2015-10-04 16:44:32" + "support": { + "source": "https://github.com/getgrav/parsedown/tree/master" + }, + "time": "2015-12-17 17:48:21" }, { "name": "erusev/parsedown-extra", @@ -1125,9 +1127,18 @@ } ], "packages-dev": [], - "aliases": [], + "aliases": [ + { + "alias": "1.6.0", + "alias_normalized": "1.6.0.0", + "version": "9999999-dev", + "package": "erusev/parsedown" + } + ], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": { + "erusev/parsedown": 20 + }, "prefer-stable": false, "prefer-lowest": false, "platform": { From 3d3c6f4eba9381400d27539ee2c968e2885bda5f Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Thu, 17 Dec 2015 18:09:11 -0700 Subject: [PATCH 11/23] missing doc blocks --- .../src/Grav/Common/Markdown/ParsedownGravTrait.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/system/src/Grav/Common/Markdown/ParsedownGravTrait.php b/system/src/Grav/Common/Markdown/ParsedownGravTrait.php index b4d4ff2f7f..a735a2ca90 100644 --- a/system/src/Grav/Common/Markdown/ParsedownGravTrait.php +++ b/system/src/Grav/Common/Markdown/ParsedownGravTrait.php @@ -82,12 +82,24 @@ public function addInlineType($type, $tag) $this->inlineMarkerList .= $type; } + /** + * Overrides the default behavior to allow for plugin-provided blocks to be continueable + * + * @param $Type + * @return bool + */ protected function isBlockContinueable($Type) { $continueable = in_array($Type, $this->continueable_blocks) || method_exists($this, 'block'.$Type.'Continue'); return $continueable; } + /** + * Overrides the default behavior to allow for plugin-provided blocks to be completeable + * + * @param $Type + * @return bool + */ protected function isBlockCompleteable($Type) { $completeable = in_array($Type, $this->completeable_blocks) || method_exists($this, 'block'.$Type.'Complete'); From 139ef04e0ad56aebe80d4bf8becd08f3116f2734 Mon Sep 17 00:00:00 2001 From: Flavio Copes Date: Fri, 18 Dec 2015 10:38:07 +0100 Subject: [PATCH 12/23] Handle non-array values in file validation --- system/src/Grav/Common/Data/Validation.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/system/src/Grav/Common/Data/Validation.php b/system/src/Grav/Common/Data/Validation.php index 4a3bd2b163..9f0266bd42 100644 --- a/system/src/Grav/Common/Data/Validation.php +++ b/system/src/Grav/Common/Data/Validation.php @@ -287,7 +287,11 @@ protected static function filterFile($value, array $params, array $field) return (array) $value; } - return reset($value); + if (is_array($value)) { + return reset($value); + } + + return $value; } /** From 8d048c689fbfba1691902fe41da385e2ba142e0f Mon Sep 17 00:00:00 2001 From: Flavio Copes Date: Fri, 18 Dec 2015 14:44:03 +0100 Subject: [PATCH 13/23] Persists to disk the plugin parameters currently stored in the Grav Config object --- system/src/Grav/Common/Plugin.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/system/src/Grav/Common/Plugin.php b/system/src/Grav/Common/Plugin.php index 3f2f90aa17..b2084205fb 100644 --- a/system/src/Grav/Common/Plugin.php +++ b/system/src/Grav/Common/Plugin.php @@ -6,6 +6,7 @@ use Grav\Common\Config\Config; use RocketTheme\Toolbox\Event\EventDispatcher; use RocketTheme\Toolbox\Event\EventSubscriberInterface; +use RocketTheme\Toolbox\File\YamlFile; /** * The Plugin object just holds the id and path to a plugin. @@ -182,4 +183,27 @@ protected function mergeConfig(Page $page, $deep = false, $params = []) // Return configurations as a new data config class return new Data($header); } + + /** + * Persists to disk the plugin parameters currently stored in the Grav Config object + * + * @param string $plugin_name The name of the plugin whose config it should store. + * If omitted, saves the current plugin + * + * @return true + */ + protected function saveConfig($plugin_name = '') { + if (!$plugin_name) { + $plugin_name = $this->name; + } + + $locator = $this->grav['locator']; + $filename = 'config://plugins/' . $plugin_name . '.yaml'; + $file = YamlFile::instance($locator->findResource($filename, true, true)); + $content = $this->grav['config']->get('plugins.' . $plugin_name); + $file->save($content); + $file->free(); + + return true; + } } From 987feb1385cda8f026f6d97531a0aaca4e5cc155 Mon Sep 17 00:00:00 2001 From: Flavio Copes Date: Fri, 18 Dec 2015 15:42:33 +0100 Subject: [PATCH 14/23] Make saveConfig static so it's more easily accessible --- system/src/Grav/Common/Plugin.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/system/src/Grav/Common/Plugin.php b/system/src/Grav/Common/Plugin.php index b2084205fb..96084b0ed2 100644 --- a/system/src/Grav/Common/Plugin.php +++ b/system/src/Grav/Common/Plugin.php @@ -188,19 +188,18 @@ protected function mergeConfig(Page $page, $deep = false, $params = []) * Persists to disk the plugin parameters currently stored in the Grav Config object * * @param string $plugin_name The name of the plugin whose config it should store. - * If omitted, saves the current plugin * * @return true */ - protected function saveConfig($plugin_name = '') { + public static function saveConfig($plugin_name) { if (!$plugin_name) { - $plugin_name = $this->name; + return false; } - $locator = $this->grav['locator']; + $locator = Grav::instance()['locator']; $filename = 'config://plugins/' . $plugin_name . '.yaml'; $file = YamlFile::instance($locator->findResource($filename, true, true)); - $content = $this->grav['config']->get('plugins.' . $plugin_name); + $content = Grav::instance()['config']->get('plugins.' . $plugin_name); $file->save($content); $file->free(); From e87daa23619acc0cf38012e95191a380b155aedb Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Fri, 18 Dec 2015 12:29:45 -0700 Subject: [PATCH 15/23] Added support to get plugin languages from individual language files in `languages` folder of plugin --- .../Common/Service/ConfigServiceProvider.php | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/system/src/Grav/Common/Service/ConfigServiceProvider.php b/system/src/Grav/Common/Service/ConfigServiceProvider.php index 9efbd74652..ebb156b1a6 100644 --- a/system/src/Grav/Common/Service/ConfigServiceProvider.php +++ b/system/src/Grav/Common/Service/ConfigServiceProvider.php @@ -108,10 +108,45 @@ public static function languages(Container $container) $files += (new ConfigFileFinder)->locateFiles($paths); $paths = $locator->findResources('plugins://'); $files += (new ConfigFileFinder)->setBase('plugins')->locateInFolders($paths, 'languages'); + $paths = static::pluginFolderPaths($paths, 'languages'); + $files += (new ConfigFileFinder)->locateFiles($paths); } $languages = new CompiledLanguages($cache, $files, GRAV_ROOT); return $languages->name("master-{$setup->environment}")->load(); } + + /** + * Find specific paths in plugins + * + * @param $plugins + * @param $folder_path + * @return array + */ + private static function pluginFolderPaths($plugins, $folder_path) + { + $paths = []; + + foreach ($plugins as $path) { + $iterator = new \DirectoryIterator($path); + + /** @var \DirectoryIterator $directory */ + foreach ($iterator as $directory) { + if (!$directory->isDir() || $directory->isDot()) { + continue; + } + + // Path to the languages folder + $lang_path = $directory->getPathName() . '/' . $folder_path; + + // If this folder exists, add it to the list of paths + if (file_exists($lang_path)) { + $paths []= $lang_path; + } + } + } + return $paths; + } + } From 1996dd7de85b147dcd12c404737030c89bf7b277 Mon Sep 17 00:00:00 2001 From: Djamil Legato Date: Fri, 18 Dec 2015 13:33:57 -0800 Subject: [PATCH 16/23] Allowing Installer to set errors as string --- system/src/Grav/Common/GPM/Installer.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/system/src/Grav/Common/GPM/Installer.php b/system/src/Grav/Common/GPM/Installer.php index ee9db4816d..158c4048cd 100644 --- a/system/src/Grav/Common/GPM/Installer.php +++ b/system/src/Grav/Common/GPM/Installer.php @@ -281,6 +281,10 @@ public static function lastErrorMsg() { $msg = 'Unknown Error'; + if (is_string(self::$error)) { + return self::$error; + } + switch (self::$error) { case 0: $msg = 'No Error'; @@ -333,7 +337,7 @@ public static function lastErrorCode() /** * Allows to manually set an error - * @param $error the Error code + * @param int|string $error the Error code */ public static function setError($error) From 71c5ff8c517cbbf4ab4a4f74d4b75201dc641770 Mon Sep 17 00:00:00 2001 From: Djamil Legato Date: Fri, 18 Dec 2015 13:35:31 -0800 Subject: [PATCH 17/23] Added new `Upgrader::meetsRequirements` method Ensures the PHP version meets the Grav's mininum required one. --- system/src/Grav/Common/GPM/Upgrader.php | 29 +++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/system/src/Grav/Common/GPM/Upgrader.php b/system/src/Grav/Common/GPM/Upgrader.php index 590ad4df7a..61c9ad5ce7 100644 --- a/system/src/Grav/Common/GPM/Upgrader.php +++ b/system/src/Grav/Common/GPM/Upgrader.php @@ -1,22 +1,32 @@ remote->getChangelog($diff); } + /** + * @return bool + */ + public function meetsRequirements() + { + if (version_compare(PHP_VERSION, GRAV_PHP_MIN, '<')) { + return false; + } + + return true; + } + /** * Checks if the currently installed Grav is upgradable to a newer version + * * @return boolean True if it's upgradable, False otherwise. */ public function isUpgradable() @@ -83,6 +111,7 @@ public function isUpgradable() /** * Checks if Grav is currently symbolically linked + * * @return boolean True if Grav is symlinked, False otherwise. */ From c18f20e483c88d5acc7f00fd067aae2ddb120cda Mon Sep 17 00:00:00 2001 From: Djamil Legato Date: Fri, 18 Dec 2015 13:37:19 -0800 Subject: [PATCH 18/23] Added GRAV_PHP_MIN --- system/defines.php | 1 + 1 file changed, 1 insertion(+) diff --git a/system/defines.php b/system/defines.php index b372a50468..5783641582 100644 --- a/system/defines.php +++ b/system/defines.php @@ -4,6 +4,7 @@ define('GRAV', true); define('GRAV_VERSION', '1.0.4'); define('DS', '/'); +define('GRAV_PHP_MIN', '5.5.9'); // Directories and Paths if (!defined('GRAV_ROOT')) { From 00ecfb30f360f6e9054fa1350e8accad8a91e274 Mon Sep 17 00:00:00 2001 From: Djamil Legato Date: Fri, 18 Dec 2015 13:38:28 -0800 Subject: [PATCH 19/23] Ensuring gpm selfupgrades doesn't continue if PHP min version requirement isn't met. Gracefully abort with error and details. --- system/src/Grav/Console/Gpm/SelfupgradeCommand.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/system/src/Grav/Console/Gpm/SelfupgradeCommand.php b/system/src/Grav/Console/Gpm/SelfupgradeCommand.php index d2ef2d2d6a..ae1bc18e45 100644 --- a/system/src/Grav/Console/Gpm/SelfupgradeCommand.php +++ b/system/src/Grav/Console/Gpm/SelfupgradeCommand.php @@ -82,6 +82,18 @@ protected function serve() $remote = $this->upgrader->getRemoteVersion(); $release = strftime('%c', strtotime($this->upgrader->getReleaseDate())); + if (!$this->upgrader->meetsRequirements()) { + $this->output->writeln(""); + $this->output->writeln("ATTENTION:"); + $this->output->writeln(" Grav has increased the minimum PHP requirement."); + $this->output->writeln(" You are currently running PHP " . PHP_VERSION . ", but PHP " . GRAV_PHP_MIN . " is required."); + $this->output->writeln(" Additional informations: http://getgrav.org/blog/changing-php-requirements-to-5.5"); + $this->output->writeln(""); + $this->output->writeln("Selfupgrade aborted."); + $this->output->writeln(""); + exit; + } + if (!$this->upgrader->isUpgradable()) { $this->output->writeln("You are already running the latest version of Grav (v" . $local . ") released on " . $release); exit; From 984e0455b1b47242b2e786d08a4a91dbab0caf8e Mon Sep 17 00:00:00 2001 From: Djamil Legato Date: Fri, 18 Dec 2015 13:44:59 -0800 Subject: [PATCH 20/23] =?UTF-8?q?'informations'=20is=20not=20a=20thing=20?= =?UTF-8?q?=F0=9F=98=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- system/src/Grav/Console/Gpm/SelfupgradeCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/src/Grav/Console/Gpm/SelfupgradeCommand.php b/system/src/Grav/Console/Gpm/SelfupgradeCommand.php index ae1bc18e45..5428783807 100644 --- a/system/src/Grav/Console/Gpm/SelfupgradeCommand.php +++ b/system/src/Grav/Console/Gpm/SelfupgradeCommand.php @@ -87,7 +87,7 @@ protected function serve() $this->output->writeln("ATTENTION:"); $this->output->writeln(" Grav has increased the minimum PHP requirement."); $this->output->writeln(" You are currently running PHP " . PHP_VERSION . ", but PHP " . GRAV_PHP_MIN . " is required."); - $this->output->writeln(" Additional informations: http://getgrav.org/blog/changing-php-requirements-to-5.5"); + $this->output->writeln(" Additional information: http://getgrav.org/blog/changing-php-requirements-to-5.5"); $this->output->writeln(""); $this->output->writeln("Selfupgrade aborted."); $this->output->writeln(""); From 425831a7aedfbec6ae0df172cb049ccbc290c85a Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Fri, 18 Dec 2015 15:09:21 -0700 Subject: [PATCH 21/23] Fix for empty file when writing cache --- system/src/Grav/Common/Twig/WriteCacheFileTrait.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/system/src/Grav/Common/Twig/WriteCacheFileTrait.php b/system/src/Grav/Common/Twig/WriteCacheFileTrait.php index ec0d93c2fb..e20a2a43cb 100644 --- a/system/src/Grav/Common/Twig/WriteCacheFileTrait.php +++ b/system/src/Grav/Common/Twig/WriteCacheFileTrait.php @@ -20,6 +20,10 @@ trait WriteCacheFileTrait */ protected function writeCacheFile($file, $content) { + if (empty($file)) { + return; + } + if (!isset(self::$umask)) { self::$umask = self::getGrav()['config']->get('system.twig.umask_fix', false); } From 4a80691e075642af93c8240181db5eb05c9f5961 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Fri, 18 Dec 2015 16:49:03 -0700 Subject: [PATCH 22/23] version update --- CHANGELOG.md | 17 +++++++++++++++++ system/defines.php | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d51bda0d5f..44a87b32d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,20 @@ +# v1.0.5 +## 12/18/2015 + +1. [](#new) + * Add ability to extend markdown with plugins + * Added support for plugins to have individual language files + * Added `7z` to media formats + * Use Grav's fork of Parsedown until PR is merged + * New function to persist plugin configuration to disk + * GPM `selfupgrade` will now check PHP version requirements +1. [](#improved) + * If the field allows multiple files, return array +1. [](#bugfix) + * Fix when looping `fields` param in a `list` field + * Properly convert commas to spaces for media attributes + * Forcing Travis VM to HI timezone to address future files in zip file + # v1.0.4 ## 12/12/2015 diff --git a/system/defines.php b/system/defines.php index 5783641582..1153fcbe5d 100644 --- a/system/defines.php +++ b/system/defines.php @@ -2,7 +2,7 @@ // Some standard defines define('GRAV', true); -define('GRAV_VERSION', '1.0.4'); +define('GRAV_VERSION', '1.0.5'); define('DS', '/'); define('GRAV_PHP_MIN', '5.5.9'); From dcaa9a35c3ca65147ffdcc1c2296f17a38c972e7 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Fri, 18 Dec 2015 16:50:19 -0700 Subject: [PATCH 23/23] Missed changeling entry --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 44a87b32d1..a45de808db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,8 @@ * New function to persist plugin configuration to disk * GPM `selfupgrade` will now check PHP version requirements 1. [](#improved) - * If the field allows multiple files, return array + * If the field allows multiple files, return array + * Handle non-array values in file validation 1. [](#bugfix) * Fix when looping `fields` param in a `list` field * Properly convert commas to spaces for media attributes