Merge branches 'develop' and 'feature/plugin-early' of https://github.com/getgrav/grav into feature/plugin-early

This commit is contained in:
Matias Griese
2016-01-21 11:15:22 +02:00
12 changed files with 178 additions and 22 deletions

View File

@@ -51,4 +51,6 @@ $app->addCommands(array(
new \Grav\Console\Gpm\UpdateCommand(),
new \Grav\Console\Gpm\SelfupgradeCommand(),
));
$app->setDefaultCommand('index');
$app->run();

View File

@@ -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);

View File

@@ -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": [
{

10
composer.lock generated
View File

@@ -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": [],

View File

@@ -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

View File

@@ -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

View File

@@ -50,3 +50,5 @@ NICETIME:
FORM:
VALIDATION_FAIL: <b>Validacija nije uspjela:</b>
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']

View File

@@ -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'])) {

View File

@@ -1424,6 +1424,7 @@ class Page
if ($var !== null) {
$this->modified = $var;
}
return $this->modified;
}

View File

@@ -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('&nbsp; ', ($level-1)*2) . $current->title();
if ($rawRoutes) {
$route = $current->rawRoute();
} else {
$route = $current->route();
}
$list[$route] = str_repeat('&nbsp; ', ($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()));

View File

@@ -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, '/'),

View File

@@ -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: <magenta>" . $local->version . "</magenta>");
$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('<cyan>'.$title.'</cyan>');
$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(" <green>" . $this->argv . " install</green> <cyan>" . $foundPackage->slug . "</cyan>");
if ($installed && $updatable) {
$this->output->writeln("You can update this package by typing:");
$this->output->writeln(" <green>" . $this->argv . " update</green> <cyan>" . $foundPackage->slug . "</cyan>");
} else {
$this->output->writeln("You can install this package by typing:");
$this->output->writeln(" <green>" . $this->argv . " install</green> <cyan>" . $foundPackage->slug . "</cyan>");
}
$this->output->writeln('');
}