From 90ea2fc0676cce267c9b9ff6e7d5419e2815e882 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Sat, 4 Mar 2017 13:28:43 -0700 Subject: [PATCH 1/6] Added block/line option to process markdown --- CHANGELOG.md | 1 + system/src/Grav/Common/Twig/TwigExtension.php | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 620be3db5..4feb2da40 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ 1. [](#new) * Added default setting to only allow `direct-installs` from official GPM. Can be configured in `system.yaml` * Added a new `Utils::isValidUrl()` method + * Added optional parameter to `|markdown(false)` filter to toggle block/line processing (default|true = `block`) 1. [](#improved) * Genericized `direct-install` so it can be called via Admin plugin 1. [](#bugfix) diff --git a/system/src/Grav/Common/Twig/TwigExtension.php b/system/src/Grav/Common/Twig/TwigExtension.php index fff032e9c..eb6b960ad 100644 --- a/system/src/Grav/Common/Twig/TwigExtension.php +++ b/system/src/Grav/Common/Twig/TwigExtension.php @@ -432,9 +432,10 @@ class TwigExtension extends \Twig_Extension /** * @param $string * + * @param bool $block Block or Line processing * @return mixed|string */ - public function markdownFilter($string) + public function markdownFilter($string, $block = true) { $page = $this->grav['page']; $defaults = $this->config->get('system.pages.markdown'); @@ -446,7 +447,12 @@ class TwigExtension extends \Twig_Extension $parsedown = new Parsedown($page, $defaults); } - $string = $parsedown->text($string); + if ($block) { + $string = $parsedown->text($string); + } else { + $string = $parsedown->line($string); + } + return $string; } From 4726873b57058ccfeadb3d40b8f37f4f0cd76c1b Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Sun, 5 Mar 2017 18:38:34 -0700 Subject: [PATCH 2/6] Added new Page::folderExists() method --- CHANGELOG.md | 1 + system/src/Grav/Common/Page/Page.php | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4feb2da40..bd7638d4e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ * Added default setting to only allow `direct-installs` from official GPM. Can be configured in `system.yaml` * Added a new `Utils::isValidUrl()` method * Added optional parameter to `|markdown(false)` filter to toggle block/line processing (default|true = `block`) + * Added new `Page::folderExists()` method 1. [](#improved) * Genericized `direct-install` so it can be called via Admin plugin 1. [](#bugfix) diff --git a/system/src/Grav/Common/Page/Page.php b/system/src/Grav/Common/Page/Page.php index 010c906e1..d4bace32f 100644 --- a/system/src/Grav/Common/Page/Page.php +++ b/system/src/Grav/Common/Page/Page.php @@ -2560,6 +2560,16 @@ class Page return $file && $file->exists(); } + /** + * Returns whether or not the current folder exists + * + * @return bool + */ + public function folderExists() + { + return file_exists($this->path()); + } + /** * Cleans the path. * From ebb8786cd92e9b26357a30c9b6dbdb72732bfe3e Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Wed, 8 Mar 2017 15:34:54 -0700 Subject: [PATCH 3/6] Fixed `Page::expires(0)` that was not getting picked up --- CHANGELOG.md | 1 + system/src/Grav/Common/Page/Page.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4feb2da40..e75f40782 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ 1. [](#bugfix) * Fixed a minor bug in Number validation [#1329](https://github.com/getgrav/grav/issues/1329) * Fixed exception when trying to find user account and there is no `user://accounts` folder + * Fixed issue when setting `Page::expires(0)` [Admin #1009](https://github.com/getgrav/grav-plugin-admin/issues/1009) # v1.1.17 ## 02/17/2017 diff --git a/system/src/Grav/Common/Page/Page.php b/system/src/Grav/Common/Page/Page.php index 010c906e1..c1bd10606 100644 --- a/system/src/Grav/Common/Page/Page.php +++ b/system/src/Grav/Common/Page/Page.php @@ -1208,7 +1208,7 @@ class Page $this->expires = $var; } - return empty($this->expires) ? Grav::instance()['config']->get('system.pages.expires') : $this->expires; + return !isset($this->expires) ? Grav::instance()['config']->get('system.pages.expires') : $this->expires; } /** From 23ba8a13867785f72dd52fe7492b8c3dd2306394 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Wed, 8 Mar 2017 15:34:54 -0700 Subject: [PATCH 4/6] Fixed `Page::expires(0)` that was not getting picked up --- CHANGELOG.md | 1 + system/src/Grav/Common/Page/Page.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bd7638d4e..223a4cd53 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ 1. [](#bugfix) * Fixed a minor bug in Number validation [#1329](https://github.com/getgrav/grav/issues/1329) * Fixed exception when trying to find user account and there is no `user://accounts` folder + * Fixed issue when setting `Page::expires(0)` [Admin #1009](https://github.com/getgrav/grav-plugin-admin/issues/1009) # v1.1.17 ## 02/17/2017 diff --git a/system/src/Grav/Common/Page/Page.php b/system/src/Grav/Common/Page/Page.php index d4bace32f..d35aff821 100644 --- a/system/src/Grav/Common/Page/Page.php +++ b/system/src/Grav/Common/Page/Page.php @@ -1208,7 +1208,7 @@ class Page $this->expires = $var; } - return empty($this->expires) ? Grav::instance()['config']->get('system.pages.expires') : $this->expires; + return !isset($this->expires) ? Grav::instance()['config']->get('system.pages.expires') : $this->expires; } /** From ec9342ced10b63bb91926212a0a91a17c62088ff Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Wed, 8 Mar 2017 17:08:22 -0700 Subject: [PATCH 5/6] Removed ID from `nonce_field()` twig function causing validation error https://github.com/getgrav/grav-plugin-form/issues/115 --- CHANGELOG.md | 1 + system/src/Grav/Common/Twig/TwigExtension.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 223a4cd53..6745ca6e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ * Fixed a minor bug in Number validation [#1329](https://github.com/getgrav/grav/issues/1329) * Fixed exception when trying to find user account and there is no `user://accounts` folder * Fixed issue when setting `Page::expires(0)` [Admin #1009](https://github.com/getgrav/grav-plugin-admin/issues/1009) + * Removed ID from `nonce_field()` Twig function causing validation errors [Form #115](https://github.com/getgrav/grav-plugin-form/issues/115) # v1.1.17 ## 02/17/2017 diff --git a/system/src/Grav/Common/Twig/TwigExtension.php b/system/src/Grav/Common/Twig/TwigExtension.php index eb6b960ad..6b3f0b1dc 100644 --- a/system/src/Grav/Common/Twig/TwigExtension.php +++ b/system/src/Grav/Common/Twig/TwigExtension.php @@ -784,7 +784,7 @@ class TwigExtension extends \Twig_Extension */ public function nonceFieldFunc($action, $nonceParamName = 'nonce') { - $string = ''; + $string = ''; return $string; } From c86d791d44058a32cca1f57dc7eeda28646409a1 Mon Sep 17 00:00:00 2001 From: Josh Weiss Date: Thu, 9 Mar 2017 06:54:26 -0800 Subject: [PATCH 6/6] Fix for the blueprint fix. (#1334) Discussed with @mahagr. Saved YAML configs gave undesired extra parameter (!!float 1 for example) because floats were not being cast back to integers upon save. This was even true when the filterNumber function was giving back a correct parameter. filter_var from validateFloat was actually perserving the float variable type which the YAML engine perserved upon Yaml::dump. This is a unconventional fix, but it is the simplest way to handle this edge case. --- system/src/Grav/Common/Data/Validation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/src/Grav/Common/Data/Validation.php b/system/src/Grav/Common/Data/Validation.php index fd886b017..a508312d0 100644 --- a/system/src/Grav/Common/Data/Validation.php +++ b/system/src/Grav/Common/Data/Validation.php @@ -339,7 +339,7 @@ class Validation protected static function filterNumber($value, array $params, array $field) { - return self::validateFloat($value, $params) ? (float) $value : (int) $value; + return (string)(int)$value !== (string)(float)$value ? (float) $value : (int) $value; } protected static function filterDateTime($value, array $params, array $field)