From aa9b735a5017f4fbd0202029eb262c615fb88faa Mon Sep 17 00:00:00 2001 From: Flavio Copes Date: Sat, 9 Jan 2016 20:45:06 +0100 Subject: [PATCH 01/15] Return the parent routes in the `route` options. Added a Pages::parentsRawRoutes() method, uses the same internal method as Pages::parents(). Refactored Pages::getList() to accept an optional $rawRoutes bool and if set, return the raw routes --- system/blueprints/pages/default.yaml | 2 +- system/src/Grav/Common/Page/Pages.php | 40 +++++++++++++++++++++++---- 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/system/blueprints/pages/default.yaml b/system/blueprints/pages/default.yaml index d421bbd62..6eab5d464 100644 --- a/system/blueprints/pages/default.yaml +++ b/system/blueprints/pages/default.yaml @@ -139,7 +139,7 @@ form: type: select label: PLUGIN_ADMIN.PARENT classes: fancy - '@data-options': '\Grav\Common\Page\Pages::parents' + '@data-options': '\Grav\Common\Page\Pages::parentsRawRoutes' '@data-default': '\Grav\Plugin\admin::route' options: '/': PLUGIN_ADMIN.DEFAULT_OPTION_ROOT diff --git a/system/src/Grav/Common/Page/Pages.php b/system/src/Grav/Common/Page/Pages.php index 7193db791..52bfb7492 100644 --- a/system/src/Grav/Common/Page/Pages.php +++ b/system/src/Grav/Common/Page/Pages.php @@ -398,7 +398,7 @@ class Pages * @return array * @throws \RuntimeException */ - public function getList(Page $current = null, $level = 0) + public function getList(Page $current = null, $level = 0, $rawRoutes = false) { if (!$current) { if ($level) { @@ -411,11 +411,16 @@ class Pages $list = array(); if (!$current->root()) { - $list[$current->route()] = str_repeat('  ', ($level-1)*2) . $current->title(); + if ($rawRoutes) { + $route = $current->rawRoute(); + } else { + $route = $current->route(); + } + $list[$route] = str_repeat('  ', ($level-1)*2) . $current->title(); } foreach ($current->children() as $next) { - $list = array_merge($list, $this->getList($next, $level + 1)); + $list = array_merge($list, $this->getList($next, $level + 1, $rawRoutes)); } return $list; @@ -517,18 +522,42 @@ class Pages } /** - * Get available parents. + * Get available parents routes * * @return array */ public static function parents() + { + $rawRoutes = false; + return self::getParents($rawRoutes); + } + + /** + * Get available parents raw routes. + * + * @return array + */ + public static function parentsRawRoutes() + { + $rawRoutes = true; + return self::getParents($rawRoutes); + } + + /** + * Get available parents routes + * + * @param bool $rawRoutes get the raw route or the normal route + * + * @return array + */ + private static function getParents($rawRoutes) { $grav = Grav::instance(); /** @var Pages $pages */ $pages = $grav['pages']; - $parents = $pages->getList(); + $parents = $pages->getList(null, 0, $rawRoutes); /** @var Admin $admin */ $admin = $grav['admin']; @@ -544,6 +573,7 @@ class Pages } return $parents; + } /** From 182b6977bd5f7a6e3cf12785844a6e64450eb43b Mon Sep 17 00:00:00 2001 From: Flavio Copes Date: Sun, 10 Jan 2016 15:03:50 +0100 Subject: [PATCH 02/15] The date for the last update of a page that is modular is the update time of the module that was last modified --- system/src/Grav/Common/Page/Page.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/system/src/Grav/Common/Page/Page.php b/system/src/Grav/Common/Page/Page.php index 5e02559af..91747f868 100644 --- a/system/src/Grav/Common/Page/Page.php +++ b/system/src/Grav/Common/Page/Page.php @@ -1424,6 +1424,17 @@ class Page if ($var !== null) { $this->modified = $var; } + + if ($this->template == 'modular') { + foreach ($this->children() as $child) { + $modified = $child->modified(); + + if ($modified > $this->modified) { + $this->modified = $modified; + } + } + } + return $this->modified; } From be2af197c375bf1766a45d76a892d9e50ebf6ea9 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Mon, 11 Jan 2016 16:18:57 -0700 Subject: [PATCH 03/15] Allow twig_vars to be exposed earlier and merged later --- system/src/Grav/Common/Twig/Twig.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/src/Grav/Common/Twig/Twig.php b/system/src/Grav/Common/Twig/Twig.php index 0b3be023c..aa3119946 100644 --- a/system/src/Grav/Common/Twig/Twig.php +++ b/system/src/Grav/Common/Twig/Twig.php @@ -25,7 +25,7 @@ class Twig /** * @var array */ - public $twig_vars; + public $twig_vars = []; /** * @var array @@ -143,7 +143,7 @@ class Twig $this->grav->fireEvent('onTwigExtensions'); // Set some standard variables for twig - $this->twig_vars = array( + $this->twig_vars = $this->twig_vars + array( 'config' => $config, 'uri' => $this->grav['uri'], 'base_dir' => rtrim(ROOT_DIR, '/'), From 7e5b60917b0150b84d30357d4d8146316b4e5d17 Mon Sep 17 00:00:00 2001 From: Flavio Copes Date: Tue, 12 Jan 2016 11:19:20 +0100 Subject: [PATCH 04/15] Add ext-* to composer --- composer.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 1dd394581..41eb7e3ca 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,10 @@ "donatj/phpuseragentparser": "~0.3", "pimple/pimple": "~3.0", "rockettheme/toolbox": "~1.2", - "maximebf/debugbar": "~1.10" + "maximebf/debugbar": "~1.10", + "ext-mbstring": "*", + "ext-openssl": "*", + "ext-curl": "*" }, "repositories": [ { From af6e35208318a8a55114b8215c3421bf90d781d3 Mon Sep 17 00:00:00 2001 From: Matias Griese Date: Tue, 12 Jan 2016 12:53:54 +0200 Subject: [PATCH 05/15] Fix stream override ordering --- system/src/Grav/Common/Config/Setup.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/src/Grav/Common/Config/Setup.php b/system/src/Grav/Common/Config/Setup.php index b345426c1..8b6b70750 100644 --- a/system/src/Grav/Common/Config/Setup.php +++ b/system/src/Grav/Common/Config/Setup.php @@ -158,7 +158,7 @@ class Setup extends Data } // Update streams. - foreach ($files as $path) { + foreach (array_reverse($files) as $path) { $file = CompiledYamlFile::instance($path); $content = $file->content(); if (!empty($content['schemes'])) { From 479e73e9509f5dcbf98fbcb96ee01c23b43475c3 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Mon, 11 Jan 2016 18:45:07 -0700 Subject: [PATCH 06/15] Some optimizations/cleanup on CLI commands --- bin/gpm | 2 ++ bin/plugin | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/bin/gpm b/bin/gpm index 3fc5fa79c..37e183b0b 100755 --- a/bin/gpm +++ b/bin/gpm @@ -51,4 +51,6 @@ $app->addCommands(array( new \Grav\Console\Gpm\UpdateCommand(), new \Grav\Console\Gpm\SelfupgradeCommand(), )); + +$app->setDefaultCommand('index'); $app->run(); diff --git a/bin/plugin b/bin/plugin index 71fd926b9..1741ec281 100755 --- a/bin/plugin +++ b/bin/plugin @@ -107,10 +107,12 @@ try { exit; } -foreach ($commands as $command) { - require_once "plugins://{$name}/cli/{$command}"; - $command = 'Grav\Plugin\Console\\' . preg_replace('/.php$/', '', $command); - $app->add(new $command()); +foreach ($commands as $command_path) { + require_once "plugins://{$name}/cli/{$command_path}"; + + $command_class = 'Grav\Plugin\Console\\' . preg_replace('/.php$/', '', $command_path); + $command = new $command_class(); + $app->add($command); } $app->run($input); From d65ec29408a5fb775643dd3bb47cd30b36bd3e62 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Wed, 13 Jan 2016 17:42:56 -0700 Subject: [PATCH 07/15] Moved logic into page recurse where pages are already recursed and use collection() --- system/src/Grav/Common/Page/Page.php | 10 ---------- system/src/Grav/Common/Page/Pages.php | 11 +++++++++++ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/system/src/Grav/Common/Page/Page.php b/system/src/Grav/Common/Page/Page.php index 91747f868..916d99aca 100644 --- a/system/src/Grav/Common/Page/Page.php +++ b/system/src/Grav/Common/Page/Page.php @@ -1425,16 +1425,6 @@ class Page $this->modified = $var; } - if ($this->template == 'modular') { - foreach ($this->children() as $child) { - $modified = $child->modified(); - - if ($modified > $this->modified) { - $this->modified = $modified; - } - } - } - return $this->modified; } diff --git a/system/src/Grav/Common/Page/Pages.php b/system/src/Grav/Common/Page/Pages.php index 7193db791..a6368ec17 100644 --- a/system/src/Grav/Common/Page/Pages.php +++ b/system/src/Grav/Common/Page/Pages.php @@ -790,6 +790,17 @@ class Pages $page->routable(false); } + // Override the modified time if modular + if ($page->template() == 'modular') { + foreach ($page->collection() as $child) { + $modified = $child->modified(); + + if ($modified > $last_modified) { + $last_modified = $modified; + } + } + } + // Override the modified and ID so that it takes the latest change into account $page->modified($last_modified); $page->id($last_modified.md5($page->filePath())); From fc08cb8e52e5c5417dfc6cbf381a8f8181b2b0e4 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Wed, 13 Jan 2016 17:43:19 -0700 Subject: [PATCH 08/15] Updated Twig library --- composer.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/composer.lock b/composer.lock index 60dd52fa6..006287240 100644 --- a/composer.lock +++ b/composer.lock @@ -1076,16 +1076,16 @@ }, { "name": "twig/twig", - "version": "v1.23.1", + "version": "v1.23.3", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "d9b6333ae8dd2c8e3fd256e127548def0bc614c6" + "reference": "ae53fc2c312fdee63773b75cb570304f85388b08" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/d9b6333ae8dd2c8e3fd256e127548def0bc614c6", - "reference": "d9b6333ae8dd2c8e3fd256e127548def0bc614c6", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/ae53fc2c312fdee63773b75cb570304f85388b08", + "reference": "ae53fc2c312fdee63773b75cb570304f85388b08", "shasum": "" }, "require": { @@ -1133,7 +1133,7 @@ "keywords": [ "templating" ], - "time": "2015-11-05 12:49:06" + "time": "2016-01-11 14:02:19" } ], "packages-dev": [], From 5d38e60076f64bec54e0b99abc31607da9b425bc Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Thu, 14 Jan 2016 17:21:54 -0700 Subject: [PATCH 09/15] Enhanced the `bin/gpm info` CLI command with CHANGELOG support - #559 --- system/src/Grav/Console/Gpm/InfoCommand.php | 64 ++++++++++++++++++++- 1 file changed, 62 insertions(+), 2 deletions(-) diff --git a/system/src/Grav/Console/Gpm/InfoCommand.php b/system/src/Grav/Console/Gpm/InfoCommand.php index 0ff0850bb..99f8bd2e2 100644 --- a/system/src/Grav/Console/Gpm/InfoCommand.php +++ b/system/src/Grav/Console/Gpm/InfoCommand.php @@ -5,6 +5,7 @@ use Grav\Common\GPM\GPM; use Grav\Console\ConsoleCommand; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Question\ConfirmationQuestion; /** * Class InfoCommand @@ -34,6 +35,12 @@ class InfoCommand extends ConsoleCommand InputOption::VALUE_NONE, 'Force fetching the new data remotely' ) + ->addOption( + 'all-yes', + 'y', + InputOption::VALUE_NONE, + 'Assumes yes (or best approach) instead of prompting' + ) ->addArgument( 'package', InputArgument::REQUIRED, @@ -107,9 +114,62 @@ class InfoCommand extends ConsoleCommand } } + $type = rtrim($foundPackage->package_type, 's'); + $updatable = $this->gpm->{'is' . $type . 'Updatable'}($foundPackage->slug); + $installed = $this->gpm->{'is' . $type . 'Installed'}($foundPackage->slug); + + // display current version if installed and different + if ($installed && $updatable) { + $local = $this->gpm->{'getInstalled'. $type}($foundPackage->slug); + $this->output->writeln(''); + $this->output->writeln("Currently installed version: " . $local->version . ""); + $this->output->writeln(''); + } + + // display changelog information + $questionHelper = $this->getHelper('question'); + $skipPrompt = $this->input->getOption('all-yes'); + + if (!$skipPrompt) { + $question = new ConfirmationQuestion("Would you like to read the changelog? [y|N] ", + false); + $answer = $questionHelper->ask($this->input, $this->output, $question); + + if ($answer) { + $changelog = $foundPackage->changelog; + + $this->output->writeln(""); + foreach ($changelog as $version => $log) { + $title = $version . ' [' . $log['date'] . ']'; + $content = preg_replace_callback("/\d\.\s\[\]\(#(.*)\)/", function ($match) { + return "\n" . ucfirst($match[1]) . ":"; + }, $log['content']); + + $this->output->writeln(''.$title.''); + $this->output->writeln(str_repeat('-', strlen($title))); + $this->output->writeln($content); + $this->output->writeln(""); + + $question = new ConfirmationQuestion("Press [ENTER] to continue or [q] to quit ", true); + if (!$questionHelper->ask($this->input, $this->output, $question)) { + break; + } + $this->output->writeln(""); + } + } + } + + $this->output->writeln(''); - $this->output->writeln("You can install this package by typing:"); - $this->output->writeln(" " . $this->argv . " install " . $foundPackage->slug . ""); + + if ($installed && $updatable) { + $this->output->writeln("You can update this package by typing:"); + $this->output->writeln(" " . $this->argv . " update " . $foundPackage->slug . ""); + } else { + $this->output->writeln("You can install this package by typing:"); + $this->output->writeln(" " . $this->argv . " install " . $foundPackage->slug . ""); + } + $this->output->writeln(''); } From 0d33a1d4793c52ef528798e690d2b539105c3dfd Mon Sep 17 00:00:00 2001 From: v3d Date: Fri, 15 Jan 2016 12:40:58 +0100 Subject: [PATCH 10/15] Update hr.yaml Update MONTHS_OF_THE_YEAR and DAYS_OF_THE_WEEK --- system/languages/hr.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/system/languages/hr.yaml b/system/languages/hr.yaml index 3dbd80218..098b8f922 100644 --- a/system/languages/hr.yaml +++ b/system/languages/hr.yaml @@ -50,3 +50,5 @@ NICETIME: FORM: VALIDATION_FAIL: Validacija nije uspjela: INVALID_INPUT: Unos nije valjan +MONTHS_OF_THE_YEAR: ['Siječanj', 'Veljača', 'Ožujak', 'Travanj', 'Svibanj', 'Lipanj', 'Srpanj', 'Kolovoz', 'Rujan', 'Listopad', 'Studeni', 'Prosinac'] +DAYS_OF_THE_WEEK: ['ponedjeljak', 'utorak', 'srijeda', 'četvrtak', 'petak', 'subota', 'nedjelja'] From 70f8707b048a0da4a2d879e59e6a27cc81eba5e8 Mon Sep 17 00:00:00 2001 From: Flavio Copes Date: Fri, 15 Jan 2016 12:54:24 +0100 Subject: [PATCH 11/15] Blueprint for New Folder modal --- system/blueprints/pages/new_folder.yaml | 35 +++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 system/blueprints/pages/new_folder.yaml diff --git a/system/blueprints/pages/new_folder.yaml b/system/blueprints/pages/new_folder.yaml new file mode 100644 index 000000000..311d814bd --- /dev/null +++ b/system/blueprints/pages/new_folder.yaml @@ -0,0 +1,35 @@ +rules: + slug: + pattern: "[a-z][a-z0-9_\-]+" + min: 2 + max: 80 + +form: + validation: loose + fields: + + section: + type: section + title: PLUGIN_ADMIN.ADD_PAGE + + folder: + type: text + label: PLUGIN_ADMIN.FOLDER_NAME + help: PLUGIN_ADMIN.FOLDER_NAME_HELP + validate: + type: slug + required: true + + route: + type: select + label: PLUGIN_ADMIN.PARENT_PAGE + classes: fancy + '@data-options': '\Grav\Common\Page\Pages::parents' + '@data-default': '\Grav\Plugin\admin::getLastPageRoute' + options: + '/': PLUGIN_ADMIN.DEFAULT_OPTION_ROOT + validate: + required: true + + blueprint: + type: blueprint From 77d4925f3844965fae5f813f6efbb8ae18d1afa8 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Sat, 16 Jan 2016 17:54:43 -0700 Subject: [PATCH 12/15] Added shortcode square brackets to grav trait --- .../src/Grav/Common/Markdown/ParsedownGravTrait.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/system/src/Grav/Common/Markdown/ParsedownGravTrait.php b/system/src/Grav/Common/Markdown/ParsedownGravTrait.php index 57bdcd93b..6617ab5a0 100644 --- a/system/src/Grav/Common/Markdown/ParsedownGravTrait.php +++ b/system/src/Grav/Common/Markdown/ParsedownGravTrait.php @@ -34,6 +34,7 @@ trait ParsedownGravTrait $this->page = $page; $this->pages = $grav['pages']; $this->BlockTypes['{'] [] = "TwigTag"; + $this->BlockTypes['['] [] = "ShortcodeTag"; $this->base_url = rtrim(self::getGrav()['base_url'] . self::getGrav()['pages']->base(), '/'); $this->pages_dir = self::getGrav()['locator']->findResource('page://'); $this->special_chars = array('>' => 'gt', '<' => 'lt', '"' => 'quot'); @@ -145,6 +146,16 @@ trait ParsedownGravTrait } } + protected function blockShortcodeTag($Line) + { + if (preg_match('/^(?:\[)(.*)(?:\])$/', $Line['body'], $matches)) { + $Block = array( + 'markup' => $Line['body'], + ); + return $Block; + } + } + protected function inlineSpecialCharacter($Excerpt) { if ($Excerpt['text'][0] === '&' && ! preg_match('/^&#?\w+;/', $Excerpt['text'])) { From 0a76e46d8fb67b5bf3e2e3eff8a52dd638792062 Mon Sep 17 00:00:00 2001 From: Flavio Copes Date: Sun, 17 Jan 2016 20:40:45 +0100 Subject: [PATCH 13/15] Remove ircmaxell/password-compat as it's intended to provide backward compatibility for PHP 5.4 However, it will still be installed in `vendor` as required by `rockettheme/toolbox` --- composer.json | 1 - 1 file changed, 1 deletion(-) diff --git a/composer.json b/composer.json index 41eb7e3ca..d49443764 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,6 @@ "filp/whoops": "2.0.0-alpha2", "monolog/monolog": "~1.0", "gregwar/image": "~2.0", - "ircmaxell/password-compat": "1.0.*", "mrclay/minify": "~2.2", "donatj/phpuseragentparser": "~0.3", "pimple/pimple": "~3.0", From 778ae8aceddd82c3d1af0072a0e0a925da57e904 Mon Sep 17 00:00:00 2001 From: Tyler Cosgrove Date: Tue, 19 Jan 2016 14:15:12 -0500 Subject: [PATCH 14/15] Update Whoops to latest Should have line highlights. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index d49443764..7caba972d 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "symfony/var-dumper": "~2.8", "symfony/polyfill-iconv": "~1.0", "doctrine/cache": "~1.5", - "filp/whoops": "2.0.0-alpha2", + "filp/whoops": "2.0.0", "monolog/monolog": "~1.0", "gregwar/image": "~2.0", "mrclay/minify": "~2.2", From 8406802a05bd593734283fcfd1ce347bad6e5457 Mon Sep 17 00:00:00 2001 From: Tyler Cosgrove Date: Tue, 19 Jan 2016 14:46:30 -0500 Subject: [PATCH 15/15] Change to next significant release --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 7caba972d..a0b000e04 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "symfony/var-dumper": "~2.8", "symfony/polyfill-iconv": "~1.0", "doctrine/cache": "~1.5", - "filp/whoops": "2.0.0", + "filp/whoops": "~2.0", "monolog/monolog": "~1.0", "gregwar/image": "~2.0", "mrclay/minify": "~2.2",