From 36e52146f536d33a5ac8dc6785af70a9d13e1781 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Tue, 27 Oct 2015 12:35:29 -0600 Subject: [PATCH 01/40] changelog updated --- CHANGELOG.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aad2c4b8a..fa91a22cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,11 @@ # v1.0.0-rc.2 -## xx/xx/2015 +## 10/27/2015 1. [](#new) * Added support for CSS Asset groups * Added a `wrapped_site` system option for themes/plugins to use + * Pass `Page` object as event to `onTwigPageVariables()` event hook + * New `Data.items()` method to get all items 1. [](#improved) * Missing pipelined remote asset will now fail quietly * More reliably handle inline JS and CSS to remove only surrounding HTML tags @@ -11,8 +13,10 @@ * Improved Medium metadata merging to allow for automatic title/alt/class attributes * Moved Grav object to global variable rather than template variable (useful for macros) * German language improvements + * Updated bundled composer 1. [](#bugfix) * Accept variety of `true` values in `User.authorize()` method + * Fix for `Validation` throwing an error if no label set # v1.0.0-rc.1 ## 10/23/2015 From abf6d6638ef8486c708225a4dccc274ef50e061a Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Tue, 27 Oct 2015 14:47:27 -0600 Subject: [PATCH 02/40] version update --- system/defines.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/defines.php b/system/defines.php index 2adc2b99e..b3d9c06e4 100644 --- a/system/defines.php +++ b/system/defines.php @@ -2,7 +2,7 @@ // Some standard defines define('GRAV', true); -define('GRAV_VERSION', '1.0.0-rc.1'); +define('GRAV_VERSION', '1.0.0-rc.2'); define('DS', '/'); // Directories and Paths From 5260c181a1e649d6796dfa495c1b82876703de37 Mon Sep 17 00:00:00 2001 From: hwmaier Date: Wed, 28 Oct 2015 13:15:03 +1000 Subject: [PATCH 03/40] 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`. --- system/defines.php | 8 ++++---- system/src/Grav/Common/Assets.php | 21 ++++++++++++++------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/system/defines.php b/system/defines.php index b3d9c06e4..2db9a02f8 100644 --- a/system/defines.php +++ b/system/defines.php @@ -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/'); diff --git a/system/src/Grav/Common/Assets.php b/system/src/Grav/Common/Assets.php index f1a61b349..50e4ba4a2 100644 --- a/system/src/Grav/Common/Assets.php +++ b/system/src/Grav/Common/Assets.php @@ -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) { From bd2f7088e91e73aab5ca778e86a31d8646870c98 Mon Sep 17 00:00:00 2001 From: littmus Date: Wed, 28 Oct 2015 17:55:23 +0900 Subject: [PATCH 04/40] Typo fixed --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 83daee5d3..7a6cd4084 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ 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 @@ -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 From 70b67a0805c2093f1b3b03702cb5d2b0cc3905b7 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Wed, 28 Oct 2015 10:39:15 -0600 Subject: [PATCH 05/40] Created whitelist for fallback route functionality --- system/blueprints/config/system.yaml | 10 ++++++++++ system/config/system.yaml | 1 + system/src/Grav/Common/Grav.php | 13 +++++++++++-- system/src/Grav/Common/Uri.php | 6 +++++- 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/system/blueprints/config/system.yaml b/system/blueprints/config/system.yaml index b17fc3605..e79da93e3 100644 --- a/system/blueprints/config/system.yaml +++ b/system/blueprints/config/system.yaml @@ -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 diff --git a/system/config/system.yaml b/system/config/system.yaml index 443788d67..2da34e00e 100644 --- a/system/config/system.yaml +++ b/system/config/system.yaml @@ -54,6 +54,7 @@ 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 diff --git a/system/src/Grav/Common/Grav.php b/system/src/Grav/Common/Grav.php index cbf81eecb..d60cfd0a4 100644 --- a/system/src/Grav/Common/Grav.php +++ b/system/src/Grav/Common/Grav.php @@ -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); diff --git a/system/src/Grav/Common/Uri.php b/system/src/Grav/Common/Uri.php index 92648df7a..0473d3938 100644 --- a/system/src/Grav/Common/Uri.php +++ b/system/src/Grav/Common/Uri.php @@ -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 From ebf9bb5c189926758a4c0f936973aa90188c51c8 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Wed, 28 Oct 2015 13:33:35 -0600 Subject: [PATCH 06/40] Improved collection support #384 --- system/src/Grav/Common/Page/Collection.php | 14 +++++ system/src/Grav/Common/Page/Page.php | 72 ++++++++++++++++------ 2 files changed, 68 insertions(+), 18 deletions(-) diff --git a/system/src/Grav/Common/Page/Collection.php b/system/src/Grav/Common/Page/Collection.php index 5abb8e939..b5836bd45 100644 --- a/system/src/Grav/Common/Page/Collection.php +++ b/system/src/Grav/Common/Page/Collection.php @@ -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; } /** diff --git a/system/src/Grav/Common/Page/Page.php b/system/src/Grav/Common/Page/Page.php index 80aa8bab7..b2734f19e 100644 --- a/system/src/Grav/Common/Page/Page.php +++ b/system/src/Grav/Common/Page/Page.php @@ -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,6 +1957,9 @@ class Page return $value; } + /** @var Pages $pages */ + $pages = self::getGrav()['pages']; + $parts = explode('.', $cmd); $current = array_shift($parts); @@ -1966,42 +1969,75 @@ class Page 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 'recurse': + $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); + // Handle a @page.recurse + if (!empty($parts) && isset($page)) { + switch ($parts[0]) { + case 'self': + $results = new Collection(); + $results = $results->addPage($page); + break; - if ($what == '@root') { - $page = $pages->root(); - } else { - $page = $this->find($what); + case 'recurse': + $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] == 'recurse') { + $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 From c84c1366e73884c03869217be067668967fc285c Mon Sep 17 00:00:00 2001 From: Tu Pham Nguyen Date: Wed, 28 Oct 2015 16:25:29 -0500 Subject: [PATCH 07/40] Updated README.md Just a typo :) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7a6cd4084..0c7989070 100644 --- a/README.md +++ b/README.md @@ -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. From 07b2767ac9649d4184c1a97d48907abfb67038a9 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Wed, 28 Oct 2015 20:52:22 -0600 Subject: [PATCH 08/40] Changed collection types from .recurse to .descendants --- system/src/Grav/Common/Page/Page.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/system/src/Grav/Common/Page/Page.php b/system/src/Grav/Common/Page/Page.php index b2734f19e..8fa66d5aa 100644 --- a/system/src/Grav/Common/Page/Page.php +++ b/system/src/Grav/Common/Page/Page.php @@ -1989,7 +1989,7 @@ class Page $results = $this->parent()->children()->remove($this->path()); break; - case 'recurse': + case 'descendants': $results = $pages->all($this)->remove($this->path())->nonModular(); break; } @@ -2005,7 +2005,7 @@ class Page $page = $this->find($params[0]); } - // Handle a @page.recurse + // Handle a @page.descendants if (!empty($parts) && isset($page)) { switch ($parts[0]) { case 'self': @@ -2013,7 +2013,7 @@ class Page $results = $results->addPage($page); break; - case 'recurse': + case 'descendants': $results = $pages->all($page)->remove($page->path()); break; @@ -2030,7 +2030,7 @@ class Page break; case '@root': - if (!empty($parts) && $parts[0] == 'recurse') { + if (!empty($parts) && $parts[0] == 'descendants') { $results = $pages->all($pages->root())->nonModular()->published(); } else { $results = $pages->root()->children()->nonModular()->published(); From c87e3f419d2d986c3a9edf67fa1670ad2039e484 Mon Sep 17 00:00:00 2001 From: Henrik Maier Date: Thu, 29 Oct 2015 12:52:24 +1000 Subject: [PATCH 09/40] Allow inline styles to be added to Markdown and Twig image tags --- system/src/Grav/Common/Page/Medium/Medium.php | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/system/src/Grav/Common/Page/Medium/Medium.php b/system/src/Grav/Common/Page/Medium/Medium.php index d3d3e6298..f49604166 100644 --- a/system/src/Grav/Common/Page/Medium/Medium.php +++ b/system/src/Grav/Common/Page/Medium/Medium.php @@ -209,9 +209,13 @@ class Medium extends Data implements RenderableInterface $style = ''; foreach ($this->styleAttributes as $key => $value) { - $style .= $key . ': ' . $value . ';'; + if (is_numeric($key)) // Special case for inline style attributes, refer to style() method + $style .= $value; + else + $style .= $key . ': ' . $value . ';'; } - $attributes['style'] = $style; + if ($style) + $attributes['style'] = $style; if (empty($attributes['title'])) { if (!empty($title)) { @@ -388,6 +392,20 @@ class Medium extends Data implements RenderableInterface return $this->link($reset, $attributes); } + /** + * Allows to add an inline style attribute from Markdown or Twig + * Example: ![Example](myimg.png?style=float:left) + * + * @param string $style + * @return $this + */ + public function style($style) + { + error_log($style); + $this->styleAttributes[] = rtrim($style, ';') . ';'; + return $this; + } + /** * Allow any action to be called on this medium from twig or markdown * @@ -440,4 +458,5 @@ class Medium extends Data implements RenderableInterface return $this->_thumbnail; } + } From 8f9671ad32413bcf974a9a07a48c8fe2abdc3a27 Mon Sep 17 00:00:00 2001 From: Henrik Maier Date: Thu, 29 Oct 2015 12:53:00 +1000 Subject: [PATCH 10/40] Allow width and height attributes to be added to Markdown and Twig image tags --- .../Grav/Common/Page/Medium/ImageMedium.php | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/system/src/Grav/Common/Page/Medium/ImageMedium.php b/system/src/Grav/Common/Page/Medium/ImageMedium.php index c38d8e874..38d375a51 100644 --- a/system/src/Grav/Common/Page/Medium/ImageMedium.php +++ b/system/src/Grav/Common/Page/Medium/ImageMedium.php @@ -359,6 +359,48 @@ class ImageMedium extends Medium return empty($this->sizes) ? '100vw' : $this->sizes; } + /** + * Allows to set the width attribute from Markdown or Twig + * Examples: ![Example](myimg.png?width=200&height=400) + * ![Example](myimg.png?resize=100,200&width=100&height=200) + * ![Example](myimg.png?width=auto&height=auto) + * ![Example](myimg.png?width&height) + * {{ page.media['myimg.png'].width().height().html }} + * {{ page.media['myimg.png'].resize(100,200).width(100).height(200).html }} + * + * @param mixed $value A value or 'auto' or empty to use the width of the image + * @return $this + */ + public function width($value = 'auto') + { + if (!$value || $value == 'auto') + $this->attributes['width'] = $this->get('width'); + else + $this->attributes['width'] = $value; + return $this; + } + + /** + * Allows to set the height attribute from Markdown or Twig + * Examples: ![Example](myimg.png?width=200&height=400) + * ![Example](myimg.png?resize=100,200&width=100&height=200) + * ![Example](myimg.png?width=auto&height=auto) + * ![Example](myimg.png?width&height) + * {{ page.media['myimg.png'].width().height().html }} + * {{ page.media['myimg.png'].resize(100,200).width(100).height(200).html }} + * + * @param mixed $value A value or 'auto' or empty to use the height of the image + * @return $this + */ + public function height($value = 'auto') + { + if (!$value || $value == 'auto') + $this->attributes['height'] = $this->get('height'); + else + $this->attributes['height'] = $value; + return $this; + } + /** * Forward the call to the image processing method. * From e91554770c71c2c24a49995b1823843b56cdbf73 Mon Sep 17 00:00:00 2001 From: Nick Balestra Date: Wed, 28 Oct 2015 19:58:38 -0700 Subject: [PATCH 11/40] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0c7989070..8a405e3dc 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ The underlying architecture of Grav is designed to use well-established and _bes * [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 From bb16dbab78b4c5cafa7a1e8e3b8ab93f3ec53bec Mon Sep 17 00:00:00 2001 From: Henrik Maier Date: Thu, 29 Oct 2015 13:02:22 +1000 Subject: [PATCH 12/40] Remove debug error_log output --- system/src/Grav/Common/Page/Medium/Medium.php | 1 - 1 file changed, 1 deletion(-) diff --git a/system/src/Grav/Common/Page/Medium/Medium.php b/system/src/Grav/Common/Page/Medium/Medium.php index f49604166..b36864c27 100644 --- a/system/src/Grav/Common/Page/Medium/Medium.php +++ b/system/src/Grav/Common/Page/Medium/Medium.php @@ -401,7 +401,6 @@ class Medium extends Data implements RenderableInterface */ public function style($style) { - error_log($style); $this->styleAttributes[] = rtrim($style, ';') . ';'; return $this; } From 9445aa43e68a100399590c3392f494013cc2e2e3 Mon Sep 17 00:00:00 2001 From: Benny Date: Thu, 29 Oct 2015 13:44:29 +0100 Subject: [PATCH 13/40] Fix #395 (Problem with default language and slugs that is starting with language name) --- system/src/Grav/Common/Language/Language.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/src/Grav/Common/Language/Language.php b/system/src/Grav/Common/Language/Language.php index 4f6718836..5dfe343f2 100644 --- a/system/src/Grav/Common/Language/Language.php +++ b/system/src/Grav/Common/Language/Language.php @@ -162,7 +162,7 @@ class Language */ public function setActiveFromUri($uri) { - $regex = '/(^\/(' . $this->getAvailable() . ')).*/'; + $regex = '/(^\/(' . $this->getAvailable() . '))(?:\/.*|$)/i'; // if languages set if ($this->enabled()) { From 3e32e61db153101f06af395412194e1b1b5d36e8 Mon Sep 17 00:00:00 2001 From: Flavio Copes Date: Thu, 29 Oct 2015 14:59:11 +0100 Subject: [PATCH 14/40] Revert "Add a items() method that returns the Data::items array" This reverts commit fafd72fcd8ea43f2f252f2e7c13f16f596bab5f5. --- system/src/Grav/Common/Data/Data.php | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/system/src/Grav/Common/Data/Data.php b/system/src/Grav/Common/Data/Data.php index 2a12eb22d..6a35fbc9e 100644 --- a/system/src/Grav/Common/Data/Data.php +++ b/system/src/Grav/Common/Data/Data.php @@ -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. * From 929b0806dc71d88b65d4d7544c56611cdd1a715c Mon Sep 17 00:00:00 2001 From: Benny Date: Thu, 29 Oct 2015 16:58:41 +0100 Subject: [PATCH 15/40] Addresses # 12 (form-plugin) Trim fields before validation --- system/src/Grav/Common/Data/Validation.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/system/src/Grav/Common/Data/Validation.php b/system/src/Grav/Common/Data/Validation.php index 8bdc064af..3382a7218 100644 --- a/system/src/Grav/Common/Data/Validation.php +++ b/system/src/Grav/Common/Data/Validation.php @@ -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); } From 8ba49e163d9f97c24aef6e7867eef737654b3d0a Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Thu, 29 Oct 2015 14:06:54 -0600 Subject: [PATCH 16/40] version update --- CHANGELOG.md | 13 +++++++++++++ system/defines.php | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fa91a22cb..4f10c10be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,16 @@ +# 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 +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 diff --git a/system/defines.php b/system/defines.php index 2db9a02f8..b69ba4b3e 100644 --- a/system/defines.php +++ b/system/defines.php @@ -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.3'); define('DS', '/'); // Directories and Paths From 6bf669815d2004783b22cb6ca3232621c9211397 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Thu, 29 Oct 2015 14:08:09 -0600 Subject: [PATCH 17/40] version update --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f10c10be..3a0498730 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ 1. [](#new) * New Page collection options! `@self.parent, @self.siblings, @self.descendants` + more - * Whitelist of file types for fallback route functionality + * Whitelist of file types for fallback route functionality (images by default) 1. [](#improved) * Assets switched from defines to streams 1. [](#bugfix) From 1e81d5e38ce7dd56f52510bf6ba824c9ebb8a47d Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Thu, 29 Oct 2015 16:34:30 -0600 Subject: [PATCH 18/40] whitespace tweak --- system/config/system.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/config/system.yaml b/system/config/system.yaml index 2da34e00e..022f63b13 100644 --- a/system/config/system.yaml +++ b/system/config/system.yaml @@ -49,7 +49,7 @@ 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 From fc18a40c3590f928d4bd7aa48e4a73686621ff13 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Thu, 29 Oct 2015 20:03:19 -0600 Subject: [PATCH 19/40] fixed double bang --- system/src/Grav/Common/Config/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/src/Grav/Common/Config/Config.php b/system/src/Grav/Common/Config/Config.php index 9e69e994c..cc8acc085 100644 --- a/system/src/Grav/Common/Config/Config.php +++ b/system/src/Grav/Common/Config/Config.php @@ -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; } From 49d4fbcf3de4b253c4a4491197818bc45c339cf2 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Thu, 29 Oct 2015 21:50:58 -0600 Subject: [PATCH 20/40] fix for non-existing page with collection `@page: /something` format --- system/src/Grav/Common/Page/Page.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/system/src/Grav/Common/Page/Page.php b/system/src/Grav/Common/Page/Page.php index 8fa66d5aa..f2c6ea2d9 100644 --- a/system/src/Grav/Common/Page/Page.php +++ b/system/src/Grav/Common/Page/Page.php @@ -1963,7 +1963,7 @@ class Page $parts = explode('.', $cmd); $current = array_shift($parts); - $results = null; + $results = new Collection(); switch ($current) { case '@self': if (!empty($parts)) { @@ -2005,8 +2005,13 @@ class Page $page = $this->find($params[0]); } + // safety check in case page is not found + if (!isset($page)) { + return $results; + } + // Handle a @page.descendants - if (!empty($parts) && isset($page)) { + if (!empty($parts)) { switch ($parts[0]) { case 'self': $results = new Collection(); From 3d7fa06129d6ac53319ed08c41b20387f31a9771 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Thu, 29 Oct 2015 21:52:52 -0600 Subject: [PATCH 21/40] version update --- CHANGELOG.md | 6 ++++++ system/defines.php | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a0498730..b70544e62 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# v1.0.0-rc.4 +## 10/29/2015 + +1. [](#bugfix) + * Fixed a fatal error if you have a collection with missing/invalid `@page: /route` + # v1.0.0-rc.3 ## 10/29/2015 diff --git a/system/defines.php b/system/defines.php index b69ba4b3e..ff7cf777e 100644 --- a/system/defines.php +++ b/system/defines.php @@ -2,7 +2,7 @@ // Some standard defines define('GRAV', true); -define('GRAV_VERSION', '1.0.0-rc.3'); +define('GRAV_VERSION', '1.0.0-rc.4'); define('DS', '/'); // Directories and Paths From c97edb60a5b24e93d25af47dd49384fd9a5ab061 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Thu, 29 Oct 2015 22:11:06 -0600 Subject: [PATCH 22/40] version update --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b70544e62..4300bc74b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## 10/29/2015 1. [](#bugfix) - * Fixed a fatal error if you have a collection with missing/invalid `@page: /route` + * Fixed a fatal error if you have a collection with missing or invalid `@page: /route` # v1.0.0-rc.3 ## 10/29/2015 From 4b6a85f30a0ecc48ebb2b46d689cc5ddb7d51e05 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Fri, 30 Oct 2015 11:41:03 -0600 Subject: [PATCH 23/40] updated vendor libs --- composer.lock | 77 +++++++++++++++++++++++---------------------------- 1 file changed, 35 insertions(+), 42 deletions(-) diff --git a/composer.lock b/composer.lock index 7b094c5e9..43990b358 100644 --- a/composer.lock +++ b/composer.lock @@ -1,23 +1,24 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], "hash": "e1db721096772d41f16003b39b47c85a", + "content-hash": "294dd2282a332d96b19d163ad08e7ba7", "packages": [ { "name": "doctrine/cache", - "version": "v1.4.2", + "version": "v1.5.0", "source": { "type": "git", "url": "https://github.com/doctrine/cache.git", - "reference": "8c434000f420ade76a07c64cbe08ca47e5c101ca" + "reference": "eb8a73619af4f1c8711e2ce482f5de3643258a1f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/cache/zipball/8c434000f420ade76a07c64cbe08ca47e5c101ca", - "reference": "8c434000f420ade76a07c64cbe08ca47e5c101ca", + "url": "https://api.github.com/repos/doctrine/cache/zipball/eb8a73619af4f1c8711e2ce482f5de3643258a1f", + "reference": "eb8a73619af4f1c8711e2ce482f5de3643258a1f", "shasum": "" }, "require": { @@ -38,8 +39,8 @@ } }, "autoload": { - "psr-0": { - "Doctrine\\Common\\Cache\\": "lib/" + "psr-4": { + "Doctrine\\Common\\Cache\\": "lib/Doctrine/Common/Cache" } }, "notification-url": "https://packagist.org/downloads/", @@ -74,7 +75,7 @@ "cache", "caching" ], - "time": "2015-08-31 12:36:41" + "time": "2015-10-28 11:27:45" }, { "name": "donatj/phpuseragentparser", @@ -714,16 +715,16 @@ }, { "name": "symfony/console", - "version": "v2.7.5", + "version": "v2.7.6", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "06cb17c013a82f94a3d840682b49425cd00a2161" + "reference": "5efd632294c8320ea52492db22292ff853a43766" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/06cb17c013a82f94a3d840682b49425cd00a2161", - "reference": "06cb17c013a82f94a3d840682b49425cd00a2161", + "url": "https://api.github.com/repos/symfony/console/zipball/5efd632294c8320ea52492db22292ff853a43766", + "reference": "5efd632294c8320ea52492db22292ff853a43766", "shasum": "" }, "require": { @@ -732,7 +733,6 @@ "require-dev": { "psr/log": "~1.0", "symfony/event-dispatcher": "~2.1", - "symfony/phpunit-bridge": "~2.7", "symfony/process": "~2.1" }, "suggest": { @@ -767,20 +767,20 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2015-09-25 08:32:23" + "time": "2015-10-20 14:38:46" }, { "name": "symfony/event-dispatcher", - "version": "v2.7.5", + "version": "v2.7.6", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "ae4dcc2a8d3de98bd794167a3ccda1311597c5d9" + "reference": "87a5db5ea887763fa3a31a5471b512ff1596d9b8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/ae4dcc2a8d3de98bd794167a3ccda1311597c5d9", - "reference": "ae4dcc2a8d3de98bd794167a3ccda1311597c5d9", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/87a5db5ea887763fa3a31a5471b512ff1596d9b8", + "reference": "87a5db5ea887763fa3a31a5471b512ff1596d9b8", "shasum": "" }, "require": { @@ -791,7 +791,6 @@ "symfony/config": "~2.0,>=2.0.5", "symfony/dependency-injection": "~2.6", "symfony/expression-language": "~2.6", - "symfony/phpunit-bridge": "~2.7", "symfony/stopwatch": "~2.3" }, "suggest": { @@ -825,28 +824,25 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "https://symfony.com", - "time": "2015-09-22 13:49:29" + "time": "2015-10-11 09:39:48" }, { "name": "symfony/var-dumper", - "version": "v2.7.5", + "version": "v2.7.6", "source": { "type": "git", "url": "https://github.com/symfony/var-dumper.git", - "reference": "ba8c9a0edf18f70a7efcb8d3eb35323a10263338" + "reference": "eb033050050916b6bfa51be71009ef67b16046c9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-dumper/zipball/ba8c9a0edf18f70a7efcb8d3eb35323a10263338", - "reference": "ba8c9a0edf18f70a7efcb8d3eb35323a10263338", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/eb033050050916b6bfa51be71009ef67b16046c9", + "reference": "eb033050050916b6bfa51be71009ef67b16046c9", "shasum": "" }, "require": { "php": ">=5.3.9" }, - "require-dev": { - "symfony/phpunit-bridge": "~2.7" - }, "suggest": { "ext-symfony_debug": "" }, @@ -884,28 +880,25 @@ "debug", "dump" ], - "time": "2015-09-22 14:41:01" + "time": "2015-10-25 17:17:38" }, { "name": "symfony/yaml", - "version": "v2.7.5", + "version": "v2.7.6", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "31cb2ad0155c95b88ee55fe12bc7ff92232c1770" + "reference": "eca9019c88fbe250164affd107bc8057771f3f4d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/31cb2ad0155c95b88ee55fe12bc7ff92232c1770", - "reference": "31cb2ad0155c95b88ee55fe12bc7ff92232c1770", + "url": "https://api.github.com/repos/symfony/yaml/zipball/eca9019c88fbe250164affd107bc8057771f3f4d", + "reference": "eca9019c88fbe250164affd107bc8057771f3f4d", "shasum": "" }, "require": { "php": ">=5.3.9" }, - "require-dev": { - "symfony/phpunit-bridge": "~2.7" - }, "type": "library", "extra": { "branch-alias": { @@ -933,20 +926,20 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2015-09-14 14:14:09" + "time": "2015-10-11 09:39:48" }, { "name": "twig/twig", - "version": "v1.22.3", + "version": "v1.23.0", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "ebfc36b7e77b0c1175afe30459cf943010245540" + "reference": "5868cd822fd6cf626d5f805439575f9c323cee2a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/ebfc36b7e77b0c1175afe30459cf943010245540", - "reference": "ebfc36b7e77b0c1175afe30459cf943010245540", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/5868cd822fd6cf626d5f805439575f9c323cee2a", + "reference": "5868cd822fd6cf626d5f805439575f9c323cee2a", "shasum": "" }, "require": { @@ -959,7 +952,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.22-dev" + "dev-master": "1.23-dev" } }, "autoload": { @@ -994,7 +987,7 @@ "keywords": [ "templating" ], - "time": "2015-10-13 07:07:02" + "time": "2015-10-29 23:29:01" } ], "packages-dev": [], From 5478cfaf9f8f6e8825a935a01923c97a79a2f36b Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Fri, 30 Oct 2015 11:41:52 -0600 Subject: [PATCH 24/40] Improved .htaccess security --- .htaccess | 12 +++++++----- htaccess.txt | 12 +++++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/.htaccess b/.htaccess index db5015937..55bcd08a7 100644 --- a/.htaccess +++ b/.htaccess @@ -44,15 +44,17 @@ RewriteRule .* index.php [L] ## Begin - Security # Block all direct access for these folders -RewriteRule ^(.git|cache|bin|logs|backup)/(.*) error [L] -# Block access to specific file types for these folders -RewriteRule ^(system|user|vendor)/(.*)\.(txt|md|html|yaml|php|twig|sh|bat)$ error [L] +RewriteRule ^(.git|cache|bin|logs|backup)/(.*) error [F] +# Block access to specific file types for these system folders +RewriteRule ^(system|vendor)/(.*)\.(txt|xml|md|html|yaml|php|pl|py|cgi|twig|sh|bat)$ error [F] +# Block access to specific file types for these user folders +RewriteRule ^(user)/(.*)\.(txt|md|yaml|php|pl|py|cgi|twig|sh|bat)$ error [F] # Block all direct access to .md files: -RewriteRule \.md$ error [L] +RewriteRule \.md$ error [F] # Block all direct access to files and folders beginning with a dot RewriteRule (^\.|/\.) - [F] # Block access to specific files in the root folder -RewriteRule ^(LICENSE|composer.lock|composer.json|nginx.conf|web.config)$ error [F] +RewriteRule ^(LICENSE|composer.lock|composer.json|nginx.conf|web.config|htaccess.txt|\.htaccess)$ error [F] ## End - Security diff --git a/htaccess.txt b/htaccess.txt index db5015937..55bcd08a7 100644 --- a/htaccess.txt +++ b/htaccess.txt @@ -44,15 +44,17 @@ RewriteRule .* index.php [L] ## Begin - Security # Block all direct access for these folders -RewriteRule ^(.git|cache|bin|logs|backup)/(.*) error [L] -# Block access to specific file types for these folders -RewriteRule ^(system|user|vendor)/(.*)\.(txt|md|html|yaml|php|twig|sh|bat)$ error [L] +RewriteRule ^(.git|cache|bin|logs|backup)/(.*) error [F] +# Block access to specific file types for these system folders +RewriteRule ^(system|vendor)/(.*)\.(txt|xml|md|html|yaml|php|pl|py|cgi|twig|sh|bat)$ error [F] +# Block access to specific file types for these user folders +RewriteRule ^(user)/(.*)\.(txt|md|yaml|php|pl|py|cgi|twig|sh|bat)$ error [F] # Block all direct access to .md files: -RewriteRule \.md$ error [L] +RewriteRule \.md$ error [F] # Block all direct access to files and folders beginning with a dot RewriteRule (^\.|/\.) - [F] # Block access to specific files in the root folder -RewriteRule ^(LICENSE|composer.lock|composer.json|nginx.conf|web.config)$ error [F] +RewriteRule ^(LICENSE|composer.lock|composer.json|nginx.conf|web.config|htaccess.txt|\.htaccess)$ error [F] ## End - Security From 8899b3ebb86ed14e5718178afe922482d9433a0f Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Fri, 30 Oct 2015 11:42:08 -0600 Subject: [PATCH 25/40] Rewrote nginx.conf to be simpler and more in line with .htaccess --- nginx.conf | 120 +++++++++++++++++------------------------------------ 1 file changed, 38 insertions(+), 82 deletions(-) diff --git a/nginx.conf b/nginx.conf index 5ce2521b4..2d8b57b10 100644 --- a/nginx.conf +++ b/nginx.conf @@ -1,87 +1,43 @@ -worker_processes 1; +server { + #listen 80; + index index.html index.php; -events { - worker_connections 1024; -} - -http { - include mime.types; - default_type application/octet-stream; - sendfile on; - keepalive_timeout 65; - - server { - listen 80; - server_name localhost; - - error_page 500 502 503 504 /50x.html; - location = /50x.html { - root html; - } - - location / { - root html; - index index.php; - if (!-e $request_filename){ rewrite ^(.*)$ /index.php last; } - } - - # if you want grav in a sub-directory of your main site - # (for example, example.com/mygrav) then you need this rewrite: - location /mygrav { - index index.php; - if (!-e $request_filename){ rewrite ^(.*)$ /mygrav/$2 last; } - try_files $uri $uri/ /index.php?$args; - } - - # if using grav in a sub-directory of your site, - # prepend the actual path to each location - # for example: /mygrav/images - # and: /mygrav/user - # and: /mygrav/cache - # and so on - - location /images/ { - # Serve images as static - } - - location /user { - rewrite ^/user/accounts/(.*)$ /error redirect; - rewrite ^/user/config/(.*)$ /error redirect; - rewrite ^/user/(.*)\.(txt|md|html|php|yaml|json|twig|sh|bat)$ /error redirect; - } - - location /cache { - rewrite ^/cache/(.*) /error redirect; - } - - location /bin { - rewrite ^/bin/(.*)$ /error redirect; - } - - location /backup { - rewrite ^/backup/(.*) /error redirect; - } - - location /system { - rewrite ^/system/(.*)\.(txt|md|html|php|yaml|json|twig|sh|bat)$ /error redirect; - } - - location /vendor { - rewrite ^/vendor/(.*)\.(txt|md|html|php|yaml|json|twig|sh|bat)$ /error redirect; - } - - # Remember to change 127.0.0.1:9000 to the Ip/port - # you configured php-cgi.exe to run from - - location ~ \.php$ { - try_files $uri =404; - fastcgi_split_path_info ^(.+\.php)(/.+)$; - fastcgi_pass 127.0.0.1:9000; - fastcgi_index index.php; - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; - include fastcgi_params; - } + ## Begin - Server Info + root /home/user/www/html; + server_name localhost; + ## End - Server Info + ## Begin - Index + # for subfolders, simply adjust the rewrite: + # to use `/subfolder/index.php` + location / { + try_files $uri $uri/ /index.html; + if (!-e $request_filename){ rewrite ^(.*)$ /index.php last; } } + ## End - Index + ## Begin - PHP + location ~ \.php$ { + # Choose either a socket or TCP/IP address + fastcgi_pass unix:/var/run/php5-fpm.sock; + # fastcgi_pass 127.0.0.1:9000; + + fastcgi_split_path_info ^(.+\.php)(/.+)$; + fastcgi_index index.php; + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name; + } + ## End - PHP + + ## Begin - Security + # deny all direct access for these folders + location ~* /(.git|cache|bin|logs|backups)/.*$ { return 403; } + # deny running scripts inside core system folders + location ~* /(system|vendor)/.*\.(txt|xml|md|html|yaml|php|pl|py|cgi|twig|sh|bat)$ { return 403; } + # deny running scripts inside user folder + location ~* /user/.*\.(txt|md|yaml|php|pl|py|cgi|twig|sh|bat)$ { return 403; } + # deny access to specific files in the root folder + location ~ /(LICENSE|composer.lock|composer.json|nginx.conf|web.config|htaccess.txt|\.htaccess) { return 403; } + ## End - Security } + From 467d68344e284ef5b62f353f0c13e93b281851f2 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Fri, 30 Oct 2015 11:42:36 -0600 Subject: [PATCH 26/40] added a default `umask_fix` property to system.yaml --- system/config/system.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/system/config/system.yaml b/system/config/system.yaml index 022f63b13..43b1dbba5 100644 --- a/system/config/system.yaml +++ b/system/config/system.yaml @@ -72,6 +72,7 @@ twig: autoescape: false # Autoescape Twig vars undefined_functions: true # Allow undefined functions undefined_filters: true # Allow undefined filters + umask_fix: false # By default Twig creates cached files as 755, fix switches this to 775 assets: # Configuration for Assets Manager (JS, CSS) css_pipeline: false # The CSS pipeline is the unification of multiple CSS resources into one file From ec73eef6953bb1af2c0fc4a267e4126a2e2f59ce Mon Sep 17 00:00:00 2001 From: Djamil Legato Date: Fri, 30 Oct 2015 10:49:08 -0700 Subject: [PATCH 27/40] Updated comments for subfolders --- nginx.conf | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/nginx.conf b/nginx.conf index 2d8b57b10..d325ff308 100644 --- a/nginx.conf +++ b/nginx.conf @@ -8,8 +8,9 @@ server { ## End - Server Info ## Begin - Index - # for subfolders, simply adjust the rewrite: - # to use `/subfolder/index.php` + # for subfolders, simply adjust: + # `location /subfolder {` + # and the rewrite to use `/subfolder/index.php` location / { try_files $uri $uri/ /index.html; if (!-e $request_filename){ rewrite ^(.*)$ /index.php last; } From b0c1dbe4b792ff075484a727bdef551fff135508 Mon Sep 17 00:00:00 2001 From: Henrik Maier Date: Sat, 31 Oct 2015 16:21:05 +1000 Subject: [PATCH 28/40] Added support for default routes with a trailing slash --- system/src/Grav/Common/Grav.php | 7 +++++-- system/src/Grav/Common/Page/Pages.php | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/system/src/Grav/Common/Grav.php b/system/src/Grav/Common/Grav.php index cbf81eecb..9aeff682c 100644 --- a/system/src/Grav/Common/Grav.php +++ b/system/src/Grav/Common/Grav.php @@ -114,7 +114,7 @@ class Grav extends Container /** @var Uri $uri */ $uri = $c['uri']; - $path = rtrim($uri->path(), '/'); + $path = $uri->path(); // Don't trim to support trailing slash default routes $path = $path ?: '/'; $page = $pages->dispatch($path); @@ -296,7 +296,10 @@ class Grav extends Container if ($uri->isExternal($route)) { $url = $route; } else { - $url = rtrim($uri->rootUrl(), '/') .'/'. trim($route, '/'); + if ($this['config']->get('system.pages.redirect_trailing_slash', true)) + $url = rtrim($uri->rootUrl(), '/') .'/'. trim($route, '/'); // Remove trailing slash + else + $url = rtrim($uri->rootUrl(), '/') .'/'. ltrim($route, '/'); // Support trailing slash default routes } header("Location: {$url}", true, $code); diff --git a/system/src/Grav/Common/Page/Pages.php b/system/src/Grav/Common/Page/Pages.php index ccb7530d1..53790bac6 100644 --- a/system/src/Grav/Common/Page/Pages.php +++ b/system/src/Grav/Common/Page/Pages.php @@ -272,6 +272,10 @@ class Pages { // Fetch page if there's a defined route to it. $page = isset($this->routes[$url]) ? $this->get($this->routes[$url]) : null; + // Try without trailing slash + if (!$page && Utils::endsWith($url, '/')) { + $page = isset($this->routes[rtrim($url, '/')]) ? $this->get($this->routes[rtrim($url, '/')]) : null; + } // Are we in the admin? this is important! $not_admin = !isset($this->grav['admin']); From ccf2a780b6a328b3cef2f7ed765756fd777b4873 Mon Sep 17 00:00:00 2001 From: Henrik Maier Date: Sun, 1 Nov 2015 10:26:56 +1000 Subject: [PATCH 29/40] Clear previously applied operations when doing a reset on image files --- system/src/Grav/Common/Page/Medium/ImageFile.php | 8 ++++++++ system/src/Grav/Common/Page/Medium/ImageMedium.php | 1 + 2 files changed, 9 insertions(+) diff --git a/system/src/Grav/Common/Page/Medium/ImageFile.php b/system/src/Grav/Common/Page/Medium/ImageFile.php index bb9ce59aa..e75f6d979 100644 --- a/system/src/Grav/Common/Page/Medium/ImageFile.php +++ b/system/src/Grav/Common/Page/Medium/ImageFile.php @@ -9,6 +9,14 @@ class ImageFile extends \Gregwar\Image\Image { use GravTrait; + /** + * Clear previously applied operations + */ + public function clearOperations() + { + $this->operations = []; + } + /** * This is the same as the Gregwar Image class except this one fires a Grav Event on creation of new cached file * diff --git a/system/src/Grav/Common/Page/Medium/ImageMedium.php b/system/src/Grav/Common/Page/Medium/ImageMedium.php index c38d8e874..65fba3006 100644 --- a/system/src/Grav/Common/Page/Medium/ImageMedium.php +++ b/system/src/Grav/Common/Page/Medium/ImageMedium.php @@ -260,6 +260,7 @@ class ImageMedium extends Medium if ($this->image) { $this->image(); + $this->image->clearOperations(); // Clear previously applied operations $this->filter(); } From a86ce7cb280b842392b1b4926e49c5d4b76dac6e Mon Sep 17 00:00:00 2001 From: Henrik Maier Date: Sun, 1 Nov 2015 17:50:23 +1000 Subject: [PATCH 30/40] Use streams instead of hardcoded paths for clearCache() --- system/src/Grav/Common/Cache.php | 36 +++++++++++++++++++------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/system/src/Grav/Common/Cache.php b/system/src/Grav/Common/Cache.php index 0445c502b..47cf3fa52 100644 --- a/system/src/Grav/Common/Cache.php +++ b/system/src/Grav/Common/Cache.php @@ -21,6 +21,8 @@ use Grav\Common\Filesystem\Folder; */ class Cache extends Getters { + use GravTrait; + /** * @var string Cache key. */ @@ -44,30 +46,30 @@ class Cache extends Getters protected $cache_dir; protected static $standard_remove = [ - 'cache/twig/', - 'cache/doctrine/', - 'cache/compiled/', - 'cache/validated-', - 'images/', - 'assets/', + 'cache://twig/', + 'cache://doctrine/', + 'cache://compiled/', + 'cache://validated-', + 'cache://images', + 'asset://', ]; protected static $all_remove = [ - 'cache/', - 'images/', - 'assets/' + 'cache://', + 'cache://images', + 'asset://' ]; protected static $assets_remove = [ - 'assets/' + 'asset://' ]; protected static $images_remove = [ - 'images/' + 'cache://images' ]; protected static $cache_remove = [ - 'cache/' + 'cache://' ]; /** @@ -221,7 +223,7 @@ class Cache extends Getters */ public static function clearCache($remove = 'standard') { - + $locator = self::getGrav()['locator']; $output = []; $user_config = USER_DIR . 'config/system.yaml'; @@ -243,7 +245,13 @@ class Cache extends Getters } - foreach ($remove_paths as $path) { + foreach ($remove_paths as $stream) { + + // Convert stream to a real path + $path = $locator->findResource($stream); + // Make sure path exists before proceeding, otherwise we would wipe ROOT_DIR + if (!$path) + throw new \RuntimeException("Stream '{$stream}' not found", 500); $anything = false; $files = glob(ROOT_DIR . $path . '*'); From b3144ee921637fb8d1366054eb0f79c3db71afda Mon Sep 17 00:00:00 2001 From: Henrik Maier Date: Sun, 1 Nov 2015 18:55:33 +1000 Subject: [PATCH 31/40] Return resource even if not physically present --- system/src/Grav/Common/Cache.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/src/Grav/Common/Cache.php b/system/src/Grav/Common/Cache.php index 47cf3fa52..f92c53448 100644 --- a/system/src/Grav/Common/Cache.php +++ b/system/src/Grav/Common/Cache.php @@ -248,7 +248,7 @@ class Cache extends Getters foreach ($remove_paths as $stream) { // Convert stream to a real path - $path = $locator->findResource($stream); + $path = $locator->findResource($stream, true, true); // Make sure path exists before proceeding, otherwise we would wipe ROOT_DIR if (!$path) throw new \RuntimeException("Stream '{$stream}' not found", 500); From 0c729e5b0a75df371d89cc5b89d455980089f3c2 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Sun, 1 Nov 2015 13:56:10 -0700 Subject: [PATCH 32/40] latest vendor updates --- composer.lock | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/composer.lock b/composer.lock index 43990b358..d3a9d25b8 100644 --- a/composer.lock +++ b/composer.lock @@ -1,11 +1,10 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], "hash": "e1db721096772d41f16003b39b47c85a", - "content-hash": "294dd2282a332d96b19d163ad08e7ba7", "packages": [ { "name": "doctrine/cache", From 18c1ca3919398199cc554f1106a9d5ae8a705226 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Sun, 1 Nov 2015 18:32:55 -0700 Subject: [PATCH 33/40] added 'theme' to config containing current theme configuration so now possible to just to `{{ config.theme.dropdown_enabled }}` #406 --- system/src/Grav/Common/Themes.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/system/src/Grav/Common/Themes.php b/system/src/Grav/Common/Themes.php index 1b9051c01..add87d3be 100644 --- a/system/src/Grav/Common/Themes.php +++ b/system/src/Grav/Common/Themes.php @@ -171,6 +171,8 @@ class Themes extends Iterator exit("Theme '$name' does not exist, unable to display page."); } + $this->config->set('theme', $config->get('themes.' . $name)); + if (empty($class)) { $class = new Theme($grav, $config, $name); } From b99876f0b4907599ee3134a5ce24090c4a28ee3b Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Sun, 1 Nov 2015 19:24:39 -0700 Subject: [PATCH 34/40] Revert "Return resource even if not physically present" This reverts commit b3144ee921637fb8d1366054eb0f79c3db71afda. --- system/src/Grav/Common/Cache.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/src/Grav/Common/Cache.php b/system/src/Grav/Common/Cache.php index f92c53448..47cf3fa52 100644 --- a/system/src/Grav/Common/Cache.php +++ b/system/src/Grav/Common/Cache.php @@ -248,7 +248,7 @@ class Cache extends Getters foreach ($remove_paths as $stream) { // Convert stream to a real path - $path = $locator->findResource($stream, true, true); + $path = $locator->findResource($stream); // Make sure path exists before proceeding, otherwise we would wipe ROOT_DIR if (!$path) throw new \RuntimeException("Stream '{$stream}' not found", 500); From e016b172763fa6b9ad64319a5b693d409f0e51c7 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Sun, 1 Nov 2015 19:24:46 -0700 Subject: [PATCH 35/40] Revert "Use streams instead of hardcoded paths for clearCache()" This reverts commit a86ce7cb280b842392b1b4926e49c5d4b76dac6e. --- system/src/Grav/Common/Cache.php | 36 +++++++++++++------------------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/system/src/Grav/Common/Cache.php b/system/src/Grav/Common/Cache.php index 47cf3fa52..0445c502b 100644 --- a/system/src/Grav/Common/Cache.php +++ b/system/src/Grav/Common/Cache.php @@ -21,8 +21,6 @@ use Grav\Common\Filesystem\Folder; */ class Cache extends Getters { - use GravTrait; - /** * @var string Cache key. */ @@ -46,30 +44,30 @@ class Cache extends Getters protected $cache_dir; protected static $standard_remove = [ - 'cache://twig/', - 'cache://doctrine/', - 'cache://compiled/', - 'cache://validated-', - 'cache://images', - 'asset://', + 'cache/twig/', + 'cache/doctrine/', + 'cache/compiled/', + 'cache/validated-', + 'images/', + 'assets/', ]; protected static $all_remove = [ - 'cache://', - 'cache://images', - 'asset://' + 'cache/', + 'images/', + 'assets/' ]; protected static $assets_remove = [ - 'asset://' + 'assets/' ]; protected static $images_remove = [ - 'cache://images' + 'images/' ]; protected static $cache_remove = [ - 'cache://' + 'cache/' ]; /** @@ -223,7 +221,7 @@ class Cache extends Getters */ public static function clearCache($remove = 'standard') { - $locator = self::getGrav()['locator']; + $output = []; $user_config = USER_DIR . 'config/system.yaml'; @@ -245,13 +243,7 @@ class Cache extends Getters } - foreach ($remove_paths as $stream) { - - // Convert stream to a real path - $path = $locator->findResource($stream); - // Make sure path exists before proceeding, otherwise we would wipe ROOT_DIR - if (!$path) - throw new \RuntimeException("Stream '{$stream}' not found", 500); + foreach ($remove_paths as $path) { $anything = false; $files = glob(ROOT_DIR . $path . '*'); From dc8efded34d380a349a275e254ddd6f5b07235bf Mon Sep 17 00:00:00 2001 From: Henrik Maier Date: Sun, 1 Nov 2015 17:50:23 +1000 Subject: [PATCH 36/40] Use streams instead of hardcoded paths for clearCache() --- system/src/Grav/Common/Cache.php | 36 +++++++++++++++++++------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/system/src/Grav/Common/Cache.php b/system/src/Grav/Common/Cache.php index 0445c502b..47cf3fa52 100644 --- a/system/src/Grav/Common/Cache.php +++ b/system/src/Grav/Common/Cache.php @@ -21,6 +21,8 @@ use Grav\Common\Filesystem\Folder; */ class Cache extends Getters { + use GravTrait; + /** * @var string Cache key. */ @@ -44,30 +46,30 @@ class Cache extends Getters protected $cache_dir; protected static $standard_remove = [ - 'cache/twig/', - 'cache/doctrine/', - 'cache/compiled/', - 'cache/validated-', - 'images/', - 'assets/', + 'cache://twig/', + 'cache://doctrine/', + 'cache://compiled/', + 'cache://validated-', + 'cache://images', + 'asset://', ]; protected static $all_remove = [ - 'cache/', - 'images/', - 'assets/' + 'cache://', + 'cache://images', + 'asset://' ]; protected static $assets_remove = [ - 'assets/' + 'asset://' ]; protected static $images_remove = [ - 'images/' + 'cache://images' ]; protected static $cache_remove = [ - 'cache/' + 'cache://' ]; /** @@ -221,7 +223,7 @@ class Cache extends Getters */ public static function clearCache($remove = 'standard') { - + $locator = self::getGrav()['locator']; $output = []; $user_config = USER_DIR . 'config/system.yaml'; @@ -243,7 +245,13 @@ class Cache extends Getters } - foreach ($remove_paths as $path) { + foreach ($remove_paths as $stream) { + + // Convert stream to a real path + $path = $locator->findResource($stream); + // Make sure path exists before proceeding, otherwise we would wipe ROOT_DIR + if (!$path) + throw new \RuntimeException("Stream '{$stream}' not found", 500); $anything = false; $files = glob(ROOT_DIR . $path . '*'); From a95b716aa79e6ea7923c97f60b095819bb9711ab Mon Sep 17 00:00:00 2001 From: Henrik Maier Date: Sun, 1 Nov 2015 18:55:33 +1000 Subject: [PATCH 37/40] Return resource even if not physically present --- system/src/Grav/Common/Cache.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/src/Grav/Common/Cache.php b/system/src/Grav/Common/Cache.php index 47cf3fa52..f92c53448 100644 --- a/system/src/Grav/Common/Cache.php +++ b/system/src/Grav/Common/Cache.php @@ -248,7 +248,7 @@ class Cache extends Getters foreach ($remove_paths as $stream) { // Convert stream to a real path - $path = $locator->findResource($stream); + $path = $locator->findResource($stream, true, true); // Make sure path exists before proceeding, otherwise we would wipe ROOT_DIR if (!$path) throw new \RuntimeException("Stream '{$stream}' not found", 500); From 4b68036a1b7d88bbec9c2af94245955e0b106c63 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Sun, 1 Nov 2015 20:52:14 -0700 Subject: [PATCH 38/40] Fixed assets stream for `bin/grav clear` --- system/config/streams.yaml | 5 ----- system/src/Grav/Common/Cache.php | 4 ++-- system/src/Grav/Common/Config/Config.php | 6 ++++++ 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/system/config/streams.yaml b/system/config/streams.yaml index c06ec3547..9053b9080 100644 --- a/system/config/streams.yaml +++ b/system/config/streams.yaml @@ -1,9 +1,4 @@ schemes: - asset: - type: ReadOnlyStream - paths: - - assets - image: type: ReadOnlyStream paths: diff --git a/system/src/Grav/Common/Cache.php b/system/src/Grav/Common/Cache.php index f92c53448..6ba75f4a3 100644 --- a/system/src/Grav/Common/Cache.php +++ b/system/src/Grav/Common/Cache.php @@ -254,7 +254,7 @@ class Cache extends Getters throw new \RuntimeException("Stream '{$stream}' not found", 500); $anything = false; - $files = glob(ROOT_DIR . $path . '*'); + $files = glob($path . '/*'); if (is_array($files)) { foreach ($files as $file) { @@ -271,7 +271,7 @@ class Cache extends Getters } if ($anything) { - $output[] = 'Cleared: ' . $path . '*'; + $output[] = 'Cleared: ' . $path . '/*'; } } diff --git a/system/src/Grav/Common/Config/Config.php b/system/src/Grav/Common/Config/Config.php index cc8acc085..fe8105ddf 100644 --- a/system/src/Grav/Common/Config/Config.php +++ b/system/src/Grav/Common/Config/Config.php @@ -30,6 +30,12 @@ class Config extends Data '' => ['user'], ] ], + 'asset' => [ + 'type' => 'ReadOnlyStream', + 'prefixes' => [ + '' => ['assets'], + ] + ], 'blueprints' => [ 'type' => 'ReadOnlyStream', 'prefixes' => [ From e400207a65accd8ae17a81ca14728d1d366897c2 Mon Sep 17 00:00:00 2001 From: Flavio Copes Date: Mon, 2 Nov 2015 18:57:16 +0100 Subject: [PATCH 39/40] Fix https://github.com/getgrav/grav-plugin-admin/issues/249, password not required any more. If not set, it's not changed. If set, it's changed (if it satisfies the requirements) --- system/blueprints/user/account.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/blueprints/user/account.yaml b/system/blueprints/user/account.yaml index 207421ae0..efe5bda74 100644 --- a/system/blueprints/user/account.yaml +++ b/system/blueprints/user/account.yaml @@ -29,7 +29,7 @@ form: size: large label: PLUGIN_ADMIN.PASSWORD validate: - required: true + required: false message: PLUGIN_ADMIN.PASSWORD_VALIDATION_MESSAGE pattern: '(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,}' From 77d80f12f3acf53ee918b85acedd18bae5b0c087 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Mon, 2 Nov 2015 17:28:46 -0700 Subject: [PATCH 40/40] Fix for untranslated validation messages #246 --- system/src/Grav/Common/Data/Blueprint.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/system/src/Grav/Common/Data/Blueprint.php b/system/src/Grav/Common/Data/Blueprint.php index 15cdce65c..4f24620af 100644 --- a/system/src/Grav/Common/Data/Blueprint.php +++ b/system/src/Grav/Common/Data/Blueprint.php @@ -76,7 +76,8 @@ class Blueprint try { $this->validateArray($data, $this->nested); } catch (\RuntimeException $e) { - throw new \RuntimeException(sprintf('Validation failed: %s', $e->getMessage())); + $language = self::getGrav()['language']; + throw new \RuntimeException(sprintf('Validation failed: %s', $language->translate($e->getMessage()))); } }