Merge branch 'release/1.1.10'

This commit is contained in:
Andy Miller
2016-12-21 13:06:53 -07:00
18 changed files with 87 additions and 39 deletions

View File

@@ -1,3 +1,17 @@
# v1.1.10
## 12/21/2016
1. [](#improved)
* Improve detection of home path. Also allow `~/.grav` on Windows, drop `ConsoleTrait::isWindows()` method, used only for that [#1204](https://github.com/getgrav/grav/pull/1204)
* Reworked PHP CLI router [#1219](https://github.com/getgrav/grav/pull/1219)
* More robust theme/plugin logic in `bin/gpm direct-install`
1. [](#bugfix)
* Fixed case where extracting a package would cause an error during rename
* Fix issue with using `Yaml::parse` direcly on a filename, now deprecated
* Add pattern for frontend validation of folder slugs [#891](https://github.com/getgrav/grav-plugin-admin/issues/891)
* Fix issue with Inflector when translation is disabled [https://github.com/getgrav/grav-plugin-simplesearch/issues/87](https://github.com/getgrav/grav-plugin-simplesearch/issues/87)
* Explicitly expose `array_unique` Twig filter [https://github.com/getgrav/grav-plugin-admin/issues/897](https://github.com/getgrav/grav-plugin-admin/issues/897)
# v1.1.9
## 12/13/2016

View File

@@ -14,6 +14,12 @@ if (!is_file($autoload)) {
die("Please run: <i>bin/grav install</i>");
}
if (PHP_SAPI == 'cli-server') {
if (!isset($_SERVER['PHP_CLI_ROUTER'])) {
die("PHP webserver requires a router to run Grav, please use: <pre>php -S {$_SERVER["SERVER_NAME"]}:{$_SERVER["SERVER_PORT"]} system/router.php</pre>");
}
}
use Grav\Common\Grav;
use RocketTheme\Toolbox\Event\Event;

View File

@@ -133,6 +133,7 @@ form:
label: PLUGIN_ADMIN.FOLDER_NAME
validate:
type: slug
pattern: '[a-zа-я][a-zа-я0-9_\-]+'
route:
type: select

View File

@@ -24,6 +24,7 @@ form:
validate:
type: slug
required: true
pattern: '[a-zа-я][a-zа-я0-9_\-]+'
route:
type: select

View File

@@ -73,6 +73,7 @@ form:
validate:
type: slug
required: true
pattern: '[a-zа-я][a-zа-я0-9_\-]+'
route:
type: select

View File

@@ -26,6 +26,7 @@ form:
validate:
type: slug
required: true
pattern: '[a-zа-я][a-zа-я0-9_\-]+'
route:
type: select

View File

@@ -19,6 +19,7 @@ form:
validate:
type: slug
required: true
pattern: '[a-zа-я][a-zа-я0-9_\-]+'
route:
type: select

View File

@@ -73,6 +73,7 @@ form:
validate:
type: slug
required: true
pattern: '[a-zа-я][a-zа-я0-9_\-]+'
route:
type: select

View File

@@ -8,7 +8,7 @@
// Some standard defines
define('GRAV', true);
define('GRAV_VERSION', '1.1.9');
define('GRAV_VERSION', '1.1.10');
define('GRAV_TESTING', false);
define('DS', '/');
define('GRAV_PHP_MIN', '5.5.9');

26
system/router.php Normal file
View File

@@ -0,0 +1,26 @@
<?php
/**
* @package Grav.Core
*
* @copyright Copyright (C) 2014 - 2016 RocketTheme, LLC. All rights reserved.
* @license MIT License; see LICENSE file for details.
*/
if (PHP_SAPI !== 'cli-server') {
exit('This script cannot be run from browser. Run it from a CLI.');
}
$_SERVER['PHP_CLI_ROUTER'] = true;
if (is_file($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . $_SERVER['SCRIPT_NAME'])) {
return false;
}
$_SERVER = array_merge($_SERVER, $_ENV);
$_SERVER['SCRIPT_FILENAME'] = $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'index.php';
$_SERVER['SCRIPT_NAME'] = DIRECTORY_SEPARATOR . 'index.php';
$_SERVER['PHP_SELF'] = DIRECTORY_SEPARATOR . 'index.php';
require 'index.php';
error_log(sprintf('%s:%d [%d]: %s', $_SERVER['REMOTE_ADDR'], $_SERVER['REMOTE_PORT'], http_response_code(), $_SERVER['REQUEST_URI']), 4);

View File

@@ -582,9 +582,10 @@ class Validation
foreach ($values as $key => $value) {
if (is_array($value)) {
$value = implode(',', $value);
}
$values[$key] = array_map('trim', explode(',', $value));
$values[$key] = array_map('trim', explode(',', $value));
} else {
$values[$key] = trim($value);
}
}
}

View File

@@ -181,7 +181,7 @@ class Installer
return false;
}
$package_folder_name = $zip->getNameIndex(0);
$package_folder_name = preg_replace('#\./$#', '', $zip->getNameIndex(0));
$zip->close();
$extracted_folder = $destination . '/' . $package_folder_name;

View File

@@ -26,11 +26,11 @@ class Inflector
{
if (empty($this->plural)) {
$language = Grav::instance()['language'];
$this->plural = $language->translate('INFLECTOR_PLURALS', null, true);
$this->singular = $language->translate('INFLECTOR_SINGULAR', null, true);
$this->uncountable = $language->translate('INFLECTOR_UNCOUNTABLE', null, true);
$this->irregular = $language->translate('INFLECTOR_IRREGULAR', null, true);
$this->ordinals = $language->translate('INFLECTOR_ORDINALS', null, true);
$this->plural = $language->translate('INFLECTOR_PLURALS', null, true) ?: [];
$this->singular = $language->translate('INFLECTOR_SINGULAR', null, true) ?: [];
$this->uncountable = $language->translate('INFLECTOR_UNCOUNTABLE', null, true) ?: [];
$this->irregular = $language->translate('INFLECTOR_IRREGULAR', null, true) ?: [];
$this->ordinals = $language->translate('INFLECTOR_ORDINALS', null, true) ?: [];
}
}

View File

@@ -87,6 +87,7 @@ class TwigExtension extends \Twig_Extension
new \Twig_SimpleFilter('truncate', ['\Grav\Common\Utils', 'truncate']),
new \Twig_SimpleFilter('truncate_html', ['\Grav\Common\Utils', 'truncateHTML']),
new \Twig_SimpleFilter('json_decode', [$this, 'jsonDecodeFilter']),
new \Twig_SimpleFilter('array_unique', 'array_unique'),
];
}

View File

@@ -65,20 +65,15 @@ class InstallCommand extends ConsoleCommand
// fix trailing slash
$this->destination = rtrim($this->destination, DS) . DS;
$this->user_path = $this->destination . USER_PATH;
if (false === $this->isWindows()) {
$local_config_file = exec('eval echo ~/.grav/config');
if (file_exists($local_config_file)) {
$this->local_config = Yaml::parse($local_config_file);
$this->output->writeln('Read local config from <cyan>' . $local_config_file . '</cyan>');
}
if ($local_config_file = $this->loadLocalConfig()) {
$this->output->writeln('Read local config from <cyan>' . $local_config_file . '</cyan>');
}
// Look for dependencies file in ROOT and USER dir
if (file_exists($this->user_path . $dependencies_file)) {
$this->config = Yaml::parse($this->user_path . $dependencies_file);
$this->config = Yaml::parse(file_get_contents($this->user_path . $dependencies_file));
} elseif (file_exists($this->destination . $dependencies_file)) {
$this->config = Yaml::parse($this->destination . $dependencies_file);
$this->config = Yaml::parse(file_get_contents($this->destination . $dependencies_file));
} else {
$this->output->writeln('<red>ERROR</red> Missing .dependencies file in <cyan>user/</cyan> folder');
}

View File

@@ -16,6 +16,7 @@ use Symfony\Component\Console\Formatter\OutputFormatterStyle;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Yaml\Yaml;
trait ConsoleTrait
{
@@ -113,19 +114,20 @@ trait ConsoleTrait
}
/**
* Validate if the system is based on windows or not.
* Load the local config file
*
* @return bool
* @return mixed string the local config file name. false if local config does not exist
*/
public function isWindows()
public function loadLocalConfig()
{
$keys = [
'CYGWIN_NT-5.1',
'WIN32',
'WINNT',
'Windows'
];
$home_folder = getenv('HOME') ?: getenv('HOMEDRIVE') . getenv('HOMEPATH');
$local_config_file = $home_folder . '/.grav/config';
return array_key_exists(PHP_OS, $keys);
if (file_exists($local_config_file)) {
$this->local_config = Yaml::parse(file_get_contents($local_config_file));
return $local_config_file;
}
return false;
}
}

View File

@@ -84,6 +84,7 @@ class DirectInstallCommand extends ConsoleCommand
$this->output->write("\x0D");
$this->output->writeln(" |- Extracting package... <green>ok</green>");
$type = $this->getPackageType($extracted);
if (!$type) {
@@ -238,6 +239,9 @@ class DirectInstallCommand extends ConsoleCommand
*/
protected function getPackageType($source)
{
$plugin_regex = '/^class\\s{1,}[a-zA-Z0-9]{1,}\\s{1,}extends.+Plugin/m';
$theme_regex = '/^class\\s{1,}[a-zA-Z0-9]{1,}\\s{1,}extends.+Theme/m';
if (
file_exists($source . 'system/defines.php') &&
file_exists($source . 'system/config/system.yaml')
@@ -258,9 +262,9 @@ class DirectInstallCommand extends ConsoleCommand
}
foreach (glob($source . "*.php") as $filename) {
$contents = file_get_contents($filename);
if (Utils::contains($contents, 'Grav\Common\Theme')) {
if (preg_match($theme_regex, $contents)) {
return 'theme';
} elseif (Utils::contains($contents, 'Grav\Common\Plugin')) {
} elseif (preg_match($plugin_regex, $contents)) {
return 'plugin';
}
}

View File

@@ -20,7 +20,6 @@ use Grav\Console\ConsoleCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Question\ConfirmationQuestion;
use Symfony\Component\Yaml\Yaml;
define('GIT_REGEX', '/http[s]?:\/\/(?:.*@)?(github|bitbucket)(?:.org|.com)\/.*\/(.*)/');
@@ -112,13 +111,7 @@ class InstallCommand extends ConsoleCommand
$packages = array_map('strtolower', $this->input->getArgument('package'));
$this->data = $this->gpm->findPackages($packages);
if (false === $this->isWindows() && @is_file(getenv("HOME") . '/.grav/config')) {
$local_config_file = exec('eval echo ~/.grav/config');
if (file_exists($local_config_file)) {
$this->local_config = Yaml::parse($local_config_file);
}
}
$this->loadLocalConfig();
if (
!Installer::isGravInstance($this->destination) ||