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); diff --git a/composer.json b/composer.json index 1dd394581..a0b000e04 100644 --- a/composer.json +++ b/composer.json @@ -15,15 +15,17 @@ "symfony/var-dumper": "~2.8", "symfony/polyfill-iconv": "~1.0", "doctrine/cache": "~1.5", - "filp/whoops": "2.0.0-alpha2", + "filp/whoops": "~2.0", "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", "rockettheme/toolbox": "~1.2", - "maximebf/debugbar": "~1.10" + "maximebf/debugbar": "~1.10", + "ext-mbstring": "*", + "ext-openssl": "*", + "ext-curl": "*" }, "repositories": [ { 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": [], 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/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 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'] 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'])) { diff --git a/system/src/Grav/Common/Page/Page.php b/system/src/Grav/Common/Page/Page.php index 5e02559af..916d99aca 100644 --- a/system/src/Grav/Common/Page/Page.php +++ b/system/src/Grav/Common/Page/Page.php @@ -1424,6 +1424,7 @@ class Page if ($var !== null) { $this->modified = $var; } + return $this->modified; } diff --git a/system/src/Grav/Common/Page/Pages.php b/system/src/Grav/Common/Page/Pages.php index 7193db791..2dd1bbadf 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; + } /** @@ -790,6 +820,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())); 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, '/'), 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(''); }