From 3cf8bd59288eeff7f3593cf245666a75f928b39a Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Mon, 13 Mar 2017 13:39:17 -0600 Subject: [PATCH 01/51] Improved `evaluate()` Twig function to use environment/context --- CHANGELOG.md | 1 + system/src/Grav/Common/Twig/TwigExtension.php | 56 ++++++++++++++----- 2 files changed, 44 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6745ca6e2..dc6779a18 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ * Added optional parameter to `|markdown(false)` filter to toggle block/line processing (default|true = `block`) * Added new `Page::folderExists()` method 1. [](#improved) + * `Twig::evaluate()` now takes current environment and context into account * Genericized `direct-install` so it can be called via Admin plugin 1. [](#bugfix) * Fixed a minor bug in Number validation [#1329](https://github.com/getgrav/grav/issues/1329) diff --git a/system/src/Grav/Common/Twig/TwigExtension.php b/system/src/Grav/Common/Twig/TwigExtension.php index 6b3f0b1dc..dfda5c874 100644 --- a/system/src/Grav/Common/Twig/TwigExtension.php +++ b/system/src/Grav/Common/Twig/TwigExtension.php @@ -104,7 +104,8 @@ class TwigExtension extends \Twig_Extension new \Twig_simpleFunction('authorize', [$this, 'authorize']), new \Twig_SimpleFunction('debug', [$this, 'dump'], ['needs_context' => true, 'needs_environment' => true]), new \Twig_SimpleFunction('dump', [$this, 'dump'], ['needs_context' => true, 'needs_environment' => true]), - new \Twig_SimpleFunction('evaluate', [$this, 'evaluateFunc']), + new \Twig_SimpleFunction('evaluate', [$this, 'evaluateStringFunc'], ['needs_context' => true, 'needs_environment' => true]), + new \Twig_SimpleFunction('evaluate_twig', [$this, 'evaluateTwigFunc'], ['needs_context' => true, 'needs_environment' => true]), new \Twig_SimpleFunction('gist', [$this, 'gistFunc']), new \Twig_SimpleFunction('nonce_field', [$this, 'nonceFieldFunc']), new \Twig_simpleFunction('random_string', [$this, 'randomStringFunc']), @@ -587,22 +588,51 @@ class TwigExtension extends \Twig_Extension } /** - * Evaluate a string + * This function will evaluate Twig $twig through the $environment, and return its results. * - * @example {{ evaluate('grav.language.getLanguage') }} - * - * @param string $input String to be evaluated - * - * @return string Returns the evaluated string + * @param \Twig_Environment $environment + * @param array $context + * @param string $twig + * @return mixed */ - public function evaluateFunc($input) - { - if (!$input) { //prevent an obscure Twig error if $input is not set - $input = '""'; - } - return $this->grav['twig']->processString("{{ $input }}"); + public function evaluateTwigFunc( \Twig_Environment $environment, $context, $twig ) { + $loader = $environment->getLoader( ); + + $parsed = $this->parseString( $environment, $context, $twig ); + + $environment->setLoader( $loader ); + return $parsed; } + /** + * This function will evaluate a $string through the $environment, and return its results. + * + * @param \Twig_Environment $environment + * @param $context + * @param $string + * @return mixed + */ + public function evaluateStringFunc(\Twig_Environment $environment, $context, $string ) + { + $parsed = $this->evaluateTwigFunc($environment, $context, "{{ $string }}"); + return $parsed; + } + + /** + * Sets the parser for the environment to Twig_Loader_String, and parsed the string $string. + * + * @param \Twig_Environment $environment + * @param array $context + * @param string $string + * @return string + */ + protected function parseString( \Twig_Environment $environment, $context, $string ) { + $environment->setLoader( new \Twig_Loader_String( ) ); + return $environment->render( $string, $context ); + } + + + /** * Based on Twig_Extension_Debug / twig_var_dump * (c) 2011 Fabien Potencier From 04228ecee972ac8c3a3370dccc9696b3d681f027 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Mon, 13 Mar 2017 18:38:06 -0600 Subject: [PATCH 02/51] Prepare for release --- CHANGELOG.md | 4 ++-- system/defines.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dc6779a18..67a4c7acc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ -# v1.1.18 -## 02/xx/2017 +# v1.2.0-rc.1 +## 03/13/2017 1. [](#new) * Added default setting to only allow `direct-installs` from official GPM. Can be configured in `system.yaml` diff --git a/system/defines.php b/system/defines.php index 387435b35..1e385c003 100644 --- a/system/defines.php +++ b/system/defines.php @@ -8,8 +8,8 @@ // Some standard defines define('GRAV', true); -define('GRAV_VERSION', '1.1.17'); -define('GRAV_TESTING', false); +define('GRAV_VERSION', '1.2.0-rc.1'); +define('GRAV_TESTING', true); define('DS', '/'); if (!defined('GRAV_PHP_MIN')) { From 79d6b8ab22a64d642e8191c9f2bdc926fd746c05 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Mon, 13 Mar 2017 19:20:08 -0600 Subject: [PATCH 03/51] Set default release to testing during RC --- system/config/system.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/config/system.yaml b/system/config/system.yaml index 99628151c..3ef29e623 100644 --- a/system/config/system.yaml +++ b/system/config/system.yaml @@ -134,7 +134,7 @@ session: path: gpm: - releases: stable # Set to either 'stable' or 'testing' + releases: testing # Set to either 'stable' or 'testing' proxy_url: # Configure a manual proxy URL for GPM (eg 127.0.0.1:3128) method: 'auto' # Either 'curl', 'fopen' or 'auto'. 'auto' will try fopen first and if not available cURL verify_peer: true # Sometimes on some systems (Windows most commonly) GPM is unable to connect because the SSL certificate cannot be verified. Disabling this setting might help. From 874160480faf5d968a8f32a3f254618e4dd0ad0d Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Wed, 15 Mar 2017 17:21:49 -0600 Subject: [PATCH 04/51] Optimized theme autoloader to work with hyphenated classnames #1353 --- system/src/Grav/Common/Themes.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/system/src/Grav/Common/Themes.php b/system/src/Grav/Common/Themes.php index e1db8d7db..b98817993 100644 --- a/system/src/Grav/Common/Themes.php +++ b/system/src/Grav/Common/Themes.php @@ -311,17 +311,14 @@ class Themes extends Iterator */ protected function autoloadTheme($class) { - /** @var UniformResourceLocator $locator */ - $locator = $this->grav['locator']; - $prefix = "Grav\\Theme"; if (false !== strpos($class, $prefix)) { // Remove prefix from class $class = substr($class, strlen($prefix)); // Replace namespace tokens to directory separators - $path = strtolower(ltrim(preg_replace('#\\\|_(?!.+\\\)#', '/', $class), '/')); - $file = $locator->findResource("themes://{$path}/{$path}.php"); + $path = $this->grav['inflector']->hyphenize(ltrim($class,"\\")); + $file = $this->grav['locator']->findResource("themes://{$path}/{$path}.php"); // Load class if (file_exists($file)) { From 262951ece4ec8476b3fbe92256644fb7de84e9e2 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Wed, 15 Mar 2017 17:28:00 -0600 Subject: [PATCH 05/51] Updated changelog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 67a4c7acc..fa6da90fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# v1.2.0-rc.2 +## 03/xx/2017 + +1. [](#bugfix) + * Fixed an issue with theme inheritance and hyphenated base themes [#1353](https://github.com/getgrav/grav/issues/1353) + # v1.2.0-rc.1 ## 03/13/2017 From 252b2f71a0667ddad5ee963d018bc44d0b308b25 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Wed, 15 Mar 2017 18:15:34 -0600 Subject: [PATCH 06/51] Stopped invalid derivates throwing fatal error #1341 --- CHANGELOG.md | 1 + system/src/Grav/Common/Page/Media.php | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fa6da90fc..974ff630a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ 1. [](#bugfix) * Fixed an issue with theme inheritance and hyphenated base themes [#1353](https://github.com/getgrav/grav/issues/1353) + * Fixed an issue when trying to use an `@2x` derivative on a non-image media file [#1341](https://github.com/getgrav/grav/issues/1341) # v1.2.0-rc.1 ## 03/13/2017 diff --git a/system/src/Grav/Common/Page/Media.php b/system/src/Grav/Common/Page/Media.php index eb12eeb1c..34396bff3 100644 --- a/system/src/Grav/Common/Page/Media.php +++ b/system/src/Grav/Common/Page/Media.php @@ -141,8 +141,12 @@ class Media extends AbstractMedia foreach ($types['alternative'] as $altMedium) { if ($altMedium['file'] != $medium) { - $ratio = $altMedium['file']->get('width') / $medium->get('width'); - $medium->addAlternative($ratio, $altMedium['file']); + $altWidth = $altMedium['file']->get('width'); + $medWidth = $medium->get('width'); + if ($altWidth && $medWidth) { + $ratio = $altWidth / $medWidth; + $medium->addAlternative($ratio, $altMedium['file']); + } } } } From b5cfb53d784752ad1310f0530da77ea77844ace7 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Wed, 15 Mar 2017 18:16:03 -0600 Subject: [PATCH 07/51] Updated vendor libraries --- CHANGELOG.md | 2 + composer.lock | 239 +++++++++++++++++++++++++++----------------------- 2 files changed, 130 insertions(+), 111 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 974ff630a..c64aa2321 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ # v1.2.0-rc.2 ## 03/xx/2017 +1. [](#improved) + * Updated vendor libraries to latest 1. [](#bugfix) * Fixed an issue with theme inheritance and hyphenated base themes [#1353](https://github.com/getgrav/grav/issues/1353) * Fixed an issue when trying to use an `@2x` derivative on a non-image media file [#1341](https://github.com/getgrav/grav/issues/1341) diff --git a/composer.lock b/composer.lock index 5b083f85d..dee97ada4 100644 --- a/composer.lock +++ b/composer.lock @@ -122,16 +122,16 @@ }, { "name": "donatj/phpuseragentparser", - "version": "v0.6.0", + "version": "v0.7.0", "source": { "type": "git", "url": "https://github.com/donatj/PhpUserAgent.git", - "reference": "a4f515619c8d9697f34dd8da2eb353bb4c57c5dc" + "reference": "73c819d4c7de034f1bfb7c7a36259192d7d7472a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/donatj/PhpUserAgent/zipball/a4f515619c8d9697f34dd8da2eb353bb4c57c5dc", - "reference": "a4f515619c8d9697f34dd8da2eb353bb4c57c5dc", + "url": "https://api.github.com/repos/donatj/PhpUserAgent/zipball/73c819d4c7de034f1bfb7c7a36259192d7d7472a", + "reference": "73c819d4c7de034f1bfb7c7a36259192d7d7472a", "shasum": "" }, "require": { @@ -169,7 +169,7 @@ "user agent", "useragent" ], - "time": "2017-01-23T19:32:09+00:00" + "time": "2017-03-01T22:19:13+00:00" }, { "name": "erusev/parsedown", @@ -177,12 +177,12 @@ "source": { "type": "git", "url": "https://github.com/erusev/parsedown.git", - "reference": "4b6493999acfa7792efa3cb252d90168e6f266b9" + "reference": "3fc442b07857aa11a63fcb2fb6aa03a569153240" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/erusev/parsedown/zipball/4b6493999acfa7792efa3cb252d90168e6f266b9", - "reference": "4b6493999acfa7792efa3cb252d90168e6f266b9", + "url": "https://api.github.com/repos/erusev/parsedown/zipball/3fc442b07857aa11a63fcb2fb6aa03a569153240", + "reference": "3fc442b07857aa11a63fcb2fb6aa03a569153240", "shasum": "" }, "require": { @@ -211,7 +211,7 @@ "markdown", "parser" ], - "time": "2017-01-23 07:45:19" + "time": "2017-03-10 07:41:24" }, { "name": "erusev/parsedown-extra", @@ -259,20 +259,21 @@ }, { "name": "filp/whoops", - "version": "2.1.5", + "version": "2.1.8", "source": { "type": "git", "url": "https://github.com/filp/whoops.git", - "reference": "2abce9d956589122c6443d6265f01cf7e9388e3c" + "reference": "f2950be7da8b8d6c4e77821b6c9d486e36cdc4f3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/filp/whoops/zipball/2abce9d956589122c6443d6265f01cf7e9388e3c", - "reference": "2abce9d956589122c6443d6265f01cf7e9388e3c", + "url": "https://api.github.com/repos/filp/whoops/zipball/f2950be7da8b8d6c4e77821b6c9d486e36cdc4f3", + "reference": "f2950be7da8b8d6c4e77821b6c9d486e36cdc4f3", "shasum": "" }, "require": { - "php": "^5.5.9 || ^7.0" + "php": "^5.5.9 || ^7.0", + "psr/log": "^1.0.1" }, "require-dev": { "mockery/mockery": "0.9.*", @@ -315,7 +316,7 @@ "whoops", "zf2" ], - "time": "2016-12-26T16:13:31+00:00" + "time": "2017-03-07T09:04:45+00:00" }, { "name": "gregwar/cache", @@ -632,16 +633,16 @@ }, { "name": "monolog/monolog", - "version": "1.22.0", + "version": "1.22.1", "source": { "type": "git", "url": "https://github.com/Seldaek/monolog.git", - "reference": "bad29cb8d18ab0315e6c477751418a82c850d558" + "reference": "1e044bc4b34e91743943479f1be7a1d5eb93add0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Seldaek/monolog/zipball/bad29cb8d18ab0315e6c477751418a82c850d558", - "reference": "bad29cb8d18ab0315e6c477751418a82c850d558", + "url": "https://api.github.com/repos/Seldaek/monolog/zipball/1e044bc4b34e91743943479f1be7a1d5eb93add0", + "reference": "1e044bc4b34e91743943479f1be7a1d5eb93add0", "shasum": "" }, "require": { @@ -706,7 +707,7 @@ "logging", "psr-3" ], - "time": "2016-11-26T00:15:39+00:00" + "time": "2017-03-13T07:08:03+00:00" }, { "name": "pimple/pimple", @@ -899,21 +900,21 @@ }, { "name": "symfony/console", - "version": "v2.8.17", + "version": "v2.8.18", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "f3c234cd8db9f7e520a91d695db7d8bb5daeb7a4" + "reference": "81508e6fac4476771275a3f4f53c3fee9b956bfa" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/f3c234cd8db9f7e520a91d695db7d8bb5daeb7a4", - "reference": "f3c234cd8db9f7e520a91d695db7d8bb5daeb7a4", + "url": "https://api.github.com/repos/symfony/console/zipball/81508e6fac4476771275a3f4f53c3fee9b956bfa", + "reference": "81508e6fac4476771275a3f4f53c3fee9b956bfa", "shasum": "" }, "require": { "php": ">=5.3.9", - "symfony/debug": "~2.7,>=2.7.2|~3.0.0", + "symfony/debug": "^2.7.2|~3.0.0", "symfony/polyfill-mbstring": "~1.0" }, "require-dev": { @@ -956,7 +957,7 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2017-02-06T12:04:06+00:00" + "time": "2017-03-04T11:00:12+00:00" }, { "name": "symfony/debug", @@ -1017,16 +1018,16 @@ }, { "name": "symfony/event-dispatcher", - "version": "v2.8.17", + "version": "v2.8.18", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "74877977f90fb9c3e46378d5764217c55f32df34" + "reference": "bb4ec47e8e109c1c1172145732d0aa468d967cd0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/74877977f90fb9c3e46378d5764217c55f32df34", - "reference": "74877977f90fb9c3e46378d5764217c55f32df34", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/bb4ec47e8e109c1c1172145732d0aa468d967cd0", + "reference": "bb4ec47e8e109c1c1172145732d0aa468d967cd0", "shasum": "" }, "require": { @@ -1034,7 +1035,7 @@ }, "require-dev": { "psr/log": "~1.0", - "symfony/config": "~2.0,>=2.0.5|~3.0.0", + "symfony/config": "^2.0.5|~3.0.0", "symfony/dependency-injection": "~2.6|~3.0.0", "symfony/expression-language": "~2.6|~3.0.0", "symfony/stopwatch": "~2.3|~3.0.0" @@ -1073,7 +1074,7 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "https://symfony.com", - "time": "2017-01-02T20:30:24+00:00" + "time": "2017-02-21T08:33:48+00:00" }, { "name": "symfony/polyfill-iconv", @@ -1195,22 +1196,25 @@ }, { "name": "symfony/var-dumper", - "version": "v2.8.17", + "version": "v2.8.18", "source": { "type": "git", "url": "https://github.com/symfony/var-dumper.git", - "reference": "eb4526a20ba9e691f50a7510ea3db3728ada958f" + "reference": "c51daca85371e30ce0e3dea99c7b08e2cb5dbf46" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-dumper/zipball/eb4526a20ba9e691f50a7510ea3db3728ada958f", - "reference": "eb4526a20ba9e691f50a7510ea3db3728ada958f", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/c51daca85371e30ce0e3dea99c7b08e2cb5dbf46", + "reference": "c51daca85371e30ce0e3dea99c7b08e2cb5dbf46", "shasum": "" }, "require": { "php": ">=5.3.9", "symfony/polyfill-mbstring": "~1.0" }, + "conflict": { + "phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0" + }, "require-dev": { "twig/twig": "~1.20|~2.0" }, @@ -1254,20 +1258,20 @@ "debug", "dump" ], - "time": "2017-01-24T13:02:12+00:00" + "time": "2017-02-20T13:37:30+00:00" }, { "name": "symfony/yaml", - "version": "v2.8.17", + "version": "v2.8.18", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "322a8c2dfbca15ad6b1b27e182899f98ec0e0153" + "reference": "2a7bab3c16f6f452c47818fdd08f3b1e49ffcf7d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/322a8c2dfbca15ad6b1b27e182899f98ec0e0153", - "reference": "322a8c2dfbca15ad6b1b27e182899f98ec0e0153", + "url": "https://api.github.com/repos/symfony/yaml/zipball/2a7bab3c16f6f452c47818fdd08f3b1e49ffcf7d", + "reference": "2a7bab3c16f6f452c47818fdd08f3b1e49ffcf7d", "shasum": "" }, "require": { @@ -1303,33 +1307,34 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2017-01-21T16:40:50+00:00" + "time": "2017-03-01T18:13:50+00:00" }, { "name": "twig/twig", - "version": "v1.31.0", + "version": "v1.32.0", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "ddc9e3e20ee9c0b6908f401ac8353635b750eca7" + "reference": "9935b662e24d6e634da88901ab534cc12e8c728f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/ddc9e3e20ee9c0b6908f401ac8353635b750eca7", - "reference": "ddc9e3e20ee9c0b6908f401ac8353635b750eca7", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/9935b662e24d6e634da88901ab534cc12e8c728f", + "reference": "9935b662e24d6e634da88901ab534cc12e8c728f", "shasum": "" }, "require": { "php": ">=5.2.7" }, "require-dev": { + "psr/container": "^1.0", "symfony/debug": "~2.7", "symfony/phpunit-bridge": "~3.2" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.31-dev" + "dev-master": "1.32-dev" } }, "autoload": { @@ -1364,7 +1369,7 @@ "keywords": [ "templating" ], - "time": "2017-01-11T19:36:15+00:00" + "time": "2017-02-27T00:07:03+00:00" } ], "packages-dev": [ @@ -1672,21 +1677,21 @@ }, { "name": "guzzlehttp/guzzle", - "version": "6.2.2", + "version": "6.2.3", "source": { "type": "git", "url": "https://github.com/guzzle/guzzle.git", - "reference": "ebf29dee597f02f09f4d5bbecc68230ea9b08f60" + "reference": "8d6c6cc55186db87b7dc5009827429ba4e9dc006" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/ebf29dee597f02f09f4d5bbecc68230ea9b08f60", - "reference": "ebf29dee597f02f09f4d5bbecc68230ea9b08f60", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/8d6c6cc55186db87b7dc5009827429ba4e9dc006", + "reference": "8d6c6cc55186db87b7dc5009827429ba4e9dc006", "shasum": "" }, "require": { "guzzlehttp/promises": "^1.0", - "guzzlehttp/psr7": "^1.3.1", + "guzzlehttp/psr7": "^1.4", "php": ">=5.5" }, "require-dev": { @@ -1730,7 +1735,7 @@ "rest", "web service" ], - "time": "2016-10-08T15:01:37+00:00" + "time": "2017-02-28T22:50:30+00:00" }, { "name": "guzzlehttp/promises", @@ -1785,16 +1790,16 @@ }, { "name": "guzzlehttp/psr7", - "version": "1.3.1", + "version": "1.4.1", "source": { "type": "git", "url": "https://github.com/guzzle/psr7.git", - "reference": "5c6447c9df362e8f8093bda8f5d8873fe5c7f65b" + "reference": "0d6c7ca039329247e4f0f8f8f6506810e8248855" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/5c6447c9df362e8f8093bda8f5d8873fe5c7f65b", - "reference": "5c6447c9df362e8f8093bda8f5d8873fe5c7f65b", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/0d6c7ca039329247e4f0f8f8f6506810e8248855", + "reference": "0d6c7ca039329247e4f0f8f8f6506810e8248855", "shasum": "" }, "require": { @@ -1830,16 +1835,23 @@ "name": "Michael Dowling", "email": "mtdowling@gmail.com", "homepage": "https://github.com/mtdowling" + }, + { + "name": "Tobias Schultze", + "homepage": "https://github.com/Tobion" } ], - "description": "PSR-7 message implementation", + "description": "PSR-7 message implementation that also provides common utility methods", "keywords": [ "http", "message", + "request", + "response", "stream", - "uri" + "uri", + "url" ], - "time": "2016-06-24T23:00:38+00:00" + "time": "2017-02-27T10:51:17+00:00" }, { "name": "phpdocumentor/reflection-common", @@ -1989,27 +2001,27 @@ }, { "name": "phpspec/prophecy", - "version": "v1.6.2", + "version": "v1.7.0", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "6c52c2722f8460122f96f86346600e1077ce22cb" + "reference": "93d39f1f7f9326d746203c7c056f300f7f126073" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/6c52c2722f8460122f96f86346600e1077ce22cb", - "reference": "6c52c2722f8460122f96f86346600e1077ce22cb", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/93d39f1f7f9326d746203c7c056f300f7f126073", + "reference": "93d39f1f7f9326d746203c7c056f300f7f126073", "shasum": "" }, "require": { "doctrine/instantiator": "^1.0.2", "php": "^5.3|^7.0", "phpdocumentor/reflection-docblock": "^2.0|^3.0.2", - "sebastian/comparator": "^1.1", - "sebastian/recursion-context": "^1.0|^2.0" + "sebastian/comparator": "^1.1|^2.0", + "sebastian/recursion-context": "^1.0|^2.0|^3.0" }, "require-dev": { - "phpspec/phpspec": "^2.0", + "phpspec/phpspec": "^2.5|^3.2", "phpunit/phpunit": "^4.8 || ^5.6.5" }, "type": "library", @@ -2048,7 +2060,7 @@ "spy", "stub" ], - "time": "2016-11-21T14:58:47+00:00" + "time": "2017-03-02T20:05:34+00:00" }, { "name": "phpunit/php-code-coverage", @@ -2202,25 +2214,30 @@ }, { "name": "phpunit/php-timer", - "version": "1.0.8", + "version": "1.0.9", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "38e9124049cf1a164f1e4537caf19c99bf1eb260" + "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/38e9124049cf1a164f1e4537caf19c99bf1eb260", - "reference": "38e9124049cf1a164f1e4537caf19c99bf1eb260", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", + "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": "^5.3.3 || ^7.0" }, "require-dev": { - "phpunit/phpunit": "~4|~5" + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, "autoload": { "classmap": [ "src/" @@ -2242,20 +2259,20 @@ "keywords": [ "timer" ], - "time": "2016-05-12T18:03:57+00:00" + "time": "2017-02-26T11:10:40+00:00" }, { "name": "phpunit/php-token-stream", - "version": "1.4.9", + "version": "1.4.11", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "3b402f65a4cc90abf6e1104e388b896ce209631b" + "reference": "e03f8f67534427a787e21a385a67ec3ca6978ea7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/3b402f65a4cc90abf6e1104e388b896ce209631b", - "reference": "3b402f65a4cc90abf6e1104e388b896ce209631b", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/e03f8f67534427a787e21a385a67ec3ca6978ea7", + "reference": "e03f8f67534427a787e21a385a67ec3ca6978ea7", "shasum": "" }, "require": { @@ -2291,7 +2308,7 @@ "keywords": [ "tokenizer" ], - "time": "2016-11-15T14:06:22+00:00" + "time": "2017-02-27T10:12:30+00:00" }, { "name": "phpunit/phpunit", @@ -2757,16 +2774,16 @@ }, { "name": "sebastian/recursion-context", - "version": "1.0.2", + "version": "1.0.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "913401df809e99e4f47b27cdd781f4a258d58791" + "reference": "b19cc3298482a335a95f3016d2f8a6950f0fbcd7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/913401df809e99e4f47b27cdd781f4a258d58791", - "reference": "913401df809e99e4f47b27cdd781f4a258d58791", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/b19cc3298482a335a95f3016d2f8a6950f0fbcd7", + "reference": "b19cc3298482a335a95f3016d2f8a6950f0fbcd7", "shasum": "" }, "require": { @@ -2806,7 +2823,7 @@ ], "description": "Provides functionality to recursively process PHP variables", "homepage": "http://www.github.com/sebastianbergmann/recursion-context", - "time": "2015-11-11T19:50:13+00:00" + "time": "2016-10-03T07:41:43+00:00" }, { "name": "sebastian/version", @@ -2845,16 +2862,16 @@ }, { "name": "symfony/browser-kit", - "version": "v3.2.3", + "version": "v3.2.6", "source": { "type": "git", "url": "https://github.com/symfony/browser-kit.git", - "reference": "394a2475a3a89089353fde5714a7f402fbb83880" + "reference": "2fe0caa60c1a1dfeefd0425741182687a9b382b8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/browser-kit/zipball/394a2475a3a89089353fde5714a7f402fbb83880", - "reference": "394a2475a3a89089353fde5714a7f402fbb83880", + "url": "https://api.github.com/repos/symfony/browser-kit/zipball/2fe0caa60c1a1dfeefd0425741182687a9b382b8", + "reference": "2fe0caa60c1a1dfeefd0425741182687a9b382b8", "shasum": "" }, "require": { @@ -2898,20 +2915,20 @@ ], "description": "Symfony BrowserKit Component", "homepage": "https://symfony.com", - "time": "2017-01-31T21:49:23+00:00" + "time": "2017-02-21T09:12:04+00:00" }, { "name": "symfony/css-selector", - "version": "v3.2.3", + "version": "v3.2.6", "source": { "type": "git", "url": "https://github.com/symfony/css-selector.git", - "reference": "f0e628f04fc055c934b3211cfabdb1c59eefbfaa" + "reference": "a48f13dc83c168f1253a5d2a5a4fb46c36244c4c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/css-selector/zipball/f0e628f04fc055c934b3211cfabdb1c59eefbfaa", - "reference": "f0e628f04fc055c934b3211cfabdb1c59eefbfaa", + "url": "https://api.github.com/repos/symfony/css-selector/zipball/a48f13dc83c168f1253a5d2a5a4fb46c36244c4c", + "reference": "a48f13dc83c168f1253a5d2a5a4fb46c36244c4c", "shasum": "" }, "require": { @@ -2951,20 +2968,20 @@ ], "description": "Symfony CssSelector Component", "homepage": "https://symfony.com", - "time": "2017-01-02T20:32:22+00:00" + "time": "2017-02-21T09:12:04+00:00" }, { "name": "symfony/dom-crawler", - "version": "v3.2.3", + "version": "v3.2.6", "source": { "type": "git", "url": "https://github.com/symfony/dom-crawler.git", - "reference": "b814b41373fc4e535aff8c765abe39545216f391" + "reference": "403944e294cf4ceb3b8447f54cbad88ea7b99cee" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/b814b41373fc4e535aff8c765abe39545216f391", - "reference": "b814b41373fc4e535aff8c765abe39545216f391", + "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/403944e294cf4ceb3b8447f54cbad88ea7b99cee", + "reference": "403944e294cf4ceb3b8447f54cbad88ea7b99cee", "shasum": "" }, "require": { @@ -3007,20 +3024,20 @@ ], "description": "Symfony DomCrawler Component", "homepage": "https://symfony.com", - "time": "2017-01-21T17:14:11+00:00" + "time": "2017-02-21T09:12:04+00:00" }, { "name": "symfony/finder", - "version": "v3.2.3", + "version": "v3.2.6", "source": { "type": "git", "url": "https://github.com/symfony/finder.git", - "reference": "8c71141cae8e2957946b403cc71a67213c0380d6" + "reference": "92d7476d2df60cd851a3e13e078664b1deb8ce10" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/8c71141cae8e2957946b403cc71a67213c0380d6", - "reference": "8c71141cae8e2957946b403cc71a67213c0380d6", + "url": "https://api.github.com/repos/symfony/finder/zipball/92d7476d2df60cd851a3e13e078664b1deb8ce10", + "reference": "92d7476d2df60cd851a3e13e078664b1deb8ce10", "shasum": "" }, "require": { @@ -3056,20 +3073,20 @@ ], "description": "Symfony Finder Component", "homepage": "https://symfony.com", - "time": "2017-01-02T20:32:22+00:00" + "time": "2017-02-21T09:12:04+00:00" }, { "name": "symfony/process", - "version": "v3.2.3", + "version": "v3.2.6", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "32646a7cf53f3956c76dcb5c82555224ae321858" + "reference": "68bfa8c83f24c0ac04ea7193bcdcda4519f41892" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/32646a7cf53f3956c76dcb5c82555224ae321858", - "reference": "32646a7cf53f3956c76dcb5c82555224ae321858", + "url": "https://api.github.com/repos/symfony/process/zipball/68bfa8c83f24c0ac04ea7193bcdcda4519f41892", + "reference": "68bfa8c83f24c0ac04ea7193bcdcda4519f41892", "shasum": "" }, "require": { @@ -3105,7 +3122,7 @@ ], "description": "Symfony Process Component", "homepage": "https://symfony.com", - "time": "2017-02-03T12:11:38+00:00" + "time": "2017-03-04T12:23:14+00:00" }, { "name": "webmozart/assert", From 0290ffd26e5b6df03a5c4a3b3741760c8329ecfa Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Fri, 17 Mar 2017 15:13:12 -0600 Subject: [PATCH 08/51] Added the ability for a specific page to disable debugger --- CHANGELOG.md | 1 + system/blueprints/pages/default.yaml | 12 ++++++++++++ system/src/Grav/Common/Page/Page.php | 9 +++++++++ 3 files changed, 22 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c64aa2321..119115ac1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ 1. [](#improved) * Updated vendor libraries to latest + * Added the ability to disable debugger on a per-page basis with `debugger: false` in page frontmatter 1. [](#bugfix) * Fixed an issue with theme inheritance and hyphenated base themes [#1353](https://github.com/getgrav/grav/issues/1353) * Fixed an issue when trying to use an `@2x` derivative on a non-image media file [#1341](https://github.com/getgrav/grav/issues/1341) diff --git a/system/blueprints/pages/default.yaml b/system/blueprints/pages/default.yaml index 4b96ac6a2..60f298fcc 100644 --- a/system/blueprints/pages/default.yaml +++ b/system/blueprints/pages/default.yaml @@ -291,6 +291,18 @@ form: validate: type: bool + header.debugger: + type: toggle + toggleable: true + label: PLUGIN_ADMIN.DEBUGGER + help: PLUGIN_ADMIN.DEBUGGER_HELP + highlight: 1 + options: + 1: PLUGIN_ADMIN.ENABLED + 0: PLUGIN_ADMIN.DISABLED + validate: + type: bool + header.template: type: text toggleable: true diff --git a/system/src/Grav/Common/Page/Page.php b/system/src/Grav/Common/Page/Page.php index d35aff821..c5adb80ef 100644 --- a/system/src/Grav/Common/Page/Page.php +++ b/system/src/Grav/Common/Page/Page.php @@ -86,6 +86,7 @@ class Page protected $hide_home_route; protected $ssl; protected $template_format; + protected $debugger; /** * @var Page Unmodified (original) version of the page. Used for copying and moving the page. @@ -145,6 +146,11 @@ class Page $this->extension($extension); } + // some debugger logic + if (isset($this->debugger) && $this->debugger == false) { + Grav::instance()['debugger']->enabled(false); + } + // extract page language from page extension $language = trim(basename($this->extension(), 'md'), '.') ?: null; $this->language($language); @@ -424,6 +430,9 @@ class Page if (isset($this->header->template_format)) { $this->template_format = $this->header->template_format; } + if (isset($this->header->debugger)) { + $this->debugger = (bool)$this->header->debugger; + } } return $this->header; From 66a21db5046c3aa8e9bd538f526229b34a75c15e Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Fri, 17 Mar 2017 15:52:39 -0600 Subject: [PATCH 09/51] Prepare for release --- CHANGELOG.md | 2 +- system/defines.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 119115ac1..73c4febf5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ # v1.2.0-rc.2 -## 03/xx/2017 +## 03/17/2017 1. [](#improved) * Updated vendor libraries to latest diff --git a/system/defines.php b/system/defines.php index 1e385c003..e4cbb480e 100644 --- a/system/defines.php +++ b/system/defines.php @@ -8,7 +8,7 @@ // Some standard defines define('GRAV', true); -define('GRAV_VERSION', '1.2.0-rc.1'); +define('GRAV_VERSION', '1.2.0-rc.2'); define('GRAV_TESTING', true); define('DS', '/'); From 701f18e782014d97687adb6363c53f05ad409c0c Mon Sep 17 00:00:00 2001 From: Ole Vik Date: Sat, 18 Mar 2017 18:50:18 +0100 Subject: [PATCH 10/51] Fix field class for Config/Site "Default language" (#1357) --- system/blueprints/config/site.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/blueprints/config/site.yaml b/system/blueprints/config/site.yaml index fe783f084..57fd3c57a 100644 --- a/system/blueprints/config/site.yaml +++ b/system/blueprints/config/site.yaml @@ -19,7 +19,7 @@ form: default_lang: type: text label: PLUGIN_ADMIN.SITE_DEFAULT_LANG - size: vsmall + size: x-small placeholder: PLUGIN_ADMIN.SITE_DEFAULT_LANG_PLACEHOLDER help: PLUGIN_ADMIN.SITE_DEFAULT_LANG_HELP From 7e50c340c78d5ae8faab4299c845054a78f0f689 Mon Sep 17 00:00:00 2001 From: ricardo118 Date: Sat, 18 Mar 2017 17:50:37 +0000 Subject: [PATCH 11/51] Fix class for Config/System"Default ordering" (#1359) Fix class for both "Default ordering" and "Append URL extension" --- system/blueprints/config/system.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/system/blueprints/config/system.yaml b/system/blueprints/config/system.yaml index 03f6b898e..84468495f 100644 --- a/system/blueprints/config/system.yaml +++ b/system/blueprints/config/system.yaml @@ -102,7 +102,7 @@ form: pages.order.by: type: select - size: long + size: large classes: fancy label: PLUGIN_ADMIN.DEFAULT_ORDERING help: PLUGIN_ADMIN.DEFAULT_ORDERING_HELP @@ -155,6 +155,7 @@ form: pages.append_url_extension: type: text + size: x-small placeholder: "e.g. .html" label: PLUGIN_ADMIN.APPEND_URL_EXT help: PLUGIN_ADMIN.APPEND_URL_EXT_HELP From cd37ea0689700b0b3a47a599eff3fdc370171a3b Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Sat, 18 Mar 2017 13:54:25 -0600 Subject: [PATCH 12/51] Chaned image quality field to use new range field --- system/blueprints/config/system.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/system/blueprints/config/system.yaml b/system/blueprints/config/system.yaml index 03f6b898e..4a85a2973 100644 --- a/system/blueprints/config/system.yaml +++ b/system/blueprints/config/system.yaml @@ -856,13 +856,12 @@ form: fields: images.default_image_quality: - type: text + type: range append: '%' label: PLUGIN_ADMIN.DEFAULT_IMAGE_QUALITY help: PLUGIN_ADMIN.DEFAULT_IMAGE_QUALITY_HELP classes: x-small validate: - type: number min: 1 max: 100 From 10a15ef33f384da86b630db118dbe2bf10364925 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Sun, 19 Mar 2017 21:24:46 -0600 Subject: [PATCH 13/51] Simplified some logic and fixed an issue with system-level process twig logic #1351 --- CHANGELOG.md | 6 ++++++ system/src/Grav/Common/Page/Page.php | 4 ++-- system/src/Grav/Common/Twig/Twig.php | 9 +++------ 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 73c4febf5..e345ca4f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# v1.2.0-rc.3 +## 03/xx/2017 + +1. [](#bugfix) + * Simplified modular/twig processing logic and fixed an issue with system process config [#1351](https://github.com/getgrav/grav/issues/1351) + # v1.2.0-rc.2 ## 03/17/2017 diff --git a/system/src/Grav/Common/Page/Page.php b/system/src/Grav/Common/Page/Page.php index c5adb80ef..d6637f753 100644 --- a/system/src/Grav/Common/Page/Page.php +++ b/system/src/Grav/Common/Page/Page.php @@ -575,7 +575,8 @@ class Page $process_markdown = $this->shouldProcess('markdown'); - $process_twig = $this->shouldProcess('twig'); + $process_twig = $this->shouldProcess('twig') || $this->modularTwig() ; + $cache_enable = isset($this->header->cache_enable) ? $this->header->cache_enable : $config->get('system.cache.enabled', true); $twig_first = isset($this->header->twig_first) ? $this->header->twig_first : $config->get('system.pages.twig_first', @@ -2036,7 +2037,6 @@ class Page if ($var !== null) { $this->modular_twig = (bool)$var; if ($var) { - $this->process['twig'] = true; $this->visible(false); // some routable logic if (empty($this->header->routable)) { diff --git a/system/src/Grav/Common/Twig/Twig.php b/system/src/Grav/Common/Twig/Twig.php index 9ef9e3e6d..4ca45c7f6 100644 --- a/system/src/Grav/Common/Twig/Twig.php +++ b/system/src/Grav/Common/Twig/Twig.php @@ -229,25 +229,22 @@ class Twig $twig_vars['header'] = $item->header(); $local_twig = clone($this->twig); - $modular_twig = $item->modularTwig(); - $process_twig = isset($item->header()->process['twig']) ? $item->header()->process['twig'] : false; - - $output = ''; try { // Process Modular Twig - if ($modular_twig) { + if ($item->modularTwig()) { $twig_vars['content'] = $content; $template = $item->template() . TEMPLATE_EXT; $output = $content = $local_twig->render($template, $twig_vars); } // Process in-page Twig - if (!$modular_twig || ($modular_twig && $process_twig)) { + if ($item->shouldProcess('twig')) { $name = '@Page:' . $item->path(); $this->setTemplate($name, $content); $output = $local_twig->render($name, $twig_vars); } + } catch (\Twig_Error_Loader $e) { throw new \RuntimeException($e->getRawMessage(), 404, $e); } From 5c3455624685fc40afb1da0ce4c8d54bc5d076c6 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Mon, 20 Mar 2017 10:19:37 -0600 Subject: [PATCH 14/51] Fix for page-level debugger override changing the option site-wide --- CHANGELOG.md | 1 + system/src/Grav/Common/Page/Page.php | 19 ++++++++++++++----- .../Common/Service/PageServiceProvider.php | 5 +++++ 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e345ca4f9..b53fb1bd7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ 1. [](#bugfix) * Simplified modular/twig processing logic and fixed an issue with system process config [#1351](https://github.com/getgrav/grav/issues/1351) + * Fix for page-level debugger override changing the option site-wide # v1.2.0-rc.2 ## 03/17/2017 diff --git a/system/src/Grav/Common/Page/Page.php b/system/src/Grav/Common/Page/Page.php index d6637f753..fdcfe1f36 100644 --- a/system/src/Grav/Common/Page/Page.php +++ b/system/src/Grav/Common/Page/Page.php @@ -146,11 +146,6 @@ class Page $this->extension($extension); } - // some debugger logic - if (isset($this->debugger) && $this->debugger == false) { - Grav::instance()['debugger']->enabled(false); - } - // extract page language from page extension $language = trim(basename($this->extension(), 'md'), '.') ?: null; $this->language($language); @@ -1383,6 +1378,20 @@ class Page return $this->process; } + /** + * Returns the state of the debugger override etting for this page + * + * @return mixed + */ + public function debugger() + { + if (isset($this->debugger) && $this->debugger == false) { + return false; + } else { + return true; + } + } + /** * Function to merge page metadata tags and build an array of Metadata objects * that can then be rendered in the page. diff --git a/system/src/Grav/Common/Service/PageServiceProvider.php b/system/src/Grav/Common/Service/PageServiceProvider.php index 0db18a298..c57c8d1e0 100644 --- a/system/src/Grav/Common/Service/PageServiceProvider.php +++ b/system/src/Grav/Common/Service/PageServiceProvider.php @@ -34,6 +34,11 @@ class PageServiceProvider implements ServiceProviderInterface $page = $pages->dispatch($path); + // some debugger override logic + if ($page->debugger() == false) { + Grav::instance()['debugger']->enabled(false); + } + // Redirection tests if ($page) { /** @var Language $language */ From 330a90b0ab810f1ed3ca4f89f2e13cd4bc5b8087 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Mon, 20 Mar 2017 10:36:26 -0600 Subject: [PATCH 15/51] Added `language_codes` to Twig init to allow for easy language name/code/native-name lookup --- CHANGELOG.md | 2 ++ system/src/Grav/Common/Twig/Twig.php | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b53fb1bd7..ea32e2aeb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ # v1.2.0-rc.3 ## 03/xx/2017 +1. [](#new) + * Added `language_codes` to Twig init to allow for easy language name/code/native-name lookup 1. [](#bugfix) * Simplified modular/twig processing logic and fixed an issue with system process config [#1351](https://github.com/getgrav/grav/issues/1351) * Fix for page-level debugger override changing the option site-wide diff --git a/system/src/Grav/Common/Twig/Twig.php b/system/src/Grav/Common/Twig/Twig.php index 4ca45c7f6..7eec5b775 100644 --- a/system/src/Grav/Common/Twig/Twig.php +++ b/system/src/Grav/Common/Twig/Twig.php @@ -11,6 +11,7 @@ namespace Grav\Common\Twig; use Grav\Common\Grav; use Grav\Common\Config\Config; use Grav\Common\Language\Language; +use Grav\Common\Language\LanguageCodes; use Grav\Common\Page\Page; use RocketTheme\Toolbox\ResourceLocator\UniformResourceLocator; use RocketTheme\Toolbox\Event\Event; @@ -173,7 +174,7 @@ class Twig 'theme_dir' => $locator->findResource('theme://'), 'theme_url' => $this->grav['base_url'] . '/' . $locator->findResource('theme://', false), 'html_lang' => $this->grav['language']->getActive() ?: $config->get('site.default_lang', 'en'), - + 'language_codes' => new LanguageCodes, ]; } } From 04e1710de1e635f3730388d8f50743b24b8e2d72 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Mon, 20 Mar 2017 11:26:31 -0600 Subject: [PATCH 16/51] Updated composer.json to pick up latest Gregwar Image library --- composer.json | 2 +- composer.lock | 40 ++++++++++++++++++++-------------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/composer.json b/composer.json index 832587378..ae4a9775d 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "filp/whoops": "~2.0", "matthiasmullie/minify": "^1.3", "monolog/monolog": "~1.0", - "gregwar/image": "dev-master#72568cfbeb77515278f2ccb386fc344e874b7ae8", + "gregwar/image": "dev-master", "donatj/phpuseragentparser": "~0.3", "pimple/pimple": "~3.0", "rockettheme/toolbox": "~1.0", diff --git a/composer.lock b/composer.lock index dee97ada4..384f8e4bb 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "4e5b9333d3ac2de823c68c9c8e0f2017", + "content-hash": "a81345ff6d6bffba8747f6c7c5a5c7d6", "packages": [ { "name": "antoligy/dom-string-iterators", @@ -368,12 +368,12 @@ "source": { "type": "git", "url": "https://github.com/Gregwar/Image.git", - "reference": "72568cfbeb77515278f2ccb386fc344e874b7ae8" + "reference": "a53c77a0449eb9ee3e9cbcabcedfeb8637457670" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Gregwar/Image/zipball/72568cfbeb77515278f2ccb386fc344e874b7ae8", - "reference": "72568cfbeb77515278f2ccb386fc344e874b7ae8", + "url": "https://api.github.com/repos/Gregwar/Image/zipball/a53c77a0449eb9ee3e9cbcabcedfeb8637457670", + "reference": "a53c77a0449eb9ee3e9cbcabcedfeb8637457670", "shasum": "" }, "require": { @@ -411,7 +411,7 @@ "gd", "image" ], - "time": "2016-07-12 17:02:18" + "time": "2017-03-07 18:31:22" }, { "name": "league/climate", @@ -466,16 +466,16 @@ }, { "name": "matthiasmullie/minify", - "version": "1.3.43", + "version": "1.3.44", "source": { "type": "git", "url": "https://github.com/matthiasmullie/minify.git", - "reference": "aa50b2dab6fa7bfd402d334fe51005d6f2526ad7" + "reference": "a7fc4a98ef8f2cf38bba701b51f1a84a1d67bc5c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/matthiasmullie/minify/zipball/aa50b2dab6fa7bfd402d334fe51005d6f2526ad7", - "reference": "aa50b2dab6fa7bfd402d334fe51005d6f2526ad7", + "url": "https://api.github.com/repos/matthiasmullie/minify/zipball/a7fc4a98ef8f2cf38bba701b51f1a84a1d67bc5c", + "reference": "a7fc4a98ef8f2cf38bba701b51f1a84a1d67bc5c", "shasum": "" }, "require": { @@ -519,7 +519,7 @@ "minifier", "minify" ], - "time": "2017-01-26T15:48:07+00:00" + "time": "2017-03-16T16:42:50+00:00" }, { "name": "matthiasmullie/path-converter", @@ -852,16 +852,16 @@ }, { "name": "seld/cli-prompt", - "version": "1.0.2", + "version": "1.0.3", "source": { "type": "git", "url": "https://github.com/Seldaek/cli-prompt.git", - "reference": "8cbe10923cae5bcd7c5a713f6703fc4727c8c1b4" + "reference": "a19a7376a4689d4d94cab66ab4f3c816019ba8dd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Seldaek/cli-prompt/zipball/8cbe10923cae5bcd7c5a713f6703fc4727c8c1b4", - "reference": "8cbe10923cae5bcd7c5a713f6703fc4727c8c1b4", + "url": "https://api.github.com/repos/Seldaek/cli-prompt/zipball/a19a7376a4689d4d94cab66ab4f3c816019ba8dd", + "reference": "a19a7376a4689d4d94cab66ab4f3c816019ba8dd", "shasum": "" }, "require": { @@ -896,7 +896,7 @@ "input", "prompt" ], - "time": "2016-04-18T09:31:41+00:00" + "time": "2017-03-18T11:32:45+00:00" }, { "name": "symfony/console", @@ -1790,16 +1790,16 @@ }, { "name": "guzzlehttp/psr7", - "version": "1.4.1", + "version": "1.4.2", "source": { "type": "git", "url": "https://github.com/guzzle/psr7.git", - "reference": "0d6c7ca039329247e4f0f8f8f6506810e8248855" + "reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/0d6c7ca039329247e4f0f8f8f6506810e8248855", - "reference": "0d6c7ca039329247e4f0f8f8f6506810e8248855", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/f5b8a8512e2b58b0071a7280e39f14f72e05d87c", + "reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c", "shasum": "" }, "require": { @@ -1851,7 +1851,7 @@ "uri", "url" ], - "time": "2017-02-27T10:51:17+00:00" + "time": "2017-03-20T17:10:46+00:00" }, { "name": "phpdocumentor/reflection-common", From da61196b7b68e5bf8f44ceacb2da7375c596e950 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Mon, 20 Mar 2017 13:30:53 -0600 Subject: [PATCH 17/51] Cleanup package files via GPM install to make them more windows-friendly #1361 --- CHANGELOG.md | 1 + system/src/Grav/Console/Gpm/InstallCommand.php | 1 + 2 files changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ea32e2aeb..2f05f1915 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ * Added `language_codes` to Twig init to allow for easy language name/code/native-name lookup 1. [](#bugfix) * Simplified modular/twig processing logic and fixed an issue with system process config [#1351](https://github.com/getgrav/grav/issues/1351) + * Cleanup package files via GPM install to make them more windows-friendly [#1361](https://github.com/getgrav/grav/pull/1361) * Fix for page-level debugger override changing the option site-wide # v1.2.0-rc.2 diff --git a/system/src/Grav/Console/Gpm/InstallCommand.php b/system/src/Grav/Console/Gpm/InstallCommand.php index abf5e8163..70a113515 100644 --- a/system/src/Grav/Console/Gpm/InstallCommand.php +++ b/system/src/Grav/Console/Gpm/InstallCommand.php @@ -563,6 +563,7 @@ class InstallCommand extends ConsoleCommand $tmp_dir = Grav::instance()['locator']->findResource('tmp://', true, true); $this->tmp = $tmp_dir . '/Grav-' . uniqid(); $filename = $package->slug . basename($package->zipball_url); + $filename = preg_replace('/[\\\\\/:"*?&<>|]+/mi', '-', $filename); $query = ''; if ($package->premium) { From 13bc19f1e3356397f3a2e3307846033469aa301e Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Mon, 20 Mar 2017 15:25:41 -0600 Subject: [PATCH 18/51] Moved debugger logic to avoid null page instances. --- system/src/Grav/Common/Service/PageServiceProvider.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/system/src/Grav/Common/Service/PageServiceProvider.php b/system/src/Grav/Common/Service/PageServiceProvider.php index c57c8d1e0..24b1e7e4f 100644 --- a/system/src/Grav/Common/Service/PageServiceProvider.php +++ b/system/src/Grav/Common/Service/PageServiceProvider.php @@ -34,16 +34,16 @@ class PageServiceProvider implements ServiceProviderInterface $page = $pages->dispatch($path); - // some debugger override logic - if ($page->debugger() == false) { - Grav::instance()['debugger']->enabled(false); - } - // Redirection tests if ($page) { /** @var Language $language */ $language = $c['language']; + // some debugger override logic + if ($page->debugger() == false) { + Grav::instance()['debugger']->enabled(false); + } + if ($c['config']->get('system.force_ssl')) { if (!isset($_SERVER['HTTPS']) || $_SERVER["HTTPS"] != "on") { $url = "https://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]; From 0d471599d7d25f5892540b8f8e1a8ee5cd4d942d Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Tue, 21 Mar 2017 15:35:16 -0600 Subject: [PATCH 19/51] Changed logic for order handling --- system/blueprints/pages/default.yaml | 22 +++++------ system/src/Grav/Common/Page/Page.php | 56 +++++++++++++++++++++++++--- 2 files changed, 62 insertions(+), 16 deletions(-) diff --git a/system/blueprints/pages/default.yaml b/system/blueprints/pages/default.yaml index 60f298fcc..70823a988 100644 --- a/system/blueprints/pages/default.yaml +++ b/system/blueprints/pages/default.yaml @@ -117,17 +117,6 @@ form: title: PLUGIN_ADMIN.SETTINGS underline: true - ordering: - type: toggle - label: PLUGIN_ADMIN.FOLDER_NUMERIC_PREFIX - help: PLUGIN_ADMIN.FOLDER_NUMERIC_PREFIX_HELP - highlight: 1 - options: - 1: PLUGIN_ADMIN.ENABLED - 0: PLUGIN_ADMIN.DISABLED - validate: - type: bool - folder: type: text label: PLUGIN_ADMIN.FOLDER_NAME @@ -165,6 +154,17 @@ form: title: PLUGIN_ADMIN.ORDERING underline: true + ordering: + type: toggle + label: PLUGIN_ADMIN.FOLDER_NUMERIC_PREFIX + help: PLUGIN_ADMIN.FOLDER_NUMERIC_PREFIX_HELP + highlight: 1 + options: + 1: PLUGIN_ADMIN.ENABLED + 0: PLUGIN_ADMIN.DISABLED + validate: + type: bool + order: type: order label: PLUGIN_ADMIN.PAGE_ORDER diff --git a/system/src/Grav/Common/Page/Page.php b/system/src/Grav/Common/Page/Page.php index fdcfe1f36..384032847 100644 --- a/system/src/Grav/Common/Page/Page.php +++ b/system/src/Grav/Common/Page/Page.php @@ -887,12 +887,12 @@ class Page /** * Save page if there's a file assigned to it. * - * @param bool $reorder Internal use. + * @param bool|mixed $reorder Internal use. */ public function save($reorder = true) { - // Perform move, copy or reordering if needed. - $this->doRelocation($reorder); + // Perform move, copy [or reordering] if needed. + $this->doRelocation(); $file = $this->file(); if ($file) { @@ -901,6 +901,13 @@ class Page $file->markdown($this->raw_content); $file->save(); } + + // Perform reorder if required + if ($reorder && is_array($reorder)) { + $this->doReorder($reorder); + } + + $this->_original = null; } /** @@ -2605,6 +2612,46 @@ class Page return $path; } + protected function doReorder($new_order) + { + if (!$this->_original) { + return; + } + + $siblings = $this->parent()->children(); + $siblings->order('slug', 'asc', $new_order); + + $counter = 1; + + // Reorder all moved pages. + foreach ($siblings as $slug => $page) { + $order = intval(trim($page->order(),'.')); + + if ($order) { + + if ($page->path() == $this->path()) { + // Handle current page; we do want to change ordering number, but nothing else. + $this->order($counter++); + $this->save(false); + } else { + // Handle all the other pages. + $page = Grav::instance()['pages']->get($page->path()); + + if ($page && $page->exists() && !$page->_action) { + + $page = $page->move($this->parent()); + $page->order($counter++); + $page->save(false); + + } + } + + + } + + } + } + /** * Moves or copies the page in filesystem. * @@ -2614,7 +2661,7 @@ class Page * * @throws Exception */ - protected function doRelocation($reorder) + protected function doRelocation($reorder = false) { if (!$this->_original) { return; @@ -2680,7 +2727,6 @@ class Page } } - $this->_original = null; } protected function setPublishState() From ef7ff9ec4ed54511b26ae35f01feb05b79812b2d Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Tue, 21 Mar 2017 20:20:08 -0600 Subject: [PATCH 20/51] Improved reorder logic and removed old logic --- system/src/Grav/Common/Page/Page.php | 82 +++++++--------------------- 1 file changed, 21 insertions(+), 61 deletions(-) diff --git a/system/src/Grav/Common/Page/Page.php b/system/src/Grav/Common/Page/Page.php index 384032847..b2abf120f 100644 --- a/system/src/Grav/Common/Page/Page.php +++ b/system/src/Grav/Common/Page/Page.php @@ -804,6 +804,9 @@ class Page if ($name == 'folder') { return preg_replace(PAGE_ORDER_PREFIX_REGEX, '', $this->folder); } + if ($name == 'slug') { + return $this->slug(); + } if ($name == 'name') { $language = $this->language() ? '.' . $this->language() : ''; $name_val = str_replace($language . '.md', '', $this->name()); @@ -2612,43 +2615,47 @@ class Page return $path; } + /** + * Reorders all siblings according to a defined order + * + * @param $new_order + */ protected function doReorder($new_order) { if (!$this->_original) { return; } + $pages = Grav::instance()['pages']; + $pages->init(); + + $this->_original->path($this->path()); + $siblings = $this->parent()->children(); $siblings->order('slug', 'asc', $new_order); - $counter = 1; + $counter = 0; // Reorder all moved pages. foreach ($siblings as $slug => $page) { $order = intval(trim($page->order(),'.')); + $counter++; if ($order) { - - if ($page->path() == $this->path()) { + if ($page->path() == $this->path() && $this->folderExists()) { // Handle current page; we do want to change ordering number, but nothing else. - $this->order($counter++); + $this->order($counter); $this->save(false); } else { // Handle all the other pages. - $page = Grav::instance()['pages']->get($page->path()); - - if ($page && $page->exists() && !$page->_action) { - + $page = $pages->get($page->path()); + if ($page && $page->folderExists() && !$page->_action) { $page = $page->move($this->parent()); - $page->order($counter++); + $page->order($counter); $page->save(false); - } } - - } - } } @@ -2657,61 +2664,14 @@ class Page * * @internal * - * @param bool $reorder - * * @throws Exception */ - protected function doRelocation($reorder = false) + protected function doRelocation() { if (!$this->_original) { return; } - // Do reordering. - if ($reorder && $this->order() != $this->_original->order()) { - /** @var Pages $pages */ - $pages = Grav::instance()['pages']; - - $parent = $this->parent(); - - // Extract visible children from the parent page. - $list = []; - /** @var Page $page */ - foreach ($parent->children()->visible() as $page) { - if ($page->order()) { - $list[$page->slug] = $page->path(); - } - } - - // If page was moved, take it out of the list. - if ($this->_action == 'move') { - unset($list[$this->slug()]); - } - - $list = array_values($list); - - // Then add it back to the new location (if needed). - if ($this->order()) { - array_splice($list, min($this->order() - 1, count($list)), 0, [$this->path()]); - } - - // Reorder all moved pages. - foreach ($list as $order => $path) { - if ($path == $this->path()) { - // Handle current page; we do want to change ordering number, but nothing else. - $this->order($order + 1); - } else { - // Handle all the other pages. - $page = $pages->get($path); - - if ($page && $page->exists() && !$page->_action && $page->order() != $order + 1) { - $page = $page->move($parent); - $page->order($order + 1); - $page->save(false); - } - } - } - } if (is_dir($this->_original->path())) { if ($this->_action == 'move') { Folder::move($this->_original->path(), $this->path()); From 30f8eca90514c85a8987c292cfe8b451b1a21cad Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Wed, 22 Mar 2017 12:03:49 -0600 Subject: [PATCH 21/51] Allow Twig `url()` function to pass through external URLs --- CHANGELOG.md | 1 + system/src/Grav/Common/Twig/TwigExtension.php | 13 ++++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f05f1915..5a834b291 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ * Simplified modular/twig processing logic and fixed an issue with system process config [#1351](https://github.com/getgrav/grav/issues/1351) * Cleanup package files via GPM install to make them more windows-friendly [#1361](https://github.com/getgrav/grav/pull/1361) * Fix for page-level debugger override changing the option site-wide + * Allow `url()` twig function to pass-through external links # v1.2.0-rc.2 ## 03/17/2017 diff --git a/system/src/Grav/Common/Twig/TwigExtension.php b/system/src/Grav/Common/Twig/TwigExtension.php index dfda5c874..e12fa9a4c 100644 --- a/system/src/Grav/Common/Twig/TwigExtension.php +++ b/system/src/Grav/Common/Twig/TwigExtension.php @@ -570,15 +570,22 @@ class TwigExtension extends \Twig_Extension $domain = true; } + if (Grav::instance()['uri']->isExternal($input)) { + return $input; + } - if (strpos((string)$input, '://')) { + $input = ltrim((string)$input, '/'); + + if (Utils::contains((string)$input, '://')) { /** @var UniformResourceLocator $locator */ $locator = $this->grav['locator']; + + // Get relative path to the resource (or false if not found). - $resource = $locator->findResource((string)$input, false); + $resource = $locator->findResource($input, false); } else { - $resource = (string)$input; + $resource = $input; } /** @var Uri $uri */ From b8164d3fe64af7d882b60ec07c41cc2aea411c9a Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Wed, 22 Mar 2017 12:10:37 -0600 Subject: [PATCH 22/51] changelog updated --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a834b291..b78a6b898 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## 03/xx/2017 1. [](#new) + * Refactored Page re-ordering to handle all siblings at once * Added `language_codes` to Twig init to allow for easy language name/code/native-name lookup 1. [](#bugfix) * Simplified modular/twig processing logic and fixed an issue with system process config [#1351](https://github.com/getgrav/grav/issues/1351) From 88ccc25c4789266f63ab25b3198a76e8e075e39e Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Wed, 22 Mar 2017 17:12:36 -0600 Subject: [PATCH 23/51] Added an admin only section for child ordering --- CHANGELOG.md | 2 ++ system/blueprints/pages/default.yaml | 21 ++++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b78a6b898..815ce4e3d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ 1. [](#new) * Refactored Page re-ordering to handle all siblings at once * Added `language_codes` to Twig init to allow for easy language name/code/native-name lookup +1. [](#improved) + * Added an _Admin Overrides_ section with option to choose the order of children in Pages Management 1. [](#bugfix) * Simplified modular/twig processing logic and fixed an issue with system process config [#1351](https://github.com/getgrav/grav/issues/1351) * Cleanup package files via GPM install to make them more windows-friendly [#1361](https://github.com/getgrav/grav/pull/1361) diff --git a/system/blueprints/pages/default.yaml b/system/blueprints/pages/default.yaml index 70823a988..0806ba24f 100644 --- a/system/blueprints/pages/default.yaml +++ b/system/blueprints/pages/default.yaml @@ -167,7 +167,7 @@ form: order: type: order - label: PLUGIN_ADMIN.PAGE_ORDER + label: PLUGIN_ADMIN.SORTABLE_PAGES sitemap: overrides: @@ -314,6 +314,25 @@ form: toggleable: true help: PLUGIN_ADMIN.APPEND_URL_EXT_HELP + admin_only: + type: section + title: PLUGIN_ADMIN.ADMIN_SPECIFIC_OVERRIDES + underline: true + + fields: + + header.admin.children_display_order: + type: select + label: PLUGIN_ADMIN.ADMIN_CHILDREN_DISPLAY_ORDER + help: PLUGIN_ADMIN.ADMIN_CHILDREN_DISPLAY_ORDER_HELP + toggleable: true + classes: fancy + default: 'collection' + options: + 'default': 'Ordered by Folder name (default)' + 'collection': 'Ordered by Collection definition' + + header.order_by: type: hidden From c1530394570b518261f9242510d23e9a93357972 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Wed, 22 Mar 2017 17:29:47 -0600 Subject: [PATCH 24/51] Fixed loading issues with improperly named themes #1373 --- system/src/Grav/Common/Themes.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/system/src/Grav/Common/Themes.php b/system/src/Grav/Common/Themes.php index b98817993..4ce6162b7 100644 --- a/system/src/Grav/Common/Themes.php +++ b/system/src/Grav/Common/Themes.php @@ -316,6 +316,15 @@ class Themes extends Iterator // Remove prefix from class $class = substr($class, strlen($prefix)); + // Try Old style theme classes + $path = strtolower(ltrim(preg_replace('#\\\|_(?!.+\\\)#', '/', $class), '/')); + $file = $this->grav['locator']->findResource("themes://{$path}/{$path}.php"); + + // Load class + if (file_exists($file)) { + return include_once($file); + } + // Replace namespace tokens to directory separators $path = $this->grav['inflector']->hyphenize(ltrim($class,"\\")); $file = $this->grav['locator']->findResource("themes://{$path}/{$path}.php"); From f8fbc82196f8daa49ed9bd73cb08ca9cd73bed77 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Wed, 22 Mar 2017 17:30:00 -0600 Subject: [PATCH 25/51] Prepare for release --- CHANGELOG.md | 3 ++- system/defines.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 815ce4e3d..da0c01c10 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ # v1.2.0-rc.3 -## 03/xx/2017 +## 03/22/2017 1. [](#new) * Refactored Page re-ordering to handle all siblings at once @@ -7,6 +7,7 @@ 1. [](#improved) * Added an _Admin Overrides_ section with option to choose the order of children in Pages Management 1. [](#bugfix) + * Fixed loading issues with improperly named themes (use old broken method first) [#1373](https://github.com/getgrav/grav/issues/1373) * Simplified modular/twig processing logic and fixed an issue with system process config [#1351](https://github.com/getgrav/grav/issues/1351) * Cleanup package files via GPM install to make them more windows-friendly [#1361](https://github.com/getgrav/grav/pull/1361) * Fix for page-level debugger override changing the option site-wide diff --git a/system/defines.php b/system/defines.php index e4cbb480e..2ee857983 100644 --- a/system/defines.php +++ b/system/defines.php @@ -8,7 +8,7 @@ // Some standard defines define('GRAV', true); -define('GRAV_VERSION', '1.2.0-rc.2'); +define('GRAV_VERSION', '1.2.0-rc.3'); define('GRAV_TESTING', true); define('DS', '/'); From f45362b5b5fedbc16d35b5d2098774a8620cc6ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Potvin?= Date: Sun, 26 Mar 2017 13:00:42 -0400 Subject: [PATCH 26/51] Invite users to join Slack instead of Gitter (#1385) Since the team is now on Slack. --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5d5c52774..22362c8a5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -110,7 +110,7 @@ Good pull requests - patches, improvements, new features - are a fantastic help. They should remain focused in scope and avoid containing unrelated commits. -**Please ask first** in Gitter or in the Forum before embarking on any significant pull request (e.g. +**Please ask first** in [Slack](https://getgrav.org/slack) or in the Forum before embarking on any significant pull request (e.g. implementing features, refactoring code..), otherwise you risk spending a lot of time working on something that the project's developers might not want to merge into the project. From 41e7142dfc278d02aaf2dce1ef15b9f4eb1d709e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Potvin?= Date: Sun, 26 Mar 2017 13:02:50 -0400 Subject: [PATCH 27/51] [#1200] Clarified `install` and `direct-install` (#1384) To help user that need to install specific version of a package. So far it wasn't absolutely clear how to achieve and some users ended up asking for help or opening issues asking for the feature. --- system/src/Grav/Console/Gpm/DirectInstallCommand.php | 2 +- system/src/Grav/Console/Gpm/InstallCommand.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/system/src/Grav/Console/Gpm/DirectInstallCommand.php b/system/src/Grav/Console/Gpm/DirectInstallCommand.php index 202840289..679d5c635 100644 --- a/system/src/Grav/Console/Gpm/DirectInstallCommand.php +++ b/system/src/Grav/Console/Gpm/DirectInstallCommand.php @@ -31,7 +31,7 @@ class DirectInstallCommand extends ConsoleCommand ->addArgument( 'package-file', InputArgument::REQUIRED, - 'The local location or remote URL to an installable package file' + 'Installable package local or remote . Can install specific version' ) ->setDescription("Installs Grav, plugin, or theme directly from a file or a URL") ->setHelp('The direct-install command installs Grav, plugin, or theme directly from a file or a URL'); diff --git a/system/src/Grav/Console/Gpm/InstallCommand.php b/system/src/Grav/Console/Gpm/InstallCommand.php index 70a113515..bd01ead2b 100644 --- a/system/src/Grav/Console/Gpm/InstallCommand.php +++ b/system/src/Grav/Console/Gpm/InstallCommand.php @@ -80,7 +80,7 @@ class InstallCommand extends ConsoleCommand ->addArgument( 'package', InputArgument::IS_ARRAY | InputArgument::REQUIRED, - 'The package(s) that are desired to be installed. Use the "index" command for a list of packages' + 'Package(s) to install. Use "bin/gpm index" to list packages. Use "bin/gpm direct-install" to install a specific version' ) ->setDescription("Performs the installation of plugins and themes") ->setHelp('The install command allows to install plugins and themes'); From 5c40337ff0b7fbd8baa08a1dc8fdd0c7126fa0e7 Mon Sep 17 00:00:00 2001 From: Hugh Barnes Date: Mon, 27 Mar 2017 13:50:22 +1300 Subject: [PATCH 28/51] CSS pipeline rewrite URL fix for webserver root-based paths (#1383) * Implement fix to not rewrite paths in CSS pipeline when CSS URLs use a path startng at webserver root (e.g. url('/path/to/asset')) - fixes #1382 * Amend CSS pipeline's resource location checking predicates to use Utils::startsWith, and consolidate into a single predicate * Add back colon to data URL prefix test Copy error in last commit would have broken any relative path beginning with the string 'data' --- system/src/Grav/Common/Assets.php | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/system/src/Grav/Common/Assets.php b/system/src/Grav/Common/Assets.php index eeb3adabf..20b1fce26 100644 --- a/system/src/Grav/Common/Assets.php +++ b/system/src/Grav/Common/Assets.php @@ -1255,13 +1255,8 @@ class Assets $old_url = $matches[2]; - // ensure this is not a data url - if (strpos($old_url, 'data:') === 0) { - return $matches[0]; - } - - // ensure this is not a remote url - if ($this->isRemoteLink($old_url)) { + // Ensure link is not rooted to webserver, a data URL, or to a remote host + if (Utils::startsWith($old_url, '/') || Utils::startsWith($old_url, 'data:') || $this->isRemoteLink($old_url)) { return $matches[0]; } From 8fe018a7ddfaed9c873f64e77fa65194ab649892 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Wed, 29 Mar 2017 22:43:26 -0700 Subject: [PATCH 29/51] Add file upload for user avatar in admin profile --- system/blueprints/user/account.yaml | 7 +++++++ system/src/Grav/Common/User/User.php | 16 ++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/system/blueprints/user/account.yaml b/system/blueprints/user/account.yaml index ff657b4c4..7a7c82b57 100644 --- a/system/blueprints/user/account.yaml +++ b/system/blueprints/user/account.yaml @@ -8,6 +8,13 @@ form: type: userinfo size: large + avatar: + type: file + size: large + destination: 'user://accounts/avatars' + multiple: false + random_name: true + content: type: section title: PLUGIN_ADMIN.ACCOUNT diff --git a/system/src/Grav/Common/User/User.php b/system/src/Grav/Common/User/User.php index d5c108ff8..d0c35eb31 100644 --- a/system/src/Grav/Common/User/User.php +++ b/system/src/Grav/Common/User/User.php @@ -239,4 +239,20 @@ class User extends Data { return $this->authorize($action); } + + /** + * Return the User's avatar URL + * + * @return string + */ + public function avatarUrl() + { + if ($this->avatar) { + $avatar = $this->avatar; + $avatar = array_shift($avatar); + return Grav::instance()['base_url'] . '/' . $avatar['path']; + } else { + return 'https://www.gravatar.com/avatar/' . md5($this->email); + } + } } From 6564ea98b17cabdd02f79828b6ce0bdb3654f645 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Thu, 30 Mar 2017 14:30:20 -0700 Subject: [PATCH 30/51] Analysis fixes --- system/src/Grav/Common/Page/Page.php | 2 +- system/src/Grav/Common/Service/PageServiceProvider.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/system/src/Grav/Common/Page/Page.php b/system/src/Grav/Common/Page/Page.php index b2abf120f..e844a75b7 100644 --- a/system/src/Grav/Common/Page/Page.php +++ b/system/src/Grav/Common/Page/Page.php @@ -1395,7 +1395,7 @@ class Page */ public function debugger() { - if (isset($this->debugger) && $this->debugger == false) { + if (isset($this->debugger) && $this->debugger === false) { return false; } else { return true; diff --git a/system/src/Grav/Common/Service/PageServiceProvider.php b/system/src/Grav/Common/Service/PageServiceProvider.php index 24b1e7e4f..a363411a1 100644 --- a/system/src/Grav/Common/Service/PageServiceProvider.php +++ b/system/src/Grav/Common/Service/PageServiceProvider.php @@ -40,7 +40,7 @@ class PageServiceProvider implements ServiceProviderInterface $language = $c['language']; // some debugger override logic - if ($page->debugger() == false) { + if ($page->debugger() === false) { Grav::instance()['debugger']->enabled(false); } From 25ba6198e5ee4d358a9619223daec4d12960b2c7 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Fri, 31 Mar 2017 11:09:29 -0600 Subject: [PATCH 31/51] switched to stable composer vendor libs --- composer.json | 4 +- composer.lock | 129 ++++++++++++++++++++++++++++++++------------------ 2 files changed, 86 insertions(+), 47 deletions(-) diff --git a/composer.json b/composer.json index ae4a9775d..d1e846396 100644 --- a/composer.json +++ b/composer.json @@ -8,7 +8,7 @@ "require": { "php": ">=5.5.9", "twig/twig": "~1.24", - "erusev/parsedown": "dev-master as 1.6.0", + "erusev/parsedown": "~1.6", "erusev/parsedown-extra": "~0.7", "symfony/yaml": "~2.8", "symfony/console": "~2.8", @@ -19,7 +19,7 @@ "filp/whoops": "~2.0", "matthiasmullie/minify": "^1.3", "monolog/monolog": "~1.0", - "gregwar/image": "dev-master", + "gregwar/image": "~2.0", "donatj/phpuseragentparser": "~0.3", "pimple/pimple": "~3.0", "rockettheme/toolbox": "~1.0", diff --git a/composer.lock b/composer.lock index 384f8e4bb..1066c3520 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "a81345ff6d6bffba8747f6c7c5a5c7d6", + "content-hash": "e981b23b44354d081ec1e1ac214656a1", "packages": [ { "name": "antoligy/dom-string-iterators", @@ -173,16 +173,16 @@ }, { "name": "erusev/parsedown", - "version": "dev-master", + "version": "1.6.2", "source": { "type": "git", "url": "https://github.com/erusev/parsedown.git", - "reference": "3fc442b07857aa11a63fcb2fb6aa03a569153240" + "reference": "1bf24f7334fe16c88bf9d467863309ceaf285b01" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/erusev/parsedown/zipball/3fc442b07857aa11a63fcb2fb6aa03a569153240", - "reference": "3fc442b07857aa11a63fcb2fb6aa03a569153240", + "url": "https://api.github.com/repos/erusev/parsedown/zipball/1bf24f7334fe16c88bf9d467863309ceaf285b01", + "reference": "1bf24f7334fe16c88bf9d467863309ceaf285b01", "shasum": "" }, "require": { @@ -211,7 +211,7 @@ "markdown", "parser" ], - "time": "2017-03-10 07:41:24" + "time": "2017-03-29T16:04:15+00:00" }, { "name": "erusev/parsedown-extra", @@ -363,17 +363,17 @@ }, { "name": "gregwar/image", - "version": "dev-master", + "version": "v2.0.21", "target-dir": "Gregwar/Image", "source": { "type": "git", "url": "https://github.com/Gregwar/Image.git", - "reference": "a53c77a0449eb9ee3e9cbcabcedfeb8637457670" + "reference": "c9899e4c71009338f89a8c63c12c681692533ede" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Gregwar/Image/zipball/a53c77a0449eb9ee3e9cbcabcedfeb8637457670", - "reference": "a53c77a0449eb9ee3e9cbcabcedfeb8637457670", + "url": "https://api.github.com/repos/Gregwar/Image/zipball/c9899e4c71009338f89a8c63c12c681692533ede", + "reference": "c9899e4c71009338f89a8c63c12c681692533ede", "shasum": "" }, "require": { @@ -411,7 +411,7 @@ "gd", "image" ], - "time": "2017-03-07 18:31:22" + "time": "2017-01-24T09:29:39+00:00" }, { "name": "league/climate", @@ -1311,16 +1311,16 @@ }, { "name": "twig/twig", - "version": "v1.32.0", + "version": "v1.33.0", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "9935b662e24d6e634da88901ab534cc12e8c728f" + "reference": "05cf49921b13f6f01d3cfdf9018cfa7a8086fd5a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/9935b662e24d6e634da88901ab534cc12e8c728f", - "reference": "9935b662e24d6e634da88901ab534cc12e8c728f", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/05cf49921b13f6f01d3cfdf9018cfa7a8086fd5a", + "reference": "05cf49921b13f6f01d3cfdf9018cfa7a8086fd5a", "shasum": "" }, "require": { @@ -1329,12 +1329,12 @@ "require-dev": { "psr/container": "^1.0", "symfony/debug": "~2.7", - "symfony/phpunit-bridge": "~3.2" + "symfony/phpunit-bridge": "~3.3@dev" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.32-dev" + "dev-master": "1.33-dev" } }, "autoload": { @@ -1369,7 +1369,7 @@ "keywords": [ "templating" ], - "time": "2017-02-27T00:07:03+00:00" + "time": "2017-03-22T15:40:09+00:00" } ], "packages-dev": [ @@ -1434,16 +1434,16 @@ }, { "name": "codeception/codeception", - "version": "2.2.9", + "version": "2.2.10", "source": { "type": "git", "url": "https://github.com/Codeception/Codeception.git", - "reference": "0204f1362040d3e408404af2545e5fa27e8964e2" + "reference": "c32a3f92834db08ceedb4666ea2265c3aa43396e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Codeception/Codeception/zipball/0204f1362040d3e408404af2545e5fa27e8964e2", - "reference": "0204f1362040d3e408404af2545e5fa27e8964e2", + "url": "https://api.github.com/repos/Codeception/Codeception/zipball/c32a3f92834db08ceedb4666ea2265c3aa43396e", + "reference": "c32a3f92834db08ceedb4666ea2265c3aa43396e", "shasum": "" }, "require": { @@ -1458,6 +1458,7 @@ "phpunit/phpunit": ">4.8.20 <6.0", "sebastian/comparator": "~1.1", "sebastian/diff": "^1.4", + "stecman/symfony-console-completion": "^0.7.0", "symfony/browser-kit": ">=2.7 <4.0", "symfony/console": ">=2.7 <4.0", "symfony/css-selector": ">=2.7 <4.0", @@ -1522,7 +1523,7 @@ "functional testing", "unit testing" ], - "time": "2017-02-04T02:04:21+00:00" + "time": "2017-03-25T03:19:52+00:00" }, { "name": "doctrine/instantiator", @@ -1580,34 +1581,37 @@ }, { "name": "facebook/webdriver", - "version": "1.3.0", + "version": "1.4.0", "source": { "type": "git", "url": "https://github.com/facebook/php-webdriver.git", - "reference": "77300c4ab2025d4316635f592ec849ca7323bd8c" + "reference": "3ea034c056189e11c0ce7985332a9f4b5b2b5db2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/facebook/php-webdriver/zipball/77300c4ab2025d4316635f592ec849ca7323bd8c", - "reference": "77300c4ab2025d4316635f592ec849ca7323bd8c", + "url": "https://api.github.com/repos/facebook/php-webdriver/zipball/3ea034c056189e11c0ce7985332a9f4b5b2b5db2", + "reference": "3ea034c056189e11c0ce7985332a9f4b5b2b5db2", "shasum": "" }, "require": { "ext-curl": "*", + "ext-zip": "*", "php": "^5.5 || ~7.0", "symfony/process": "^2.8 || ^3.1" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^1.11", + "friendsofphp/php-cs-fixer": "^2.0", "php-mock/php-mock-phpunit": "^1.1", "phpunit/phpunit": "4.6.* || ~5.0", "satooshi/php-coveralls": "^1.0", "squizlabs/php_codesniffer": "^2.6" }, - "suggest": { - "phpdocumentor/phpdocumentor": "2.*" - }, "type": "library", + "extra": { + "branch-alias": { + "dev-community": "1.5-dev" + } + }, "autoload": { "psr-4": { "Facebook\\WebDriver\\": "lib/" @@ -1617,7 +1621,7 @@ "license": [ "Apache-2.0" ], - "description": "A PHP client for WebDriver", + "description": "A PHP client for Selenium WebDriver", "homepage": "https://github.com/facebook/php-webdriver", "keywords": [ "facebook", @@ -1625,7 +1629,7 @@ "selenium", "webdriver" ], - "time": "2017-01-13T15:48:08+00:00" + "time": "2017-03-22T10:56:03+00:00" }, { "name": "fzaninotto/faker", @@ -2860,6 +2864,51 @@ "homepage": "https://github.com/sebastianbergmann/version", "time": "2015-06-21T13:59:46+00:00" }, + { + "name": "stecman/symfony-console-completion", + "version": "0.7.0", + "source": { + "type": "git", + "url": "https://github.com/stecman/symfony-console-completion.git", + "reference": "5461d43e53092b3d3b9dbd9d999f2054730f4bbb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/stecman/symfony-console-completion/zipball/5461d43e53092b3d3b9dbd9d999f2054730f4bbb", + "reference": "5461d43e53092b3d3b9dbd9d999f2054730f4bbb", + "shasum": "" + }, + "require": { + "php": ">=5.3.2", + "symfony/console": "~2.3 || ~3.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.6.x-dev" + } + }, + "autoload": { + "psr-4": { + "Stecman\\Component\\Symfony\\Console\\BashCompletion\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Stephen Holdaway", + "email": "stephen@stecman.co.nz" + } + ], + "description": "Automatic BASH completion for Symfony Console Component based applications.", + "time": "2016-02-24T05:08:54+00:00" + }, { "name": "symfony/browser-kit", "version": "v3.2.6", @@ -3175,19 +3224,9 @@ "time": "2016-11-23T20:04:58+00:00" } ], - "aliases": [ - { - "alias": "1.6.0", - "alias_normalized": "1.6.0.0", - "version": "9999999-dev", - "package": "erusev/parsedown" - } - ], + "aliases": [], "minimum-stability": "stable", - "stability-flags": { - "erusev/parsedown": 20, - "gregwar/image": 20 - }, + "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, "platform": { From 3a645ab4a2b765d1c38a3304101c3eb3030f18df Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Fri, 31 Mar 2017 11:09:40 -0600 Subject: [PATCH 32/51] updated changelog --- CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index da0c01c10..27830d321 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +# v1.2.0 +## 03/xx/2017 + +1. [](#new) + * Added file upload for user avatar in user/admin blueprint +1. [](#improved) + * Analysis fixes + * Switched to stable composer lib versions + # v1.2.0-rc.3 ## 03/22/2017 From ca4f6f3c5c45cf542ab838656f307656a4a4cc09 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Fri, 31 Mar 2017 11:28:34 -0600 Subject: [PATCH 33/51] Prepare for release --- CHANGELOG.md | 2 +- system/config/system.yaml | 2 +- system/defines.php | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 27830d321..955c87d34 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ # v1.2.0 -## 03/xx/2017 +## 03/31/2017 1. [](#new) * Added file upload for user avatar in user/admin blueprint diff --git a/system/config/system.yaml b/system/config/system.yaml index 3ef29e623..99628151c 100644 --- a/system/config/system.yaml +++ b/system/config/system.yaml @@ -134,7 +134,7 @@ session: path: gpm: - releases: testing # Set to either 'stable' or 'testing' + releases: stable # Set to either 'stable' or 'testing' proxy_url: # Configure a manual proxy URL for GPM (eg 127.0.0.1:3128) method: 'auto' # Either 'curl', 'fopen' or 'auto'. 'auto' will try fopen first and if not available cURL verify_peer: true # Sometimes on some systems (Windows most commonly) GPM is unable to connect because the SSL certificate cannot be verified. Disabling this setting might help. diff --git a/system/defines.php b/system/defines.php index 2ee857983..1865c871a 100644 --- a/system/defines.php +++ b/system/defines.php @@ -8,8 +8,8 @@ // Some standard defines define('GRAV', true); -define('GRAV_VERSION', '1.2.0-rc.3'); -define('GRAV_TESTING', true); +define('GRAV_VERSION', '1.2.0'); +define('GRAV_TESTING', false); define('DS', '/'); if (!defined('GRAV_PHP_MIN')) { From cbf3df4bf1f48d7278b74dd5306231e9149cf7c0 Mon Sep 17 00:00:00 2001 From: Djamil Legato Date: Fri, 31 Mar 2017 11:30:58 -0700 Subject: [PATCH 34/51] Trying using Gimme to switch Golang version --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 74dcfa60f..6b91d20bd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -55,6 +55,7 @@ before_install: fi - if [ $TRAVIS_BRANCH != 'develop' ] && [ $TRAVIS_PHP_VERSION == "5.6" ] && [ $TRAVIS_PULL_REQUEST == "false" ]; then export 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); + eval "$(curl -sL https://raw.githubusercontent.com/travis-ci/gimme/master/gimme | GIMME_GO_VERSION=1.8 bash)"; go get github.com/aktau/github-release; 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 From 06e880de57c139fcf341466f91f6f45f1bb9011d Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Sat, 1 Apr 2017 22:13:43 -0600 Subject: [PATCH 35/51] Fixed a bad method signature causing warning when running tests on `GPMTest` object --- CHANGELOG.md | 6 ++++++ tests/unit/Grav/Common/GPM/GPMTest.php | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 955c87d34..6d612c6d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# v1.2.1 +## xx/xx/2017 + +1. [](#bugfix) + * Fixed a bad method signature causing warning when running tests on `GPMTest` object + # v1.2.0 ## 03/31/2017 diff --git a/tests/unit/Grav/Common/GPM/GPMTest.php b/tests/unit/Grav/Common/GPM/GPMTest.php index 1597dd872..aba4a8cf2 100644 --- a/tests/unit/Grav/Common/GPM/GPMTest.php +++ b/tests/unit/Grav/Common/GPM/GPMTest.php @@ -11,7 +11,7 @@ class GpmStub extends GPM { public $data; - public function findPackage($packageName) + public function findPackage($packageName, $ignore_exception = false) { if (isset($this->data[$packageName])) { return $this->data[$packageName]; @@ -320,4 +320,4 @@ class GpmTest extends \Codeception\TestCase\Test $this->assertSame(null, $this->gpm->calculateVersionNumberFromDependencyVersion('*')); $this->assertSame('2.0.2', $this->gpm->calculateVersionNumberFromDependencyVersion('2.0.2')); } -} \ No newline at end of file +} From 459b7c4a33ec622be112d3507e2bbe3d50c67ed4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Potvin?= Date: Sun, 2 Apr 2017 20:45:57 -0400 Subject: [PATCH 36/51] Fix #1389 related to `bin/gpm direct-install` (#1397) Add --all-yes and --destination options Fix a problem where temporary package files will not be cleaned upon command error. --- .../Grav/Console/Gpm/DirectInstallCommand.php | 57 +++++++++++++++++-- .../Grav/Console/DirectInstallCommandTest.php | 40 +++++++++++++ 2 files changed, 93 insertions(+), 4 deletions(-) create mode 100644 tests/functional/Grav/Console/DirectInstallCommandTest.php diff --git a/system/src/Grav/Console/Gpm/DirectInstallCommand.php b/system/src/Grav/Console/Gpm/DirectInstallCommand.php index 679d5c635..46f9bcb5b 100644 --- a/system/src/Grav/Console/Gpm/DirectInstallCommand.php +++ b/system/src/Grav/Console/Gpm/DirectInstallCommand.php @@ -15,6 +15,7 @@ use Grav\Common\GPM\Installer; use Grav\Common\GPM\Response; use Grav\Console\ConsoleCommand; use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Question\ConfirmationQuestion; class DirectInstallCommand extends ConsoleCommand @@ -33,6 +34,19 @@ class DirectInstallCommand extends ConsoleCommand InputArgument::REQUIRED, 'Installable package local or remote . Can install specific version' ) + ->addOption( + 'all-yes', + 'y', + InputOption::VALUE_NONE, + 'Assumes yes (or best approach) instead of prompting' + ) + ->addOption( + 'destination', + 'd', + InputOption::VALUE_OPTIONAL, + 'The destination where the package should be installed at. By default this would be where the grav instance has been launched from', + GRAV_ROOT + ) ->setDescription("Installs Grav, plugin, or theme directly from a file or a URL") ->setHelp('The direct-install command installs Grav, plugin, or theme directly from a file or a URL'); } @@ -42,12 +56,26 @@ class DirectInstallCommand extends ConsoleCommand */ protected function serve() { + // Making sure the destination is usable + $this->destination = realpath($this->input->getOption('destination')); + + if ( + !Installer::isGravInstance($this->destination) || + !Installer::isValidDestination($this->destination, [Installer::EXISTS, Installer::IS_LINK]) + ) { + $this->output->writeln("ERROR: " . Installer::lastErrorMsg()); + exit; + } + + + $this->all_yes = $this->input->getOption('all-yes'); + $package_file = $this->input->getArgument('package-file'); $helper = $this->getHelper('question'); $question = new ConfirmationQuestion('Are you sure you want to direct-install '.$package_file.' [y|N] ', false); - $answer = $helper->ask($this->input, $this->output, $question); + $answer = $this->all_yes ? true : $helper->ask($this->input, $this->output, $question); if (!$answer) { $this->output->writeln("exiting..."); @@ -72,7 +100,7 @@ class DirectInstallCommand extends ConsoleCommand $this->output->writeln(''); exit; } - + if ($zip) { $this->output->write("\x0D"); $this->output->write(" |- Downloading package... 100%"); @@ -97,6 +125,8 @@ class DirectInstallCommand extends ConsoleCommand if (!$extracted) { $this->output->write("\x0D"); $this->output->writeln(" |- Extracting package... failed"); + Folder::delete($tmp_source); + Folder::delete($tmp_zip); exit; } @@ -109,6 +139,8 @@ class DirectInstallCommand extends ConsoleCommand if (!$type) { $this->output->writeln(" '- ERROR: Not a valid Grav package"); $this->output->writeln(''); + Folder::delete($tmp_source); + Folder::delete($tmp_zip); exit; } @@ -128,11 +160,13 @@ class DirectInstallCommand extends ConsoleCommand $question = new ConfirmationQuestion(" | '- Dependencies will not be satisfied. Continue ? [y|N] ", false); - $answer = $helper->ask($this->input, $this->output, $question); + $answer = $this->all_yes ? true : $helper->ask($this->input, $this->output, $question); if (!$answer) { $this->output->writeln("exiting..."); $this->output->writeln(''); + Folder::delete($tmp_source); + Folder::delete($tmp_zip); exit; } } @@ -147,6 +181,8 @@ class DirectInstallCommand extends ConsoleCommand $this->output->writeln(" |- Checking destination... symbolic link"); $this->output->writeln(" '- ERROR: symlinks found... " . GRAV_ROOT.""); $this->output->writeln(''); + Folder::delete($tmp_source); + Folder::delete($tmp_zip); exit; } @@ -161,6 +197,8 @@ class DirectInstallCommand extends ConsoleCommand if (!$name) { $this->output->writeln("ERROR: Name could not be determined. Please specify with --name|-n"); $this->output->writeln(''); + Folder::delete($tmp_source); + Folder::delete($tmp_zip); exit; } @@ -175,6 +213,8 @@ class DirectInstallCommand extends ConsoleCommand $this->output->writeln(" |- Checking destination... symbolic link"); $this->output->writeln(" '- ERROR: symlink found... " . GRAV_ROOT . DS . $install_path . ''); $this->output->writeln(''); + Folder::delete($tmp_source); + Folder::delete($tmp_zip); exit; } else { @@ -184,7 +224,16 @@ class DirectInstallCommand extends ConsoleCommand $this->output->write(" |- Installing package... "); - Installer::install($zip, GRAV_ROOT, ['install_path' => $install_path, 'theme' => (($type == 'theme')), 'is_update' => $is_update], $extracted); + Installer::install( + $zip, + $this->destination, + $options = [ + 'install_path' => $install_path, + 'theme' => (($type == 'theme')), + 'is_update' => $is_update + ], + $extracted + ); } Folder::delete($tmp_source); diff --git a/tests/functional/Grav/Console/DirectInstallCommandTest.php b/tests/functional/Grav/Console/DirectInstallCommandTest.php new file mode 100644 index 000000000..d1bc6cf76 --- /dev/null +++ b/tests/functional/Grav/Console/DirectInstallCommandTest.php @@ -0,0 +1,40 @@ +grav = Fixtures::get('grav'); + $this->directInstallCommand = new DirectInstallCommand(); + } + +} + +/** + * Why this test file is empty + * + * Wasn't able to call a symfony\console. Kept having $output problem. + * symfony console \NullOutput didn't cut it. + * + * We would also need to Mock tests since downloading packages would + * make tests slow and unreliable. But it's not worth the time ATM. + * + * Look at Gpm/InstallCommandTest.php + * + * For the full story: https://git.io/vSlI3 + */ From d338d79acbe42a0f5c76bac78c99b3032014cc32 Mon Sep 17 00:00:00 2001 From: Flavio Copes Date: Tue, 4 Apr 2017 16:51:16 +0200 Subject: [PATCH 37/51] When determining language from HTTP_ACCEPT_LANGUAGE, also try base language only (#1402) Fixes Safari sending the language code always with a locale (e.g. it-it or fr-fr) --- CHANGELOG.md | 1 + system/src/Grav/Common/Language/Language.php | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d612c6d5..cc79d16f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ 1. [](#bugfix) * Fixed a bad method signature causing warning when running tests on `GPMTest` object + * When determining language from `HTTP_ACCEPT_LANGUAGE`, also try base language only # v1.2.0 ## 03/31/2017 diff --git a/system/src/Grav/Common/Language/Language.php b/system/src/Grav/Common/Language/Language.php index a8363816e..dbf2b95ba 100644 --- a/system/src/Grav/Common/Language/Language.php +++ b/system/src/Grav/Common/Language/Language.php @@ -203,6 +203,15 @@ class Language } } + // repeat if not found, try base language only - fixes Safari sending the language code always + // with a locale (e.g. it-it or fr-fr) + foreach ($preferred as $lang) { + $lang = substr($lang, 0, 2); + if ($this->validate($lang)) { + $this->active = $lang; + break; + } + } } } } From 4aa6dce8530fb1f62a33264a1da03dad0f80e7be Mon Sep 17 00:00:00 2001 From: Gilles van Eeden Date: Tue, 4 Apr 2017 16:53:27 +0200 Subject: [PATCH 38/51] add function isajaxrequest() (#1400) * Update Taxonomy.php * Update TwigExtension.php * Update TwigExtension.php Incorrect comment updated. * Update TwigExtension.php Add function ishuman() to detect agent disposition. * Update TwigExtension.php * Revert "Merge remote-tracking branch 'origin/develop' into develop" This reverts commit 7a59a8429064244a42ec33f5d25eea062382700c, reversing changes made to 102973d22cdaecd1e191a86128057ea28d3fa98f. * Revert "Revert "Merge remote-tracking branch 'origin/develop' into develop"" This reverts commit 50fc775c69c123fd2b10c641685657413af58359. * Attempt to resolve conflicts * param comment corrected * Update TwigExtension.php * Update TwigExtension.php * Update TwigExtension.php * Update TwigExtension.php * add isajaxrequest Check HTTP_X_REQUESTED_WITH header. Non critical use only. Handy for streamlining ajax presentation. * remove ishuman * remove Browser class --- system/src/Grav/Common/Twig/TwigExtension.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/system/src/Grav/Common/Twig/TwigExtension.php b/system/src/Grav/Common/Twig/TwigExtension.php index e12fa9a4c..eff3e53fd 100644 --- a/system/src/Grav/Common/Twig/TwigExtension.php +++ b/system/src/Grav/Common/Twig/TwigExtension.php @@ -119,6 +119,7 @@ class TwigExtension extends \Twig_Extension new \Twig_SimpleFunction('get_cookie', [$this, 'getCookie']), new \Twig_SimpleFunction('redirect_me', [$this, 'redirectFunc']), new \Twig_SimpleFunction('range', [$this, 'rangeFunc']), + new \Twig_SimpleFunction('isajaxrequest', [$this, 'isAjaxFunc']), ]; } @@ -892,4 +893,17 @@ class TwigExtension extends \Twig_Extension { return range($start, $end, $step); } + + /** + * Check if HTTP_X_REQUESTED_WITH has been set to xmlhttprequest, + * in which case we may unsafely assume ajax. Non critical use only. + * + * @return true if HTTP_X_REQUESTED_WITH exists and has been set to xmlhttprequest + */ + public function isAjaxFunc() + { + return ( + !empty($_SERVER['HTTP_X_REQUESTED_WITH']) + && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'); + } } From 4365662304ac5c5b8c90fe1fd9fc92ae2f0bf99a Mon Sep 17 00:00:00 2001 From: Flavio Copes Date: Tue, 4 Apr 2017 16:54:48 +0200 Subject: [PATCH 39/51] Add query string in lighttpd default config (#1393) --- webserver-configs/lighttpd.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webserver-configs/lighttpd.conf b/webserver-configs/lighttpd.conf index df77c6902..fd3ca9a54 100644 --- a/webserver-configs/lighttpd.conf +++ b/webserver-configs/lighttpd.conf @@ -23,7 +23,7 @@ $HTTP["querystring"] =~ "_REQUEST(=|\[|\%[0-9A-Z])" { #REROUTING TO THE INDEX PAGE url.rewrite-if-not-file = ( - "^/grav_path/(.*)$" => "/grav_path/index.php" + "^/grav_path/(.*)$" => "/grav_path/index.php$1" ) #IMPROVING SECURITY From f510e136c8424e4ac36b5a5e9d1a0b513f6566c9 Mon Sep 17 00:00:00 2001 From: OliverO2 Date: Tue, 4 Apr 2017 19:25:39 +0200 Subject: [PATCH 40/51] Add {'loading': 'inline'} option for Js and CSS assets (#1377) * Assets.php: Extract common functionaly of addCss() and addJs() into addTo(), make css() and js() honor $attributes['loading'], make pipelineCss() and pipelineJs() return generated content instead of URL depending on new option $returnURL. * AssetsTest.php: Accept new 'loading' option for CSS, add tests for adding and pipelining local and remote assets with inline loading. --- system/src/Grav/Common/Assets.php | 216 ++++++++++++++++---------- tests/unit/Grav/Common/AssetsTest.php | 39 +++++ 2 files changed, 170 insertions(+), 85 deletions(-) diff --git a/system/src/Grav/Common/Assets.php b/system/src/Grav/Common/Assets.php index 20b1fce26..12efc1ae3 100644 --- a/system/src/Grav/Common/Assets.php +++ b/system/src/Grav/Common/Assets.php @@ -255,28 +255,32 @@ class Assets } /** - * Add a CSS asset. + * Add an asset to its assembly. * * It checks for duplicates. * You may add more than one asset passing an array as argument. + * The third argument may alternatively contain an array of options which take precedence over positional + * arguments. * - * @param mixed $asset - * @param int $priority the priority, bigger comes first - * @param bool $pipeline false if this should not be pipelined - * @param null $group + * @param array $assembly the array assembling the assets + * @param mixed $asset + * @param int $priority the priority, bigger comes first + * @param bool $pipeline false if this should not be pipelined + * @param string $loading how the asset is loaded (async/defer/inline, for CSS: only inline) + * @param string $group name of the group * * @return $this */ - public function addCss($asset, $priority = null, $pipeline = true, $group = null) + public function addTo(&$assembly, $asset, $priority = null, $pipeline = true, $loading = null, $group = null) { if (is_array($asset)) { foreach ($asset as $a) { - $this->addCss($a, $priority, $pipeline, $group); + $this->addTo($assembly, $a, $priority, $pipeline, $loading, $group); } return $this; } elseif (isset($this->collections[$asset])) { - $this->addCss($this->collections[$asset], $priority, $pipeline, $group); + $this->addTo($assembly, $this->collections[$asset], $priority, $pipeline, $loading, $group); return $this; } @@ -297,15 +301,16 @@ class Assets 'asset' => $asset, 'remote' => $remote, 'priority' => intval($priority ?: 10), - 'order' => count($this->css), + 'order' => count($assembly), 'pipeline' => (bool) $pipeline, + 'loading' => $loading ?: '', 'group' => $group ?: 'head', 'modified' => $modified ]; // check for dynamic array and merge with defaults - if (func_num_args() > 1) { - $dynamic_arg = func_get_arg(1); + if (func_num_args() > 2) { + $dynamic_arg = func_get_arg(2); if (is_array($dynamic_arg)) { $data = array_merge($data, $dynamic_arg); } @@ -313,17 +318,40 @@ class Assets $key = md5($asset); if ($asset) { - $this->css[$key] = $data; + $assembly[$key] = $data; } return $this; } + /** + * Add a CSS asset. + * + * It checks for duplicates. + * You may add more than one asset passing an array as argument. + * The second argument may alternatively contain an array of options which take precedence over positional + * arguments. + * + * @param mixed $asset + * @param int $priority the priority, bigger comes first + * @param bool $pipeline false if this should not be pipelined + * @param string $group + * @param string $loading how the asset is loaded (async/defer/inline, for CSS: only inline) + * + * @return $this + */ + public function addCss($asset, $priority = null, $pipeline = true, $group = null, $loading = null) + { + return $this->addTo($this->css, $asset, $priority, $pipeline, $loading, $group); + } + /** * Add a JavaScript asset. * * It checks for duplicates. * You may add more than one asset passing an array as argument. + * The second argument may alternatively contain an array of options which take precedence over positional + * arguments. * * @param mixed $asset * @param int $priority the priority, bigger comes first @@ -335,55 +363,7 @@ class Assets */ public function addJs($asset, $priority = null, $pipeline = true, $loading = null, $group = null) { - if (is_array($asset)) { - foreach ($asset as $a) { - $this->addJs($a, $priority, $pipeline, $loading, $group); - } - - return $this; - } elseif (isset($this->collections[$asset])) { - $this->addJs($this->collections[$asset], $priority, $pipeline, $loading, $group); - - return $this; - } - - $modified = false; - $remote = $this->isRemoteLink($asset); - if (!$remote) { - $modified = $this->getLastModificationTime($asset); - $asset = $this->buildLocalLink($asset); - } - - // Check for existence - if ($asset === false) { - return $this; - } - - $data = [ - 'asset' => $asset, - 'remote' => $remote , - 'priority' => intval($priority ?: 10), - 'order' => count($this->js), - 'pipeline' => (bool) $pipeline, - 'loading' => $loading ?: '', - 'group' => $group ?: 'head', - 'modified' => $modified - ]; - - // check for dynamic array and merge with defaults - if (func_num_args() > 1) { - $dynamic_arg = func_get_arg(1); - if (is_array($dynamic_arg)) { - $data = array_merge($data, $dynamic_arg); - } - } - - $key = md5($asset); - if ($asset) { - $this->js[$key] = $data; - } - - return $this; + return $this->addTo($this->js, $asset, $priority, $pipeline, $loading, $group); } /** @@ -547,32 +527,54 @@ class Assets $this->css = array_reverse($this->css); $this->inline_css = array_reverse($this->inline_css); + $inlineGroup = array_key_exists('loading', $attributes) && $attributes['loading'] === 'inline'; + $attributes = $this->attributes(array_merge(['type' => 'text/css', 'rel' => 'stylesheet'], $attributes)); $output = ''; $inline_css = ''; if ($this->css_pipeline) { - $pipeline_result = $this->pipelineCss($group); - $pipeline_html = '' . "\n"; + $pipeline_result = $this->pipelineCss($group, !$inlineGroup); + $pipeline_html = ($inlineGroup ? '' : '' . "\n"); if ($this->css_pipeline_before_excludes && $pipeline_result) { - $output .= $pipeline_html; + if ($inlineGroup) { + $inline_css .= $pipeline_result; + } + else { + $output .= $pipeline_html; + } } foreach ($this->css_no_pipeline as $file) { if ($group && $file['group'] == $group) { - $media = isset($file['media']) ? sprintf(' media="%s"', $file['media']) : ''; - $output .= '' . "\n"; + if ($file['loading'] === 'inline') { + $inline_css .= $this->gatherLinks([$file], CSS_ASSET) . "\n"; + } + else { + $media = isset($file['media']) ? sprintf(' media="%s"', $file['media']) : ''; + $output .= '' . "\n"; + } } } if (!$this->css_pipeline_before_excludes && $pipeline_result) { - $output .= $pipeline_html; + if ($inlineGroup) { + $inline_css .= $pipeline_result; + } + else { + $output .= $pipeline_html; + } } } else { foreach ($this->css as $file) { if ($group && $file['group'] == $group) { - $media = isset($file['media']) ? sprintf(' media="%s"', $file['media']) : ''; - $output .= '' . "\n"; + if ($inlineGroup || $file['loading'] === 'inline') { + $inline_css .= $this->gatherLinks([$file], CSS_ASSET) . "\n"; + } + else { + $media = isset($file['media']) ? sprintf(' media="%s"', $file['media']) : ''; + $output .= '' . "\n"; + } } } } @@ -626,30 +628,52 @@ class Assets $this->js = array_reverse($this->js); $this->inline_js = array_reverse($this->inline_js); + $inlineGroup = array_key_exists('loading', $attributes) && $attributes['loading'] === 'inline'; + $attributes = $this->attributes(array_merge(['type' => 'text/javascript'], $attributes)); $output = ''; $inline_js = ''; if ($this->js_pipeline) { - $pipeline_result = $this->pipelineJs($group); - $pipeline_html = '' . "\n"; + $pipeline_result = $this->pipelineJs($group, !$inlineGroup); + $pipeline_html = ($inlineGroup ? '' : '' . "\n"); if ($this->js_pipeline_before_excludes && $pipeline_result) { - $output .= $pipeline_html; + if ($inlineGroup) { + $inline_js .= $pipeline_result; + } + else { + $output .= $pipeline_html; + } } foreach ($this->js_no_pipeline as $file) { if ($group && $file['group'] == $group) { - $output .= '' . "\n"; + if ($file['loading'] === 'inline') { + $inline_js .= $this->gatherLinks([$file], JS_ASSET) . "\n"; + } + else { + $output .= '' . "\n"; + } } } if (!$this->js_pipeline_before_excludes && $pipeline_result) { - $output .= $pipeline_html; + if ($inlineGroup) { + $inline_js .= $pipeline_result; + } + else { + $output .= $pipeline_html; + } } } else { foreach ($this->js as $file) { if ($group && $file['group'] == $group) { - $output .= '' . "\n"; + if ($inlineGroup || $file['loading'] === 'inline') { + $inline_js .= $this->gatherLinks([$file], JS_ASSET) . "\n"; + } + else { + $output .= '' . "\n"; + } } } } @@ -672,10 +696,11 @@ class Assets * Minify and concatenate CSS * * @param string $group + * @param bool $returnURL true if pipeline should return the URL, otherwise the content * - * @return bool|string + * @return bool|string URL or generated content if available, else false */ - protected function pipelineCss($group = 'head') + protected function pipelineCss($group = 'head', $returnURL = true) { // temporary list of assets to pipeline $temp_css = []; @@ -695,9 +720,14 @@ class Assets $this->css_no_pipeline = json_decode(file_get_contents($this->assets_dir . $inline_file), true); } - // If pipeline exist return it + // If pipeline exist return its URL or content if (file_exists($this->assets_dir . $file)) { - return $relative_path . $this->getTimestamp(); + if ($returnURL) { + return $relative_path . $this->getTimestamp(); + } + else { + return file_get_contents($this->assets_dir . $file) . "\n"; + } } // Remove any non-pipeline files @@ -744,7 +774,12 @@ class Assets if (strlen(trim($buffer)) > 0) { file_put_contents($this->assets_dir . $file, $buffer); - return $relative_path . $this->getTimestamp(); + if ($returnURL) { + return $relative_path . $this->getTimestamp(); + } + else { + return $buffer . "\n"; + } } else { return false; } @@ -754,10 +789,11 @@ class Assets * Minify and concatenate JS files. * * @param string $group + * @param bool $returnURL true if pipeline should return the URL, otherwise the content * - * @return string + * @return bool|string URL or generated content if available, else false */ - protected function pipelineJs($group = 'head') + protected function pipelineJs($group = 'head', $returnURL = true) { // temporary list of assets to pipeline $temp_js = []; @@ -777,9 +813,14 @@ class Assets $this->js_no_pipeline = json_decode(file_get_contents($this->assets_dir . $inline_file), true); } - // If pipeline exist return it + // If pipeline exist return its URL or content if (file_exists($this->assets_dir . $file)) { - return $relative_path . $this->getTimestamp(); + if ($returnURL) { + return $relative_path . $this->getTimestamp(); + } + else { + return file_get_contents($this->assets_dir . $file) . "\n"; + } } // Remove any non-pipeline files @@ -816,7 +857,12 @@ class Assets if (strlen(trim($buffer)) > 0) { file_put_contents($this->assets_dir . $file, $buffer); - return $relative_path . $this->getTimestamp(); + if ($returnURL) { + return $relative_path . $this->getTimestamp(); + } + else { + return $buffer . "\n"; + } } else { return false; } diff --git a/tests/unit/Grav/Common/AssetsTest.php b/tests/unit/Grav/Common/AssetsTest.php index e02593cf9..e4b055cc6 100644 --- a/tests/unit/Grav/Common/AssetsTest.php +++ b/tests/unit/Grav/Common/AssetsTest.php @@ -41,6 +41,7 @@ class AssetsTest extends \Codeception\TestCase\Test 'priority' => 10, 'order' => 0, 'pipeline' => true, + 'loading' => '', 'group' => 'head', 'modified' => false ], reset($array)); @@ -56,6 +57,7 @@ class AssetsTest extends \Codeception\TestCase\Test 'priority' => 10, 'order' => 0, 'pipeline' => true, + 'loading' => '', 'group' => 'head', 'modified' => false ], reset($array)); @@ -73,6 +75,7 @@ class AssetsTest extends \Codeception\TestCase\Test 'priority' => 10, 'order' => 0, 'pipeline' => true, + 'loading' => '', 'group' => 'head', 'modified' => false ], reset($array)); @@ -90,6 +93,7 @@ class AssetsTest extends \Codeception\TestCase\Test 'priority' => 10, 'order' => 0, 'pipeline' => true, + 'loading' => '', 'group' => 'head', 'modified' => false ], reset($array)); @@ -133,6 +137,7 @@ class AssetsTest extends \Codeception\TestCase\Test 'priority' => 10, 'order' => 0, 'pipeline' => true, + 'loading' => '', 'group' => 'footer', 'modified' => false ], reset($array)); @@ -192,6 +197,22 @@ class AssetsTest extends \Codeception\TestCase\Test 'modified' => false ], reset($array)); + //Test inline + $this->assets->reset(); + $this->assets->addJs('/system/assets/jquery/jquery-2.x.min.js', null, true, 'inline', null); + $js = $this->assets->js(); + $this->assertContains('jQuery Foundation', $js); + + $this->assets->reset(); + $this->assets->addCss('/system/assets/debugger.css', null, true, null, 'inline'); + $css = $this->assets->css(); + $this->assertContains('div.phpdebugbar', $css); + + $this->assets->reset(); + $this->assets->addCss('https://fonts.googleapis.com/css?family=Roboto', null, true, null, 'inline'); + $css = $this->assets->css(); + $this->assertContains('font-family: \'Roboto\';', $css); + //Test adding media queries $this->assets->reset(); $this->assets->add('test.css', ['media' => 'only screen and (min-width: 640px)']); @@ -336,6 +357,24 @@ class AssetsTest extends \Codeception\TestCase\Test $this->assertContains($this->assets->getTimestamp(), $css); } + public function testInlinePipeline() + { + $this->assets->reset(); + + //File not existing. Pipeline searches for that file without reaching it. Output is empty. + $this->assets->add('test.css', null, true); + $this->assets->setCssPipeline(true); + $css = $this->assets->css('head', ['loading' => 'inline']); + $this->assertSame('', $css); + + //Add a core Grav CSS file, which is found. Pipeline will now return its content. + $this->assets->addCss('https://fonts.googleapis.com/css?family=Roboto', null, true); + $this->assets->add('/system/assets/debugger.css', null, true); + $css = $this->assets->css('head', ['loading' => 'inline']); + $this->assertContains('font-family:\'Roboto\';', $css); + $this->assertContains('div.phpdebugbar', $css); + } + public function testAddAsyncJs() { $this->assets->reset(); From 8dc2ced94ce09ffe9cf6f36fdb3c769e3cab799a Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Tue, 4 Apr 2017 13:24:10 -0600 Subject: [PATCH 41/51] Fix for direct-install of plugins with `languages.yaml` #1396 --- system/src/Grav/Common/GPM/GPM.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/system/src/Grav/Common/GPM/GPM.php b/system/src/Grav/Common/GPM/GPM.php index 584adbdd7..99ce448ee 100644 --- a/system/src/Grav/Common/GPM/GPM.php +++ b/system/src/Grav/Common/GPM/GPM.php @@ -599,9 +599,11 @@ class GPM extends Iterator */ public static function getPackageName($source) { + $ignore_yaml_files = ['blueprints', 'languages']; + foreach (glob($source . "*.yaml") as $filename) { $name = strtolower(basename($filename, '.yaml')); - if ($name == 'blueprints') { + if (in_array($name, $ignore_yaml_files)) { continue; } return $name; From bfb6b6d68a2cb5c32ed2a6f267c21b3bb0485eef Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Tue, 4 Apr 2017 13:31:32 -0600 Subject: [PATCH 42/51] Updated changelog --- CHANGELOG.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cc79d16f2..631e7f551 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,15 @@ # v1.2.1 ## xx/xx/2017 +1. [](#improved) + * Added `isajaxrequest()` Twig function [#1400](https://github.com/getgrav/grav/issues/1400) + * Added ability to inline CSS and JS code via Asset manager [#1377](https://github.com/getgrav/grav/pull/1377) + * Add query string in lighttpd default config [#1393](https://github.com/getgrav/grav/issues/1393) + * Add `--all-yes` and `--destination` options for `bin/gpm direct-install` [#1397](https://github.com/getgrav/grav/pull/1397) 1. [](#bugfix) + * Fix for direct-install of plugins with `languages.yaml` [#1396](https://github.com/getgrav/grav/issues/1396) + * When determining language from HTTP_ACCEPT_LANGUAGE, also try base language only [#1402](https://github.com/getgrav/grav/issues/1402) * Fixed a bad method signature causing warning when running tests on `GPMTest` object - * When determining language from `HTTP_ACCEPT_LANGUAGE`, also try base language only # v1.2.0 ## 03/31/2017 From 082d4e3435d93a16328a8df99da201744171feca Mon Sep 17 00:00:00 2001 From: Josh Weiss Date: Mon, 10 Apr 2017 11:00:58 -0700 Subject: [PATCH 43/51] Ancestor and Inherited functions for Page & Pages (#1362) * Ancestor and inherited functions for Page & Pages Addes both helper methods to `Grav\Common\Page` and Grav instance utility functions to `Grav\Common\Pages`. * Ancestor Page return considering field criteria * Updates according to code review issue Made changes to act on current Page object only for the Page functions Changed variable name to better reflect the intention of the passed param for the Pages class functions * Simplify duplicate code * Simplify Pages logic Simpilfied duplicate code. Also clarified variable naming for similar functions. --- system/src/Grav/Common/Page/Page.php | 68 +++++++++++++++++++++ system/src/Grav/Common/Page/Pages.php | 87 +++++++++++++++++++++++---- 2 files changed, 142 insertions(+), 13 deletions(-) diff --git a/system/src/Grav/Common/Page/Page.php b/system/src/Grav/Common/Page/Page.php index e844a75b7..48eae0c52 100644 --- a/system/src/Grav/Common/Page/Page.php +++ b/system/src/Grav/Common/Page/Page.php @@ -2282,6 +2282,74 @@ class Page } } + /** + * Helper method to return an ancestor page. + * + * @param string $url The url of the page + * @param bool $lookup Name of the parent folder + * + * @return \Grav\Common\Page\Page page you were looking for if it exists + */ + public function ancestor($lookup = null) + { + /** @var Pages $pages */ + $pages = Grav::instance()['pages']; + + return $pages->ancestor($this->route, $lookup); + } + + /** + * Helper method to return an ancestor page to inherit from. The current + * page object is returned. + * + * @param string $field Name of the parent folder + * + * @return Page + */ + public function inherited($field) + { + list($inherited, $currentParams) = $this->getInheritedParams($field); + + $this->modifyHeader($field, $currentParams); + + return $inherited; + } + /** + * Helper method to return an ancestor field only to inherit from. The + * first occurrence of an ancestor field will be returned if at all. + * + * @param string $field Name of the parent folder + * + * @return array + */ + public function inheritedField($field) + { + list($inherited, $currentParams) = $this->getInheritedParams($field); + + return $currentParams; + } + + /** + * Method that contains shared logic for inherited() and inheritedField() + * + * @param string $field Name of the parent folder + * + * @return array + */ + protected function getInheritedParams($field) + { + $pages = Grav::instance()['pages']; + + /** @var Pages $pages */ + $inherited = $pages->inherited($this->route, $field); + $inheritedParams = (array) $inherited->value('header.' . $field); + $currentParams = (array) $this->value('header.' . $field); + if($inheritedParams && is_array($inheritedParams)) { + $currentParams = array_replace_recursive($inheritedParams, $currentParams); + } + return [$inherited, $currentParams]; + } + /** * Helper method to return a page. * diff --git a/system/src/Grav/Common/Page/Pages.php b/system/src/Grav/Common/Page/Pages.php index 4e8614aec..9d5fd0ec1 100644 --- a/system/src/Grav/Common/Page/Pages.php +++ b/system/src/Grav/Common/Page/Pages.php @@ -291,37 +291,82 @@ class Pages return new Collection($children, [], $this); } + /** + * Get a page ancestor. + * + * @param string $route The relative URL of the page + * @param string $path The relative path of the ancestor folder + * + * @return Page|null + */ + public function ancestor($route, $path = null) + { + if (!is_null($path)) { + + $page = $this->getPage($route); + + if ($page->path() == $path) { + return $page; + } elseif (!$page->parent()->root()) { + return $this->ancestor($page->parent()->route(), $path); + } + } + + return null; + } + + /** + * Get a page ancestor trait. + * + * @param string $route The relative route of the page + * @param string $field The field name of the ancestor to query for + * + * @return Page|null + */ + public function inherited($route, $field = null) + { + if (!is_null($field)) { + + $page = $this->getPage($route); + + $ancestorField = $page->parent()->value('header.' . $field); + + if ($ancestorField != null) { + return $page->parent(); + } elseif (!$page->parent()->root()) { + return $this->inherited($page->parent()->route(), $field); + } + } + + return null; + } + /** * alias method to return find a page. * - * @param string $url The relative URL of the page + * @param string $route The relative URL of the page * @param bool $all * * @return Page|null */ - public function find($url, $all = false) + public function find($route, $all = false) { - return $this->dispatch($url, $all, false); + return $this->dispatch($route, $all, false); } /** * Dispatch URI to a page. * - * @param string $url The relative URL of the page + * @param string $route The relative URL of the page * @param bool $all * * @param bool $redirect * @return Page|null * @throws \Exception */ - public function dispatch($url, $all = false, $redirect = true) + public function dispatch($route, $all = false, $redirect = true) { - // Fetch page if there's a defined route to it. - $page = isset($this->routes[$url]) ? $this->get($this->routes[$url]) : null; - // Try without trailing slash - if (!$page && Utils::endsWith($url, '/')) { - $page = isset($this->routes[rtrim($url, '/')]) ? $this->get($this->routes[rtrim($url, '/')]) : null; - } + $page = $this->getPage($route); // Are we in the admin? this is important! $not_admin = !isset($this->grav['admin']); @@ -340,13 +385,13 @@ class Pages $config = $this->grav['config']; // See if route matches one in the site configuration - $route = $config->get("site.routes.{$url}"); + $route = $config->get("site.routes.{$route}"); if ($route) { $page = $this->dispatch($route, $all); } else { // Try Regex style redirects $uri = $this->grav['uri']; - $source_url = $url; + $source_url = $route; $extension = $uri->extension(); if (isset($extension) && !Utils::endsWith($uri->url(), $extension)) { $source_url.= '.' . $extension; @@ -389,6 +434,22 @@ class Pages return $page; } + /** + * Retrieve page instance based on the route + * + * @return Page + */ + protected function getPage($route) { + // Fetch page if there's a defined route to it. + $page = isset($this->routes[$route]) ? $this->get($this->routes[$route]) : null; + // Try without trailing slash + if (!$page && Utils::endsWith($route, '/')) { + $page = isset($this->routes[rtrim($route, '/')]) ? $this->get($this->routes[rtrim($route, '/')]) : null; + } + + return $page; + } + /** * Get root page. * From b85e595bbbedbd019657b08215d69875964d899c Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Mon, 10 Apr 2017 12:10:55 -0600 Subject: [PATCH 44/51] Little cleanup --- CHANGELOG.md | 1 + system/src/Grav/Common/Page/Pages.php | 27 ++++++++------------------- 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 631e7f551..82cde6e37 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## xx/xx/2017 1. [](#improved) + * Added various `ancestor` helper methods in Page and Pages classes [#1362](https://github.com/getgrav/grav/pull/1362) * Added `isajaxrequest()` Twig function [#1400](https://github.com/getgrav/grav/issues/1400) * Added ability to inline CSS and JS code via Asset manager [#1377](https://github.com/getgrav/grav/pull/1377) * Add query string in lighttpd default config [#1393](https://github.com/getgrav/grav/issues/1393) diff --git a/system/src/Grav/Common/Page/Pages.php b/system/src/Grav/Common/Page/Pages.php index 9d5fd0ec1..c7ca2dd7a 100644 --- a/system/src/Grav/Common/Page/Pages.php +++ b/system/src/Grav/Common/Page/Pages.php @@ -303,7 +303,7 @@ class Pages { if (!is_null($path)) { - $page = $this->getPage($route); + $page = $this->dispatch($route, true); if ($page->path() == $path) { return $page; @@ -327,7 +327,7 @@ class Pages { if (!is_null($field)) { - $page = $this->getPage($route); + $page = $this->dispatch($route, true); $ancestorField = $page->parent()->value('header.' . $field); @@ -366,7 +366,12 @@ class Pages */ public function dispatch($route, $all = false, $redirect = true) { - $page = $this->getPage($route); + // Fetch page if there's a defined route to it. + $page = isset($this->routes[$route]) ? $this->get($this->routes[$route]) : null; + // Try without trailing slash + if (!$page && Utils::endsWith($route, '/')) { + $page = isset($this->routes[rtrim($route, '/')]) ? $this->get($this->routes[rtrim($route, '/')]) : null; + } // Are we in the admin? this is important! $not_admin = !isset($this->grav['admin']); @@ -434,22 +439,6 @@ class Pages return $page; } - /** - * Retrieve page instance based on the route - * - * @return Page - */ - protected function getPage($route) { - // Fetch page if there's a defined route to it. - $page = isset($this->routes[$route]) ? $this->get($this->routes[$route]) : null; - // Try without trailing slash - if (!$page && Utils::endsWith($route, '/')) { - $page = isset($this->routes[rtrim($route, '/')]) ? $this->get($this->routes[rtrim($route, '/')]) : null; - } - - return $page; - } - /** * Get root page. * From 840a349ace29c49bd1de3de1f26dc27abd1bc9a4 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Mon, 10 Apr 2017 15:18:10 -0600 Subject: [PATCH 45/51] Updated changelog --- CHANGELOG.md | 4 + system/blueprints/pages/default.yaml | 6 +- system/blueprints/pages/modular_new.yaml | 54 ------------ system/blueprints/pages/modular_raw.yaml | 106 ----------------------- system/blueprints/pages/move.yaml | 11 --- system/blueprints/pages/new.yaml | 66 -------------- system/blueprints/pages/new_folder.yaml | 35 -------- system/blueprints/pages/raw.yaml | 105 ---------------------- 8 files changed, 5 insertions(+), 382 deletions(-) delete mode 100644 system/blueprints/pages/modular_new.yaml delete mode 100644 system/blueprints/pages/modular_raw.yaml delete mode 100644 system/blueprints/pages/move.yaml delete mode 100644 system/blueprints/pages/new.yaml delete mode 100644 system/blueprints/pages/new_folder.yaml delete mode 100644 system/blueprints/pages/raw.yaml diff --git a/CHANGELOG.md b/CHANGELOG.md index 82cde6e37..3b8c04de9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,11 @@ ## xx/xx/2017 1. [](#improved) +<<<<<<< Updated upstream * Added various `ancestor` helper methods in Page and Pages classes [#1362](https://github.com/getgrav/grav/pull/1362) +======= + * Added new 'parents' field and switched Page blueprints to use this +>>>>>>> Stashed changes * Added `isajaxrequest()` Twig function [#1400](https://github.com/getgrav/grav/issues/1400) * Added ability to inline CSS and JS code via Asset manager [#1377](https://github.com/getgrav/grav/pull/1377) * Add query string in lighttpd default config [#1393](https://github.com/getgrav/grav/issues/1393) diff --git a/system/blueprints/pages/default.yaml b/system/blueprints/pages/default.yaml index 0806ba24f..929a067c3 100644 --- a/system/blueprints/pages/default.yaml +++ b/system/blueprints/pages/default.yaml @@ -124,13 +124,9 @@ form: rule: slug route: - type: select + type: parents label: PLUGIN_ADMIN.PARENT classes: fancy - data-options@: '\Grav\Common\Page\Pages::parentsRawRoutes' - data-default@: '\Grav\Plugin\Admin\Admin::rawRoute' - options: - '/': PLUGIN_ADMIN.DEFAULT_OPTION_ROOT name: type: select diff --git a/system/blueprints/pages/modular_new.yaml b/system/blueprints/pages/modular_new.yaml deleted file mode 100644 index 966b5cbd4..000000000 --- a/system/blueprints/pages/modular_new.yaml +++ /dev/null @@ -1,54 +0,0 @@ -rules: - slug: - pattern: '[a-zA-Zа-яA-Я0-9_\-]+' - min: 1 - max: 200 - -form: - validation: loose - fields: - - section: - type: section - title: PLUGIN_ADMIN.ADD_MODULAR_CONTENT - - title: - type: text - label: PLUGIN_ADMIN.PAGE_TITLE - validate: - required: true - - folder: - type: text - label: PLUGIN_ADMIN.FOLDER_NAME - validate: - rule: slug - required: true - - route: - type: select - label: PLUGIN_ADMIN.PAGE - classes: fancy - data-options@: '\Grav\Common\Page\Pages::parentsRawRoutes' - data-default@: '\Grav\Plugin\Admin\Admin::rawRoute' - validate: - required: true - - name: - type: select - classes: fancy - label: PLUGIN_ADMIN.MODULAR_TEMPLATE - help: PLUGIN_ADMIN.PAGE_FILE_HELP - default: default - data-options@: '\Grav\Common\Page\Pages::modularTypes' - validate: - required: true - - modular: - type: hidden - default: 1 - validate: - type: bool - - blueprint: - type: blueprint diff --git a/system/blueprints/pages/modular_raw.yaml b/system/blueprints/pages/modular_raw.yaml deleted file mode 100644 index 110866677..000000000 --- a/system/blueprints/pages/modular_raw.yaml +++ /dev/null @@ -1,106 +0,0 @@ -rules: - slug: - pattern: '[a-zA-Zа-яA-Я0-9_\-]+' - min: 1 - max: 200 - -form: - validation: loose - fields: - - tabs: - type: tabs - active: 1 - - fields: - content: - type: tab - title: PLUGIN_ADMIN.CONTENT - - fields: - frontmatter: - classes: frontmatter - type: editor - label: PLUGIN_ADMIN.FRONTMATTER - autofocus: true - codemirror: - mode: 'yaml' - indentUnit: 4 - autofocus: true - indentWithTabs: false - lineNumbers: true - styleActiveLine: true - gutters: ['CodeMirror-lint-markers'] - lint: true - - content: - type: markdown - - uploads: - type: pagemedia - label: PLUGIN_ADMIN.PAGE_MEDIA - - - options: - type: tab - title: PLUGIN_ADMIN.OPTIONS - - fields: - - columns: - type: columns - - fields: - column1: - type: column - - fields: - - ordering: - type: toggle - label: PLUGIN_ADMIN.FOLDER_NUMERIC_PREFIX - help: PLUGIN_ADMIN.FOLDER_NUMERIC_PREFIX_HELP - highlight: 1 - options: - 1: PLUGIN_ADMIN.ENABLED - 0: PLUGIN_ADMIN.DISABLED - validate: - type: bool - - folder: - type: text - label: PLUGIN_ADMIN.FILENAME - validate: - rule: slug - required: true - - route: - type: select - label: PLUGIN_ADMIN.PARENT - classes: fancy - data-options@: '\Grav\Common\Page\Pages::parentsRawRoutes' - data-default@: '\Grav\Plugin\Admin\Admin::rawRoute' - options: - '': PLUGIN_ADMIN.DEFAULT_OPTION_SELECT - validate: - required: true - - name: - type: select - classes: fancy - label: PLUGIN_ADMIN.MODULAR_TEMPLATE - default: default - data-options@: '\Grav\Common\Page\Pages::modularTypes' - validate: - required: true - - column2: - type: column - - fields: - order: - type: order - label: PLUGIN_ADMIN.ORDERING - - blueprint: - type: blueprint diff --git a/system/blueprints/pages/move.yaml b/system/blueprints/pages/move.yaml deleted file mode 100644 index 3f9eda1f7..000000000 --- a/system/blueprints/pages/move.yaml +++ /dev/null @@ -1,11 +0,0 @@ -form: - validation: loose - fields: - route: - type: select - label: PLUGIN_ADMIN.PARENT - classes: fancy - data-options@: '\Grav\Common\Page\Pages::parentsRawRoutes' - data-default@: '\Grav\Plugin\Admin\Admin::rawRoute' - options: - '/': PLUGIN_ADMIN.DEFAULT_OPTION_ROOT diff --git a/system/blueprints/pages/new.yaml b/system/blueprints/pages/new.yaml deleted file mode 100644 index 78c7cecb6..000000000 --- a/system/blueprints/pages/new.yaml +++ /dev/null @@ -1,66 +0,0 @@ -rules: - slug: - pattern: '[a-zA-Zа-яA-Я0-9_\-]+' - min: 1 - max: 200 - -form: - validation: loose - fields: - - section: - type: section - title: PLUGIN_ADMIN.ADD_PAGE - - title: - type: text - label: PLUGIN_ADMIN.PAGE_TITLE - help: PLUGIN_ADMIN.PAGE_TITLE_HELP - validate: - required: true - - folder: - type: text - label: PLUGIN_ADMIN.FOLDER_NAME - help: PLUGIN_ADMIN.FOLDER_NAME_HELP - validate: - rule: slug - required: true - - route: - type: select - label: PLUGIN_ADMIN.PARENT_PAGE - classes: fancy - data-options@: '\Grav\Common\Page\Pages::parentsRawRoutes' - data-default@: '\Grav\Plugin\Admin\Admin::getLastPageRoute' - options: - '/': PLUGIN_ADMIN.DEFAULT_OPTION_ROOT - validate: - required: true - - name: - type: select - classes: fancy - label: PLUGIN_ADMIN.PAGE_FILE - help: PLUGIN_ADMIN.PAGE_FILE_HELP - data-options@: '\Grav\Common\Page\Pages::types' - data-default@: '\Grav\Plugin\Admin\Admin::getLastPageName' - validate: - required: true - - visible: - type: toggle - label: PLUGIN_ADMIN.VISIBLE - help: PLUGIN_ADMIN.VISIBLE_HELP - highlight: '' - default: '' - options: - '': Auto - 1: PLUGIN_ADMIN.YES - 0: PLUGIN_ADMIN.NO - validate: - type: bool - required: true - - blueprint: - type: blueprint diff --git a/system/blueprints/pages/new_folder.yaml b/system/blueprints/pages/new_folder.yaml deleted file mode 100644 index 44d53fc8c..000000000 --- a/system/blueprints/pages/new_folder.yaml +++ /dev/null @@ -1,35 +0,0 @@ -rules: - slug: - pattern: '[a-zA-Zа-яA-Я0-9_\-]+' - min: 1 - max: 200 - -form: - validation: loose - fields: - - section: - type: section - title: PLUGIN_ADMIN.ADD_FOLDER - - folder: - type: text - label: PLUGIN_ADMIN.FOLDER_NAME - help: PLUGIN_ADMIN.FOLDER_NAME_HELP - validate: - rule: slug - required: true - - route: - type: select - label: PLUGIN_ADMIN.PARENT_PAGE - classes: fancy - data-options@: '\Grav\Common\Page\Pages::parentsRawRoutes' - data-default@: '\Grav\Plugin\Admin\Admin::getLastPageRoute' - options: - '/': PLUGIN_ADMIN.DEFAULT_OPTION_ROOT - validate: - required: true - - blueprint: - type: blueprint diff --git a/system/blueprints/pages/raw.yaml b/system/blueprints/pages/raw.yaml deleted file mode 100644 index f61cf95f6..000000000 --- a/system/blueprints/pages/raw.yaml +++ /dev/null @@ -1,105 +0,0 @@ -rules: - slug: - pattern: '[a-zA-Zа-яA-Я0-9_\-]+' - min: 1 - max: 200 - -form: - validation: loose - fields: - - tabs: - type: tabs - active: 1 - - fields: - content: - type: tab - title: PLUGIN_ADMIN.CONTENT - - fields: - frontmatter: - classes: frontmatter - type: editor - label: PLUGIN_ADMIN.FRONTMATTER - autofocus: true - codemirror: - mode: 'yaml' - indentUnit: 4 - autofocus: true - indentWithTabs: false - lineNumbers: true - styleActiveLine: true - gutters: ['CodeMirror-lint-markers'] - lint: true - - content: - type: markdown - - uploads: - type: pagemedia - label: PLUGIN_ADMIN.PAGE_MEDIA - - options: - type: tab - title: PLUGIN_ADMIN.OPTIONS - - fields: - - columns: - type: columns - - fields: - column1: - type: column - - fields: - - ordering: - type: toggle - label: PLUGIN_ADMIN.FOLDER_NUMERIC_PREFIX - help: PLUGIN_ADMIN.FOLDER_NUMERIC_PREFIX_HELP - highlight: 1 - options: - 1: PLUGIN_ADMIN.ENABLED - 0: PLUGIN_ADMIN.DISABLED - validate: - type: bool - - folder: - type: text - label: PLUGIN_ADMIN.FOLDER_NAME - help: PLUGIN_ADMIN.FOLDER_NAME_HELP - validate: - rule: slug - required: true - - route: - type: select - label: PLUGIN_ADMIN.PARENT - classes: fancy - data-options@: '\Grav\Common\Page\Pages::parentsRawRoutes' - data-default@: '\Grav\Plugin\Admin\Admin::rawRoute' - options: - '/': PLUGIN_ADMIN.DEFAULT_OPTION_ROOT - - name: - type: select - classes: fancy - label: PLUGIN_ADMIN.DISPLAY_TEMPLATE - help: PLUGIN_ADMIN.DISPLAY_TEMPLATE_HELP - default: default - data-options@: '\Grav\Common\Page\Pages::types' - validate: - required: true - - column2: - type: column - - fields: - order: - type: order - label: PLUGIN_ADMIN.ORDERING - - blueprint: - type: blueprint From 0a22ff0c687c54187cccd053923f8658b29dce68 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Mon, 10 Apr 2017 15:18:33 -0600 Subject: [PATCH 46/51] Fixed changelog --- CHANGELOG.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b8c04de9..50d3fddfd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,11 +2,8 @@ ## xx/xx/2017 1. [](#improved) -<<<<<<< Updated upstream * Added various `ancestor` helper methods in Page and Pages classes [#1362](https://github.com/getgrav/grav/pull/1362) -======= * Added new 'parents' field and switched Page blueprints to use this ->>>>>>> Stashed changes * Added `isajaxrequest()` Twig function [#1400](https://github.com/getgrav/grav/issues/1400) * Added ability to inline CSS and JS code via Asset manager [#1377](https://github.com/getgrav/grav/pull/1377) * Add query string in lighttpd default config [#1393](https://github.com/getgrav/grav/issues/1393) From be94947d38afdedfefe7c28b5535d67c0db911f2 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Mon, 10 Apr 2017 18:36:42 -0600 Subject: [PATCH 47/51] Prepare for release --- CHANGELOG.md | 4 ++-- system/defines.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 50d3fddfd..14d4f0203 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,9 @@ # v1.2.1 -## xx/xx/2017 +## 04/10/2017 1. [](#improved) * Added various `ancestor` helper methods in Page and Pages classes [#1362](https://github.com/getgrav/grav/pull/1362) - * Added new 'parents' field and switched Page blueprints to use this + * Added new `parents` field and switched Page blueprints to use this * Added `isajaxrequest()` Twig function [#1400](https://github.com/getgrav/grav/issues/1400) * Added ability to inline CSS and JS code via Asset manager [#1377](https://github.com/getgrav/grav/pull/1377) * Add query string in lighttpd default config [#1393](https://github.com/getgrav/grav/issues/1393) diff --git a/system/defines.php b/system/defines.php index 1865c871a..a22edfe33 100644 --- a/system/defines.php +++ b/system/defines.php @@ -8,7 +8,7 @@ // Some standard defines define('GRAV', true); -define('GRAV_VERSION', '1.2.0'); +define('GRAV_VERSION', '1.2.1'); define('GRAV_TESTING', false); define('DS', '/'); From 1d7f41e4a80c60f22e942cd73cb5682bae79e652 Mon Sep 17 00:00:00 2001 From: Flavio Copes Date: Tue, 11 Apr 2017 11:30:27 +0200 Subject: [PATCH 48/51] Fix #1405 issue in direct-install with github-style dependencies --- CHANGELOG.md | 6 ++++++ .../src/Grav/Console/Gpm/DirectInstallCommand.php | 13 ++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 14d4f0203..2921f8a04 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# v1.2.2 +## 04/xx/2017 + +1. [](#bugfix) + * Fix issue in direct-install with github-style dependencies [#1405](https://github.com/getgrav/grav/issues/1405) + # v1.2.1 ## 04/10/2017 diff --git a/system/src/Grav/Console/Gpm/DirectInstallCommand.php b/system/src/Grav/Console/Gpm/DirectInstallCommand.php index 46f9bcb5b..0b368cafe 100644 --- a/system/src/Grav/Console/Gpm/DirectInstallCommand.php +++ b/system/src/Grav/Console/Gpm/DirectInstallCommand.php @@ -149,16 +149,19 @@ class DirectInstallCommand extends ConsoleCommand if (isset($blueprint['dependencies'])) { $depencencies = []; foreach ($blueprint['dependencies'] as $dependency) { - if (is_array($dependency) && isset($dependency['name'])) { - $depencencies[] = $dependency['name']; + if (is_array($dependency)){ + if (isset($dependency['name'])) { + $depencencies[] = $dependency['name']; + } + if (isset($dependency['github'])) { + $depencencies[] = $dependency['github']; + } } else { - $depencencies[] = $dependency; + $depencencies[] = $dependency; } } $this->output->writeln(" |- Dependencies found... [" . implode(',', $depencencies) . "]"); - - $question = new ConfirmationQuestion(" | '- Dependencies will not be satisfied. Continue ? [y|N] ", false); $answer = $this->all_yes ? true : $helper->ask($this->input, $this->output, $question); From 60f97f27bec1a35d42b5ef6e9ef0e56673e60dc6 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Tue, 11 Apr 2017 13:32:25 -0600 Subject: [PATCH 49/51] Fix for redirects breaking #1420 --- CHANGELOG.md | 1 + system/src/Grav/Common/Page/Pages.php | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2921f8a04..20032c332 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## 04/xx/2017 1. [](#bugfix) + * Fix for redirects breaking [#1420](https://github.com/getgrav/grav/issues/1420) * Fix issue in direct-install with github-style dependencies [#1405](https://github.com/getgrav/grav/issues/1405) # v1.2.1 diff --git a/system/src/Grav/Common/Page/Pages.php b/system/src/Grav/Common/Page/Pages.php index c7ca2dd7a..ab8825538 100644 --- a/system/src/Grav/Common/Page/Pages.php +++ b/system/src/Grav/Common/Page/Pages.php @@ -390,9 +390,9 @@ class Pages $config = $this->grav['config']; // See if route matches one in the site configuration - $route = $config->get("site.routes.{$route}"); - if ($route) { - $page = $this->dispatch($route, $all); + $site_route = $config->get("site.routes.{$route}"); + if ($site_route) { + $page = $this->dispatch($site_route, $all); } else { // Try Regex style redirects $uri = $this->grav['uri']; From 0fe676c34b150f72e571b7452cdc3bc65f26a918 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Tue, 11 Apr 2017 14:21:03 -0600 Subject: [PATCH 50/51] Preparing release --- CHANGELOG.md | 2 +- system/defines.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 20032c332..0136c0a73 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ # v1.2.2 -## 04/xx/2017 +## 04/11/2017 1. [](#bugfix) * Fix for redirects breaking [#1420](https://github.com/getgrav/grav/issues/1420) diff --git a/system/defines.php b/system/defines.php index a22edfe33..fb565e9ec 100644 --- a/system/defines.php +++ b/system/defines.php @@ -8,7 +8,7 @@ // Some standard defines define('GRAV', true); -define('GRAV_VERSION', '1.2.1'); +define('GRAV_VERSION', '1.2.2'); define('GRAV_TESTING', false); define('DS', '/'); From 56e58f3b5e2ed879f00b367f05dbcd98b92633bf Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Wed, 12 Apr 2017 10:28:55 -0600 Subject: [PATCH 51/51] Return `""` if no childType set rather than `default` --- system/src/Grav/Common/Page/Page.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/src/Grav/Common/Page/Page.php b/system/src/Grav/Common/Page/Page.php index 48eae0c52..695489942 100644 --- a/system/src/Grav/Common/Page/Page.php +++ b/system/src/Grav/Common/Page/Page.php @@ -1126,7 +1126,7 @@ class Page */ public function childType() { - return isset($this->header->child_type) ? (string)$this->header->child_type : 'default'; + return isset($this->header->child_type) ? (string)$this->header->child_type : ''; } /**