Skip to content

Commit

Permalink
Merge branch 'release/1.1.10'
Browse files Browse the repository at this point in the history
  • Loading branch information
rhukster committed Dec 21, 2016
2 parents b740142 + e0f17a4 commit 46d741a
Show file tree
Hide file tree
Showing 18 changed files with 88 additions and 40 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
6 changes: 6 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
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;

Expand Down
1 change: 1 addition & 0 deletions system/blueprints/pages/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ form:
label: PLUGIN_ADMIN.FOLDER_NAME
validate:
type: slug
pattern: '[a-zа-я][a-zа-я0-9_\-]+'

route:
type: select
Expand Down
1 change: 1 addition & 0 deletions system/blueprints/pages/modular_new.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ form:
validate:
type: slug
required: true
pattern: '[a-zа-я][a-zа-я0-9_\-]+'

route:
type: select
Expand Down
1 change: 1 addition & 0 deletions system/blueprints/pages/modular_raw.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ form:
validate:
type: slug
required: true
pattern: '[a-zа-я][a-zа-я0-9_\-]+'

route:
type: select
Expand Down
1 change: 1 addition & 0 deletions system/blueprints/pages/new.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ form:
validate:
type: slug
required: true
pattern: '[a-zа-я][a-zа-я0-9_\-]+'

route:
type: select
Expand Down
1 change: 1 addition & 0 deletions system/blueprints/pages/new_folder.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ form:
validate:
type: slug
required: true
pattern: '[a-zа-я][a-zа-я0-9_\-]+'

route:
type: select
Expand Down
1 change: 1 addition & 0 deletions system/blueprints/pages/raw.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ form:
validate:
type: slug
required: true
pattern: '[a-zа-я][a-zа-я0-9_\-]+'

route:
type: select
Expand Down
2 changes: 1 addition & 1 deletion system/defines.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
26 changes: 26 additions & 0 deletions system/router.php
Original file line number Diff line number Diff line change
@@ -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);
7 changes: 4 additions & 3 deletions system/src/Grav/Common/Data/Validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -582,9 +582,10 @@ protected static function filterArray($value, $params, $field)
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);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion system/src/Grav/Common/GPM/Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public static function unZip($zip_file, $destination)
return false;
}

$package_folder_name = $zip->getNameIndex(0);
$package_folder_name = preg_replace('#\./$#', '', $zip->getNameIndex(0));
$zip->close();
$extracted_folder = $destination . '/' . $package_folder_name;

Expand Down
10 changes: 5 additions & 5 deletions system/src/Grav/Common/Inflector.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ public function init()
{
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) ?: [];
}
}

Expand Down
1 change: 1 addition & 0 deletions system/src/Grav/Common/Twig/TwigExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public function getFilters()
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'),
];
}

Expand Down
13 changes: 4 additions & 9 deletions system/src/Grav/Console/Cli/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,15 @@ protected function serve()
// 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');
}
Expand Down
24 changes: 13 additions & 11 deletions system/src/Grav/Console/ConsoleTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
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
{
Expand Down Expand Up @@ -113,19 +114,20 @@ public function clearCache($all = [])
}

/**
* 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'
];

return array_key_exists(PHP_OS, $keys);
$home_folder = getenv('HOME') ?: getenv('HOMEDRIVE') . getenv('HOMEPATH');
$local_config_file = $home_folder . '/.grav/config';

if (file_exists($local_config_file)) {
$this->local_config = Yaml::parse(file_get_contents($local_config_file));
return $local_config_file;
}

return false;
}
}
8 changes: 6 additions & 2 deletions system/src/Grav/Console/Gpm/DirectInstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ protected function serve()
$this->output->write("\x0D");
$this->output->writeln(" |- Extracting package... <green>ok</green>");


$type = $this->getPackageType($extracted);

if (!$type) {
Expand Down Expand Up @@ -238,6 +239,9 @@ protected function getPackageName($source)
*/
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')
Expand All @@ -258,9 +262,9 @@ protected function getPackageType($source)
}
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';
}
}
Expand Down
9 changes: 1 addition & 8 deletions system/src/Grav/Console/Gpm/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
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)\/.*\/(.*)/');

Expand Down Expand Up @@ -112,13 +111,7 @@ protected function serve()

$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) ||
Expand Down

0 comments on commit 46d741a

Please sign in to comment.