Compare commits

..

30 Commits

Author SHA1 Message Date
Andy Miller
e62ff07726 Merge branch 'release/1.0.0-rc.4' 2015-10-29 22:11:19 -06:00
Andy Miller
c97edb60a5 version update 2015-10-29 22:11:06 -06:00
Andy Miller
695793b752 Merge branch 'release/1.0.0-rc.4' 2015-10-29 21:53:48 -06:00
Andy Miller
c953ffb471 Merge branch 'release/1.0.0-rc.4' into develop 2015-10-29 21:53:48 -06:00
Andy Miller
3d7fa06129 version update 2015-10-29 21:52:52 -06:00
Andy Miller
49d4fbcf3d fix for non-existing page with collection @page: /something format 2015-10-29 21:50:58 -06:00
Andy Miller
fc18a40c35 fixed double bang 2015-10-29 20:03:19 -06:00
Andy Miller
1e81d5e38c whitespace tweak 2015-10-29 16:34:30 -06:00
Andy Miller
daf8b53c0d Merge branch 'release/1.0.0-rc.3' into develop 2015-10-29 14:08:39 -06:00
Andy Miller
8de55a745d Merge branch 'release/1.0.0-rc.3' 2015-10-29 14:08:38 -06:00
Andy Miller
6bf669815d version update 2015-10-29 14:08:09 -06:00
Andy Miller
8ba49e163d version update 2015-10-29 14:06:54 -06:00
Andy Miller
26918d90ab Merge pull request #397 from Sommerregen/patch-2
Addresses # 12 (form-plugin) Trim fields before validation
2015-10-29 11:57:11 -06:00
Benny
929b0806dc Addresses # 12 (form-plugin) Trim fields before validation 2015-10-29 16:58:41 +01:00
Flavio Copes
3e32e61db1 Revert "Add a items() method that returns the Data::items array"
This reverts commit fafd72fcd8.
2015-10-29 14:59:11 +01:00
Flavio Copes
038693bffb Merge pull request #396 from Sommerregen/patch-1
Fix #395
2015-10-29 14:00:54 +01:00
Benny
9445aa43e6 Fix #395 (Problem with default language and slugs that is starting with language name) 2015-10-29 13:44:29 +01:00
Andy Miller
658212e7be Merge pull request #392 from nickbalestra/readme
Update README.md
2015-10-28 21:01:56 -06:00
Nick Balestra
e91554770c Update README.md 2015-10-28 19:58:38 -07:00
Andy Miller
7f134e39f4 Merge branch 'develop' of https://github.com/getgrav/grav into develop 2015-10-28 20:52:30 -06:00
Andy Miller
07b2767ac9 Changed collection types from .recurse to .descendants 2015-10-28 20:52:22 -06:00
Andy Miller
0ca24a9786 Merge pull request #391 from tuphamnguyen/patch-1
Updated README.md
2015-10-28 20:39:58 -06:00
Tu Pham Nguyen
c84c1366e7 Updated README.md
Just a typo :)
2015-10-28 16:25:29 -05:00
Andy Miller
ebf9bb5c18 Improved collection support #384 2015-10-28 13:33:35 -06:00
Andy Miller
70b67a0805 Created whitelist for fallback route functionality 2015-10-28 10:39:15 -06:00
Andy Miller
545b97716f Merge pull request #387 from hwmaier/feature/asset-stream
Asset management uses now streams rather the constant ASSETS_DIR
2015-10-28 10:12:54 -06:00
Flavio Copes
f7140522f6 Merge pull request #388 from littmus/develop
Typo fixed
2015-10-28 09:56:02 +01:00
littmus
bd2f7088e9 Typo fixed 2015-10-28 17:55:23 +09:00
hwmaier
5260c181a1 Asset management uses now streams rather the constant ASSETS_DIR to configure location. In addition it supports subdirectories for assets location, for example assets/runtime. 2015-10-28 13:15:03 +10:00
Andy Miller
a9538adf2b Merge branch 'release/1.0.0-rc.2' into develop 2015-10-27 14:47:43 -06:00
14 changed files with 150 additions and 51 deletions

View File

@@ -1,3 +1,22 @@
# v1.0.0-rc.4
## 10/29/2015
1. [](#bugfix)
* Fixed a fatal error if you have a collection with missing or invalid `@page: /route`
# v1.0.0-rc.3
## 10/29/2015
1. [](#new)
* New Page collection options! `@self.parent, @self.siblings, @self.descendants` + more
* Whitelist of file types for fallback route functionality (images by default)
1. [](#improved)
* Assets switched from defines to streams
1. [](#bugfix)
* README.md typos fixed
* Fixed issue with routes that have lang string in them (`/en/english`)
* Trim strings before validation so whitespace is not satisfy 'required'
# v1.0.0-rc.2
## 10/27/2015

View File

@@ -9,10 +9,10 @@ The underlying architecture of Grav is designed to use well-established and _bes
* [Twig Templating](http://twig.sensiolabs.org/): for powerful control of the user interface
* [Markdown](http://en.wikipedia.org/wiki/Markdown): for easy content creation
* [YAML](http://yaml.org): for simple configuration
* [Parsedown](http://parsedown.org/): for fast Markdown and Mardown Extra support
* [Parsedown](http://parsedown.org/): for fast Markdown and Markdown Extra support
* [Doctrine Cache](http://docs.doctrine-project.org/en/2.0.x/reference/caching.html): layer for performance
* [Pimple Dependency Injection Container](http://pimple.sensiolabs.org/): for extensibility and maintainability
* [Symfony Event Dispacher](http://symfony.com/doc/current/components/event_dispatcher/introduction.html): for plugin event handling
* [Symfony Event Dispatcher](http://symfony.com/doc/current/components/event_dispatcher/introduction.html): for plugin event handling
* [Symfony Console](http://symfony.com/doc/current/components/console/introduction.html): for CLI interface
* [Gregwar Image Library](https://github.com/Gregwar/Image): for dynamic image manipulation
@@ -53,7 +53,7 @@ You can download [plugins](http://getgrav.org/downloads/plugins) or [themes](htt
$ bin/gpm index
```
This will display all the available plugins and then you can install one ore more with:
This will display all the available plugins and then you can install one or more with:
```
$ bin/gpm install <plugin/theme>
@@ -76,7 +76,7 @@ $ bin/gpm update
# Contributing
We appreciate any contribution to Grav, whether it is related to bugs, grammar, or simply a suggestion or improvement.
However, we ask that any contribution follow our simple guidelines in order to be properly received.
However, we ask that any contributions follow our simple guidelines in order to be properly received.
All our projects follow the [GitFlow branching model][gitflow-model], from development to release. If you are not familiar with it, there are several guides and tutorials to make you understand what it is about.

View File

@@ -215,6 +215,15 @@ form:
validate:
type: bool
pages.fallback_types:
type: selectize
size: large
label: PLUGIN_ADMIN.FALLBACK_TYPES
help: PLUGIN_ADMIN.FALLBACK_TYPES_HELP
classes: fancy
validate:
type: commalist
languages:
type: section
title: PLUGIN_ADMIN.LANGUAGES
@@ -774,6 +783,7 @@ form:
param_sep:
type: select
size: medium
label: PLUGIN_ADMIN.PARAMETER_SEPARATOR
classes: fancy
help: PLUGIN_ADMIN.PARAMETER_SEPARATOR_HELP

View File

@@ -49,11 +49,12 @@ pages:
vary_accept_encoding: false # Add `Vary: Accept-Encoding` header
redirect_default_route: false # Automatically redirect to a page's default route
redirect_default_code: 301 # Default code to use for redirects
redirect_trailing_slash: true # Handle automatically or 301 redirect a trailing / URL
redirect_trailing_slash: true # Handle automatically or 301 redirect a trailing / URL
ignore_files: [.DS_Store] # Files to ignore in Pages
ignore_folders: [.git, .idea] # Folders to ignore in Pages
ignore_hidden: true # Ignore all Hidden files and folders
url_taxonomy_filters: true # Enable auto-magic URL-based taxonomy filters for page collections
fallback_types: [png,jpg,jpeg,gif] # Allowed types of files found if accessed via Page route
cache:
enabled: true # Set to true to enable caching

View File

@@ -2,7 +2,7 @@
// Some standard defines
define('GRAV', true);
define('GRAV_VERSION', '1.0.0-rc.2');
define('GRAV_VERSION', '1.0.0-rc.4');
define('DS', '/');
// Directories and Paths
@@ -13,14 +13,14 @@ define('ROOT_DIR', GRAV_ROOT . '/');
define('USER_PATH', 'user/');
define('USER_DIR', ROOT_DIR . USER_PATH);
define('SYSTEM_DIR', ROOT_DIR .'system/');
define('ASSETS_DIR', ROOT_DIR . 'assets/');
define('CACHE_DIR', ROOT_DIR . 'cache/');
define('IMAGES_DIR', ROOT_DIR . 'images/');
define('LOG_DIR', ROOT_DIR .'logs/');
define('ACCOUNTS_DIR', USER_DIR .'accounts/');
define('PAGES_DIR', USER_DIR .'pages/');
// DEPRECATED: Do not use!
define('ASSETS_DIR', ROOT_DIR . 'assets/');
define('IMAGES_DIR', ROOT_DIR . 'images/');
define('ACCOUNTS_DIR', USER_DIR .'accounts/');
define('PAGES_DIR', USER_DIR .'pages/');
define('DATA_DIR', USER_DIR .'data/');
define('LIB_DIR', SYSTEM_DIR .'src/');
define('PLUGINS_DIR', USER_DIR .'plugins/');

View File

@@ -74,6 +74,8 @@ class Assets
protected $config;
protected $base_url;
protected $timestamp = '';
protected $assets_dir;
protected $assets_url;
// Default values for pipeline settings
protected $css_minify = true;
@@ -117,7 +119,7 @@ class Assets
}
// Pipeline requires public dir
if (($this->js_pipeline || $this->css_pipeline) && !is_dir(ASSETS_DIR)) {
if (($this->js_pipeline || $this->css_pipeline) && !is_dir($this->assets_dir)) {
throw new \Exception('Assets: Public dir not found');
}
@@ -175,6 +177,11 @@ class Assets
$base_url = self::getGrav()['base_url'];
$asset_config = (array)$config->get('system.assets');
/** @var Locator $locator */
$locator = self::$grav['locator'];
$this->assets_dir = self::getGrav()['locator']->findResource('asset://') . DS;
$this->assets_url = self::getGrav()['locator']->findResource('asset://', false);
$this->config($asset_config);
$this->base_url = $base_url . '/';
@@ -621,8 +628,8 @@ class Assets
$file = md5(json_encode($this->css) . $this->css_minify . $this->css_rewrite . $group) . '.css';
$relative_path = "{$this->base_url}" . basename(ASSETS_DIR) . "/{$file}";
$absolute_path = ASSETS_DIR . $file;
$relative_path = "{$this->base_url}{$this->assets_url}/{$file}";
$absolute_path = $this->assets_dir . $file;
// If pipeline exist return it
if (file_exists($absolute_path)) {
@@ -689,8 +696,8 @@ class Assets
$file = md5(json_encode($this->js) . $this->js_minify . $group) . '.js';
$relative_path = "{$this->base_url}" . basename(ASSETS_DIR) . "/{$file}";
$absolute_path = ASSETS_DIR . $file;
$relative_path = "{$this->base_url}{$this->assets_url}/{$file}";
$absolute_path = $this->assets_dir . $file;
// If pipeline exist return it
if (file_exists($absolute_path)) {
@@ -852,12 +859,12 @@ class Assets
public function addDir($directory, $pattern = self::DEFAULT_REGEX)
{
// Check if public_dir exists
if (!is_dir(ASSETS_DIR)) {
if (!is_dir($this->assets_dir)) {
throw new Exception('Assets: Public dir not found');
}
// Get files
$files = $this->rglob(ASSETS_DIR . DIRECTORY_SEPARATOR . $directory, $pattern, ASSETS_DIR);
$files = $this->rglob($this->assets_dir . DIRECTORY_SEPARATOR . $directory, $pattern, $this->assets_dir);
// No luck? Nothing to do
if (!$files) {

View File

@@ -194,7 +194,7 @@ class Config extends Data
$checkConfig = $this->get('system.cache.check.config', true);
$checkSystem = $this->get('system.cache.check.system', true);
if (!$checkBlueprints && !!$checkLanguages && $checkConfig && !$checkSystem) {
if (!$checkBlueprints && !$checkLanguages && !$checkConfig && !$checkSystem) {
$this->messages[] = 'Skip configuration timestamp check.';
return false;
}

View File

@@ -224,16 +224,6 @@ class Data implements DataInterface
return $this->file()->raw();
}
/**
* Return the data items.
*
* @return array
*/
public function items()
{
return $this->items;
}
/**
* Set or get the data storage.
*

View File

@@ -588,6 +588,10 @@ class Validation
public static function validateRequired($value, $params)
{
if (is_string($value)) {
$value = trim($value);
}
return (bool) $params !== true || !empty($value);
}

View File

@@ -457,6 +457,16 @@ class Grav extends Container
/** @var Uri $uri */
$uri = $this['uri'];
/** @var Config $config */
$config = $this['config'];
$uri_extension = $uri->extension();
// Only allow whitelisted types to fallback
if (!in_array($uri_extension, $config->get('system.pages.fallback_types'))) {
return;
}
$path_parts = pathinfo($path);
$page = $this['pages']->dispatch($path_parts['dirname'], true);
if ($page) {
@@ -478,7 +488,6 @@ class Grav extends Container
}
// unsupported media type, try to download it...
$uri_extension = $uri->extension();
if ($uri_extension) {
$extension = $uri_extension;
} else {
@@ -491,7 +500,7 @@ class Grav extends Container
if ($extension) {
$download = true;
if (in_array(ltrim($extension, '.'), $this['config']->get('system.media.unsupported_inline_types', []))) {
if (in_array(ltrim($extension, '.'), $config->get('system.media.unsupported_inline_types', []))) {
$download = false;
}
Utils::download($page->path() . DIRECTORY_SEPARATOR . $uri->basename(), $download);

View File

@@ -162,7 +162,7 @@ class Language
*/
public function setActiveFromUri($uri)
{
$regex = '/(^\/(' . $this->getAvailable() . ')).*/';
$regex = '/(^\/(' . $this->getAvailable() . '))(?:\/.*|$)/i';
// if languages set
if ($this->enabled()) {

View File

@@ -36,6 +36,18 @@ class Collection extends Iterator
return $this->params;
}
/**
* Add a single page to a collection
*
* @param Page $page
* @return $this
*/
public function addPage(Page $page)
{
$this->items[$page->path()] = ['slug' => $page->slug()];
return $this;
}
/**
*
* Create a copy of this collection
@@ -96,6 +108,7 @@ class Collection extends Iterator
* Remove item from the list.
*
* @param Page|string|null $key
* @return $this|void
* @throws \InvalidArgumentException
*/
public function remove($key = null)
@@ -110,6 +123,7 @@ class Collection extends Iterator
}
parent::remove($key);
return $this;
}
/**

View File

@@ -1935,7 +1935,7 @@ class Page
// Format: @command.param
$cmd = $value;
$params = array();
} elseif (is_array($value) && count($value) == 1) {
} elseif (is_array($value) && count($value) == 1 && !is_int(key($value))) {
// Format: @command.param: { attr1: value1, attr2: value2 }
$cmd = (string) key($value);
$params = (array) current($value);
@@ -1957,51 +1957,92 @@ class Page
return $value;
}
/** @var Pages $pages */
$pages = self::getGrav()['pages'];
$parts = explode('.', $cmd);
$current = array_shift($parts);
$results = null;
$results = new Collection();
switch ($current) {
case '@self':
if (!empty($parts)) {
switch ($parts[0]) {
case 'modular':
// @self.modular: false (alternative to @self.children)
if (!empty($params) && $params[0] === false) {
$results = $this->children()->nonModular()->published();
$results = $this->children()->nonModular();
break;
}
$results = $this->children()->modular()->published();
$results = $this->children()->modular();
break;
case 'children':
$results = $this->children()->nonModular()->published();
$results = $this->children()->nonModular();
break;
case 'parent':
$collection = new Collection();
$results = $collection->addPage($this->parent());
break;
case 'siblings':
$results = $this->parent()->children()->remove($this->path());
break;
case 'descendants':
$results = $pages->all($this)->remove($this->path())->nonModular();
break;
}
}
$results = $results->published();
break;
case '@page':
$page = null;
if (!empty($params)) {
/** @var Pages $pages */
$pages = self::getGrav()['pages'];
$page = $this->find($params[0]);
}
list($what, $recurse) = array_pad($params, 2, null);
// safety check in case page is not found
if (!isset($page)) {
return $results;
}
if ($what == '@root') {
$page = $pages->root();
} else {
$page = $this->find($what);
// Handle a @page.descendants
if (!empty($parts)) {
switch ($parts[0]) {
case 'self':
$results = new Collection();
$results = $results->addPage($page);
break;
case 'descendants':
$results = $pages->all($page)->remove($page->path());
break;
case 'children':
$results = $page->children();
break;
}
} else {
$results = $page->children();
}
if ($page) {
if ($recurse) {
$results = $pages->all($page)->nonModular()->published();
} else {
$results = $page->children()->nonModular()->published();
}
}
$results = $results->nonModular()->published();
break;
case '@root':
if (!empty($parts) && $parts[0] == 'descendants') {
$results = $pages->all($pages->root())->nonModular()->published();
} else {
$results = $pages->root()->children()->nonModular()->published();
}
break;
case '@taxonomy':
// Gets a collection of pages by using one of the following formats:
// @taxonomy.category: blog

View File

@@ -133,11 +133,15 @@ class Uri
// set the original basename
$this->basename = $parts['basename'];
// set the extension
if (isset($parts['extension'])) {
$this->extension = $parts['extension'];
}
$valid_page_types = implode('|', $config->get('system.pages.types'));
if (preg_match("/\.(".$valid_page_types.")$/", $parts['basename'])) {
$uri = rtrim(str_replace(DIRECTORY_SEPARATOR, DS, $parts['dirname']), DS). '/' .$parts['filename'];
$this->extension = $parts['extension'];
}
// set the new url