From f244fc93c8193213def91afa0d61f6761c5a2726 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Fri, 30 Jan 2015 19:19:49 -0700 Subject: [PATCH 01/11] fix for using just defaults --- system/src/Grav/Common/Plugin.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/system/src/Grav/Common/Plugin.php b/system/src/Grav/Common/Plugin.php index b264f722b..ea000c247 100644 --- a/system/src/Grav/Common/Plugin.php +++ b/system/src/Grav/Common/Plugin.php @@ -142,6 +142,8 @@ class Plugin implements EventSubscriberInterface // Get default plugin configurations and retrieve page header configuration if (isset($page->header()->$class_name)) { $header = array_merge($defaults, $page->header()->$class_name); + } else { + $header = $defaults; } // Create new config object and set it on the page object so it's cached for next time From a6790cace37edd2f19a064cced3be8fc779e9493 Mon Sep 17 00:00:00 2001 From: Sommerregen Date: Sun, 1 Feb 2015 18:15:24 +0100 Subject: [PATCH 02/11] Added summary option --- system/src/Grav/Common/Page/Page.php | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/system/src/Grav/Common/Page/Page.php b/system/src/Grav/Common/Page/Page.php index 3f2dcc0dc..19c63eb61 100644 --- a/system/src/Grav/Common/Page/Page.php +++ b/system/src/Grav/Common/Page/Page.php @@ -308,26 +308,32 @@ class Page return $content; } + // Get summary size from site config's file + if (is_null($size)) { + $size = $config->get('site.summary.size', null); + } + // Return calculated summary based on summary divider's position - if (!$size && isset($this->summary_size)) { + $format = $config->get('site.summary.format', 'short'); + // Return entire page content on wrong/ unknown format + if (!in_array($format, array('short', 'long'))) { + return $content; + } elseif (($format === 'short') && isset($this->summary_size)) { return substr($content, 0, $this->summary_size); } - // Return calculated summary based on setting in site config file - if (is_null($size) && $config->get('site.summary.size')) { - $size = $config->get('site.summary.size'); + // If the size is zero, return the entire page content + if ($size === 0) { + return $content; } - // Return calculated summary based on defaults - if (!is_numeric($size) || ($size < 0)) { + elseif (!is_numeric($size) || ($size < 0)) { $size = 300; } return Utils::truncateHTML($content, $size); } - - /** * Gets and Sets the content based on content portion of the .md file * From f0585ddb4e86c76dbe5a9926d4886c772df7d5e3 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Mon, 2 Feb 2015 09:59:54 -0700 Subject: [PATCH 03/11] per-page debug setting not working as intended. Changing approaches... --- system/src/Grav/Common/Page/Medium.php | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/system/src/Grav/Common/Page/Medium.php b/system/src/Grav/Common/Page/Medium.php index e39390234..56bf1cf0a 100644 --- a/system/src/Grav/Common/Page/Medium.php +++ b/system/src/Grav/Common/Page/Medium.php @@ -120,16 +120,7 @@ class Medium extends Data $this->def('mime', 'application/octet-stream'); } - $debug = self::$grav['config']->get('system.images.debug'); - // try to override with page setting if possible - $page = self::$grav['page']; - if (!is_null($page)) { - if (isset($page->header()->images['debug'])) { - $debug = $page->header()->images['debug']; - } - } - - $this->set('debug', $debug); + $this->set('debug', self::$grav['config']->get('system.images.debug')); } /** From a3c848e4e2d14930c70713e3625d2f89b3cefcbb Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Mon, 2 Feb 2015 13:08:56 -0700 Subject: [PATCH 04/11] Moved to camels for plugins+themes as optional class naming type --- system/src/Grav/Common/Plugins.php | 2 +- system/src/Grav/Common/Themes.php | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/system/src/Grav/Common/Plugins.php b/system/src/Grav/Common/Plugins.php index 7397c8bb1..dd495963e 100644 --- a/system/src/Grav/Common/Plugins.php +++ b/system/src/Grav/Common/Plugins.php @@ -54,7 +54,7 @@ class Plugins extends Iterator $pluginClassFormat = [ 'Grav\\Plugin\\'.ucfirst($plugin).'Plugin', - 'Grav\\Plugin\\'.str_replace(['_','-'], '', $plugin).'Plugin' + 'Grav\\Plugin\\'.Inflector::camelize($plugin).'Plugin' ]; $pluginClassName = false; diff --git a/system/src/Grav/Common/Themes.php b/system/src/Grav/Common/Themes.php index e7620cede..e44472835 100644 --- a/system/src/Grav/Common/Themes.php +++ b/system/src/Grav/Common/Themes.php @@ -145,10 +145,19 @@ class Themes extends Iterator $class = include $file; if (!is_object($class)) { - $className = '\\Grav\\Theme\\' . ucfirst($name); - if (class_exists($className)) { - $class = new $className($grav, $config, $name); + $themeClassFormat = [ + 'Grav\\Theme\\'.ucfirst($name), + 'Grav\\Theme\\'.Inflector::camelize($name) + ]; + $themeClassName = false; + + foreach ($themeClassFormat as $themeClass) { + if (class_exists($themeClass)) { + $themeClassName = $themeClass; + $class = new $themeClassName($grav, $config, $name); + break; + } } } } elseif (!$locator('theme://') && !defined('GRAV_CLI')) { From c747c4baf753129a159ec926076e1fa9e82a3975 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Mon, 2 Feb 2015 16:27:36 -0700 Subject: [PATCH 05/11] fix for twig set capturing --- system/src/Grav/Common/Assets.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/system/src/Grav/Common/Assets.php b/system/src/Grav/Common/Assets.php index c24737276..b14ba7233 100644 --- a/system/src/Grav/Common/Assets.php +++ b/system/src/Grav/Common/Assets.php @@ -301,6 +301,7 @@ class Assets */ public function addInlineCss($asset, $priority = 10) { + $asset = (string) $asset; $key = md5($asset); if (is_string($asset) && !array_key_exists($key, $this->inline_css)) { $this->inline_css[$key] = [ @@ -326,6 +327,7 @@ class Assets */ public function addInlineJs($asset, $priority = 10) { + $asset = (string) $asset; $key = md5($asset); if (is_string($asset) && !array_key_exists($key, $this->inline_js)) { $this->inline_js[$key] = [ From 02508933d791b050133bfbe45ab2cd42f75c6f28 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Mon, 2 Feb 2015 17:24:41 -0700 Subject: [PATCH 06/11] moved summary delimiter into site config --- system/config/site.yaml | 5 ++++- system/defines.php | 3 --- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/system/config/site.yaml b/system/config/site.yaml index 59ee2ba15..23c0f1f1b 100644 --- a/system/config/site.yaml +++ b/system/config/site.yaml @@ -6,9 +6,12 @@ taxonomies: [category,tag] # Arbitrary list of taxonomy types blog: route: '/blog' # Route to blog metadata: - description: 'My Grav Site' # Site description + description: 'My Grav Site' # Site description summary: + enabled: true # enable or disable summary of page + format: short # long = summary delimiter will be ignored; short = use the first occurence of delimter or size size: 300 # Maximum length of summary (characters) + delimiter: === # The summary delimiter routes: /something/else: '/blog/sample-3' # Alias for /blog/sample-3 /another/one/here: '/blog/sample-3' # Another alias for /blog/sample-3 diff --git a/system/defines.php b/system/defines.php index 0d011136f..e55db94b1 100644 --- a/system/defines.php +++ b/system/defines.php @@ -40,6 +40,3 @@ define('RAW_CONTENT', 1); define('TWIG_CONTENT', 2); define('TWIG_CONTENT_LIST', 3); define('TWIG_TEMPLATES', 4); - -// Misc Defines -define('SUMMARY_DELIMITER', '==='); From 3f33e97f0c9279c6479a29b663ffed2dccbbfbb7 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Mon, 2 Feb 2015 17:25:14 -0700 Subject: [PATCH 07/11] fix for markdown adding HTML tags into inline JS/CSS --- system/src/Grav/Common/Assets.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/system/src/Grav/Common/Assets.php b/system/src/Grav/Common/Assets.php index b14ba7233..b63de9c72 100644 --- a/system/src/Grav/Common/Assets.php +++ b/system/src/Grav/Common/Assets.php @@ -301,7 +301,9 @@ class Assets */ public function addInlineCss($asset, $priority = 10) { - $asset = (string) $asset; + if (is_a($asset, 'Twig_Markup')) { + $asset = strip_tags((string)$asset); + } $key = md5($asset); if (is_string($asset) && !array_key_exists($key, $this->inline_css)) { $this->inline_css[$key] = [ @@ -327,7 +329,9 @@ class Assets */ public function addInlineJs($asset, $priority = 10) { - $asset = (string) $asset; + if (is_a($asset, 'Twig_Markup')) { + $asset = strip_tags((string)$asset); + } $key = md5($asset); if (is_string($asset) && !array_key_exists($key, $this->inline_js)) { $this->inline_js[$key] = [ From dc65475723f8fd7e542ba567d5ecb4f040b78c68 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Mon, 2 Feb 2015 17:25:24 -0700 Subject: [PATCH 08/11] PSR fixes --- system/src/Grav/Common/Utils.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/system/src/Grav/Common/Utils.php b/system/src/Grav/Common/Utils.php index ecee73676..ac4f95f0f 100644 --- a/system/src/Grav/Common/Utils.php +++ b/system/src/Grav/Common/Utils.php @@ -46,7 +46,8 @@ abstract class Utils * @param $dir * @return bool */ - public static function rrmdir($dir) { + public static function rrmdir($dir) + { $files = new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator($dir, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::CHILD_FIRST @@ -55,9 +56,13 @@ abstract class Utils /** @var \DirectoryIterator $fileinfo */ foreach ($files as $fileinfo) { if ($fileinfo->isDir()) { - if (false === rmdir($fileinfo->getRealPath())) return false; + if (false === rmdir($fileinfo->getRealPath())) { + return false; + } } else { - if (false === unlink($fileinfo->getRealPath())) return false; + if (false === unlink($fileinfo->getRealPath())) { + return false; + } } } @@ -74,7 +79,8 @@ abstract class Utils * @param bool $considerHtml * @return string */ - public static function truncateHtml($text, $length = 100, $ending = '...', $exact = false, $considerHtml = true) { + public static function truncateHtml($text, $length = 100, $ending = '...', $exact = false, $considerHtml = true) + { $open_tags = array(); if ($considerHtml) { // if the plain text is shorter than the maximum length, return the whole text From eb4eafd91547880c145a21bf0c6d46426fd2aff9 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Mon, 2 Feb 2015 17:25:51 -0700 Subject: [PATCH 09/11] Utilize new summary.delimiter setting rather than constant --- system/src/Grav/Common/Page/Page.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/system/src/Grav/Common/Page/Page.php b/system/src/Grav/Common/Page/Page.php index 3f2dcc0dc..7a565c610 100644 --- a/system/src/Grav/Common/Page/Page.php +++ b/system/src/Grav/Common/Page/Page.php @@ -407,10 +407,11 @@ class Page } // Handle summary divider - $divider_pos = strpos($this->content, '

'.SUMMARY_DELIMITER.'

'); + $delimiter = self::$grav['config']->get('site.summary.delimiter', '==='); + $divider_pos = strpos($this->content, "

{$delimiter}

"); if ($divider_pos !== false) { $this->summary_size = $divider_pos; - $this->content = str_replace('

'.SUMMARY_DELIMITER.'

', '', $this->content); + $this->content = str_replace("

{$delimiter}

", '', $this->content); } } From fb9705809d30993b691719db80c856df46012246 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Thu, 5 Feb 2015 15:07:31 -0700 Subject: [PATCH 10/11] HHVM fixes due to issues with traits and static variables #138 --- system/src/Grav/Common/Assets.php | 10 ++-- system/src/Grav/Common/GPM/Local/Plugins.php | 2 +- system/src/Grav/Common/GPM/Local/Themes.php | 2 +- .../src/Grav/Common/GPM/Remote/Collection.php | 2 +- system/src/Grav/Common/GravTrait.php | 3 + .../Common/Markdown/ParsedownGravTrait.php | 8 +-- system/src/Grav/Common/Page/Media.php | 14 ++--- system/src/Grav/Common/Page/Medium.php | 10 ++-- system/src/Grav/Common/Page/Page.php | 58 +++++++++---------- system/src/Grav/Common/User/User.php | 2 +- system/src/Grav/Console/ConsoleTrait.php | 4 +- .../src/Grav/Console/Gpm/UninstallCommand.php | 4 +- 12 files changed, 61 insertions(+), 58 deletions(-) diff --git a/system/src/Grav/Common/Assets.php b/system/src/Grav/Common/Assets.php index b63de9c72..4e940d09e 100644 --- a/system/src/Grav/Common/Assets.php +++ b/system/src/Grav/Common/Assets.php @@ -163,8 +163,8 @@ class Assets public function init() { /** @var Config $config */ - $config = self::$grav['config']; - $base_url = self::$grav['base_url']; + $config = self::getGrav()['config']; + $base_url = self::getGrav()['base_url']; $asset_config = (array)$config->get('system.assets'); $this->config($asset_config); @@ -358,7 +358,7 @@ class Assets } // Sort array by priorities (larger priority first) - if (self::$grav) { + if (self::getGrav()) { usort($this->css, function ($a, $b) { if ($a['priority'] == $b['priority']) { return $b['order'] - $a['order']; @@ -471,7 +471,7 @@ class Assets protected function pipeline($css = true) { /** @var Cache $cache */ - $cache = self::$grav['cache']; + $cache = self::getGrav()['cache']; $key = '?' . $cache->getKey(); if ($css) { @@ -687,7 +687,7 @@ class Assets protected function buildLocalLink($asset) { try { - $asset = self::$grav['locator']->findResource($asset, false); + $asset = self::getGrav()['locator']->findResource($asset, false); } catch (\Exception $e) { } diff --git a/system/src/Grav/Common/GPM/Local/Plugins.php b/system/src/Grav/Common/GPM/Local/Plugins.php index b5193ad86..b52efea93 100644 --- a/system/src/Grav/Common/GPM/Local/Plugins.php +++ b/system/src/Grav/Common/GPM/Local/Plugins.php @@ -17,7 +17,7 @@ class Plugins extends Collection */ public function __construct() { - $grav = self::$grav; + $grav = self::getGrav(); foreach ($grav['plugins']->all() as $name => $data) { $this->items[$name] = new Package($data, $this->type); diff --git a/system/src/Grav/Common/GPM/Local/Themes.php b/system/src/Grav/Common/GPM/Local/Themes.php index 19d68c6a6..673490144 100644 --- a/system/src/Grav/Common/GPM/Local/Themes.php +++ b/system/src/Grav/Common/GPM/Local/Themes.php @@ -6,7 +6,7 @@ class Themes extends Collection private $type = 'themes'; public function __construct() { - $grav = self::$grav; + $grav = self::getGrav(); foreach ($grav['themes']->all() as $name => $data) { $this->items[$name] = new Package($data, $this->type); diff --git a/system/src/Grav/Common/GPM/Remote/Collection.php b/system/src/Grav/Common/GPM/Remote/Collection.php index 58e2e6942..87c97ffae 100644 --- a/system/src/Grav/Common/GPM/Remote/Collection.php +++ b/system/src/Grav/Common/GPM/Remote/Collection.php @@ -31,7 +31,7 @@ class Collection extends Iterator { throw new \RuntimeException("A repository is required for storing the cache"); } - $cache_dir = self::$grav['locator']->findResource('cache://gpm', true, true); + $cache_dir = self::getGrav()['locator']->findResource('cache://gpm', true, true); $this->cache = new FilesystemCache($cache_dir); $this->repository = $repository; diff --git a/system/src/Grav/Common/GravTrait.php b/system/src/Grav/Common/GravTrait.php index b18258323..215b86848 100644 --- a/system/src/Grav/Common/GravTrait.php +++ b/system/src/Grav/Common/GravTrait.php @@ -13,6 +13,9 @@ trait GravTrait */ public function getGrav() { + if (!self::$grav) { + self::$grav = Grav::instance(); + } return self::$grav; } diff --git a/system/src/Grav/Common/Markdown/ParsedownGravTrait.php b/system/src/Grav/Common/Markdown/ParsedownGravTrait.php index 9ba39e423..9de9efeef 100644 --- a/system/src/Grav/Common/Markdown/ParsedownGravTrait.php +++ b/system/src/Grav/Common/Markdown/ParsedownGravTrait.php @@ -29,10 +29,10 @@ trait ParsedownGravTrait protected function init($page) { $this->page = $page; - $this->pages = self::$grav['pages']; + $this->pages = self::getGrav()['pages']; $this->BlockTypes['{'] [] = "TwigTag"; - $this->base_url = rtrim(self::$grav['base_url'] . self::$grav['pages']->base(), '/'); - $this->pages_dir = self::$grav['locator']->findResource('page://'); + $this->base_url = rtrim(self::getGrav()['base_url'] . self::getGrav()['pages']->base(), '/'); + $this->pages_dir = self::getGrav()['locator']->findResource('page://'); $this->special_chars = array('>' => 'gt', '<' => 'lt', '"' => 'quot'); } @@ -159,7 +159,7 @@ trait ParsedownGravTrait } else { // Create the custom lightbox element - + $attributes = $data['a_attributes']; $attributes['href'] = $data['a_href']; diff --git a/system/src/Grav/Common/Page/Media.php b/system/src/Grav/Common/Page/Media.php index afbdeeca4..e6438327a 100644 --- a/system/src/Grav/Common/Page/Media.php +++ b/system/src/Grav/Common/Page/Media.php @@ -55,7 +55,7 @@ class Media extends Getters $medium = $this->get("{$basename}.{$ext}"); if (!$alternative) { - + $medium = $medium ? $medium : $this->createMedium($info->getPathname()); if (!$medium) { @@ -70,7 +70,7 @@ class Media extends Getters } else { $altMedium = $this->createMedium($info->getPathname()); - + if (!$altMedium) { continue; } @@ -86,7 +86,7 @@ class Media extends Getters } $medium = $medium ? $medium : $this->scaleMedium($altMedium, $alternative, 1); - + $medium->addAlternative($this->parseRatio($alternative), $altMedium); } @@ -186,7 +186,7 @@ class Media extends Getters * Create a Medium object from a file * * @param string $file - * + * * @return Medium|null */ protected function createMedium($file) @@ -202,7 +202,7 @@ class Media extends Getters $basename = implode('.', $parts); /** @var Config $config */ - $config = self::$grav['config']; + $config = self::getGrav()['config']; // Check if medium type has been configured. $params = $config->get("media.".strtolower($ext)); @@ -224,7 +224,7 @@ class Media extends Getters 'modified' => filemtime($file), ); - $locator = self::$grav['locator']; + $locator = self::getGrav()['locator']; $lookup = $locator->findResources('image://'); foreach ($lookup as $lookupPath) { @@ -257,7 +257,7 @@ class Media extends Getters $medium->set('debug', false); $file = $medium->resize($width, $height)->setPrettyName($basename)->url(); - $file = preg_replace('|'. preg_quote(self::$grav['base_url_relative']) .'$|', '', GRAV_ROOT) . $file; + $file = preg_replace('|'. preg_quote(self::getGrav()['base_url_relative']) .'$|', '', GRAV_ROOT) . $file; $medium->set('debug', $debug); diff --git a/system/src/Grav/Common/Page/Medium.php b/system/src/Grav/Common/Page/Medium.php index 56bf1cf0a..224317b79 100644 --- a/system/src/Grav/Common/Page/Medium.php +++ b/system/src/Grav/Common/Page/Medium.php @@ -120,7 +120,7 @@ class Medium extends Data $this->def('mime', 'application/octet-stream'); } - $this->set('debug', self::$grav['config']->get('system.images.debug')); + $this->set('debug', self::getGrav()['config']->get('system.images.debug')); } /** @@ -168,7 +168,7 @@ class Medium extends Data $output = preg_replace('|^' . GRAV_ROOT . '|', '', $this->get('path')) . '/' . $this->get('filename'); } - return self::$grav['base_url'] . $output; + return self::getGrav()['base_url'] . $output; } @@ -332,7 +332,7 @@ class Medium extends Data } } else { // TODO: we need to find out URI in a bit better way. - $this->linkTarget = self::$grav['base_url'] . preg_replace('|^' . GRAV_ROOT . '|', '', $this->get('path')) . '/' . $this->get('filename'); + $this->linkTarget = self::getGrav()['base_url'] . preg_replace('|^' . GRAV_ROOT . '|', '', $this->get('path')) . '/' . $this->get('filename'); } return $this; @@ -422,7 +422,7 @@ class Medium extends Data */ public function image($variable = 'thumb') { - $locator = self::$grav['locator']; + $locator = self::getGrav()['locator']; // TODO: add default file $file = $this->get($variable); @@ -453,7 +453,7 @@ class Medium extends Data $ratio = 1; } - $locator = self::$grav['locator']; + $locator = self::getGrav()['locator']; $overlay = $locator->findResource("system://assets/responsive-overlays/{$ratio}x.png") ?: $locator->findResource('system://assets/responsive-overlays/unknown.png'); $this->image->merge(ImageFile::open($overlay)); } diff --git a/system/src/Grav/Common/Page/Page.php b/system/src/Grav/Common/Page/Page.php index 404ce7c42..14281fb2c 100644 --- a/system/src/Grav/Common/Page/Page.php +++ b/system/src/Grav/Common/Page/Page.php @@ -96,7 +96,7 @@ class Page public function __construct($array = array()) { /** @var Config $config */ - $config = self::$grav['config']; + $config = self::getGrav()['config']; $this->routable = true; $this->taxonomy = array(); @@ -123,20 +123,20 @@ class Page $this->modularTwig($this->slug[0] == '_'); // Handle publishing dates if no explict published option set - if (self::$grav['config']->get('system.pages.publish_dates') && !isset($this->header->published)) { + if (self::getGrav()['config']->get('system.pages.publish_dates') && !isset($this->header->published)) { // unpublish if required, if not clear cache right before page should be unpublished if ($this->unpublishDate()) { if ($this->unpublishDate() < time()) { $this->published(false); } else { $this->published(); - self::$grav['cache']->setLifeTime($this->unpublishDate()); + self::getGrav()['cache']->setLifeTime($this->unpublishDate()); } } // publish if required, if not clear cache right before page is published if ($this->publishDate() != $this->modified() && $this->publishDate() > time()) { $this->published(false); - self::$grav['cache']->setLifeTime($this->publishDate()); + self::getGrav()['cache']->setLifeTime($this->publishDate()); } } $this->published(); @@ -300,7 +300,7 @@ class Page public function summary($size = null) { /** @var Config $config */ - $config = self::$grav['config']; + $config = self::getGrav()['config']; $content = $this->content(); // Return summary based on settings in site config file @@ -362,7 +362,7 @@ class Page // Load cached content /** @var Cache $cache */ - $cache = self::$grav['cache']; + $cache = self::getGrav()['cache']; $cache_id = md5('page'.$this->id()); $this->content = $cache->fetch($cache_id); @@ -375,7 +375,7 @@ class Page // if no cached-content run everything if ($this->content == false) { $this->content = $this->raw_content; - self::$grav->fireEvent('onPageContentRaw', new Event(['page' => $this])); + self::getGrav()->fireEvent('onPageContentRaw', new Event(['page' => $this])); if ($twig_first) { if ($process_twig) { @@ -412,7 +412,7 @@ class Page } // Handle summary divider - $delimiter = self::$grav['config']->get('site.summary.delimiter', '==='); + $delimiter = self::getGrav()['config']->get('site.summary.delimiter', '==='); $divider_pos = strpos($this->content, "

{$delimiter}

"); if ($divider_pos !== false) { $this->summary_size = $divider_pos; @@ -430,7 +430,7 @@ class Page protected function processMarkdown() { /** @var Config $config */ - $config = self::$grav['config']; + $config = self::getGrav()['config']; $defaults = (array) $config->get('system.pages.markdown'); if (isset($this->header()->markdown)) { @@ -463,7 +463,7 @@ class Page */ private function processTwig() { - $twig = self::$grav['twig']; + $twig = self::getGrav()['twig']; $this->content = $twig->processPage($this, $this->content); } @@ -472,10 +472,10 @@ class Page */ private function cachePageContent() { - $cache = self::$grav['cache']; + $cache = self::getGrav()['cache']; $cache_id = md5('page'.$this->id()); - self::$grav->fireEvent('onPageContentProcessed', new Event(['page' => $this])); + self::getGrav()->fireEvent('onPageContentProcessed', new Event(['page' => $this])); $cache->save($cache_id, $this->content); } @@ -650,7 +650,7 @@ class Page public function blueprints() { /** @var Pages $pages */ - $pages = self::$grav['pages']; + $pages = self::getGrav()['pages']; return $pages->blueprints($this->template()); } @@ -729,7 +729,7 @@ class Page public function media($var = null) { /** @var Cache $cache */ - $cache = self::$grav['cache']; + $cache = self::getGrav()['cache']; if ($var) { $this->media = $var; @@ -958,7 +958,7 @@ class Page // Safety check to ensure we have a header if ($page_header) { // Merge any site.metadata settings in with page metadata - $defaults = (array) self::$grav['config']->get('site.metadata'); + $defaults = (array) self::getGrav()['config']->get('site.metadata'); if (isset($page_header->metadata)) { $page_header->metadata = array_merge($defaults, $page_header->metadata); @@ -1061,10 +1061,10 @@ class Page public function url($include_host = false) { /** @var Pages $pages */ - $pages = self::$grav['pages']; + $pages = self::getGrav()['pages']; /** @var Uri $uri */ - $uri = self::$grav['uri']; + $uri = self::getGrav()['uri']; $rootUrl = $uri->rootUrl($include_host) . $pages->base(); $url = $rootUrl.'/'.trim($this->route(), '/'); @@ -1263,7 +1263,7 @@ class Page } if (empty($this->max_count)) { /** @var Config $config */ - $config = self::$grav['config']; + $config = self::getGrav()['config']; $this->max_count = (int) $config->get('system.pages.list.count'); } return $this->max_count; @@ -1338,7 +1338,7 @@ class Page } /** @var Pages $pages */ - $pages = self::$grav['pages']; + $pages = self::getGrav()['pages']; return $pages->get($this->parent); } @@ -1351,7 +1351,7 @@ class Page public function children() { /** @var Pages $pages */ - $pages = self::$grav['pages']; + $pages = self::getGrav()['pages']; return $pages->children($this->path()); } @@ -1418,7 +1418,7 @@ class Page public function active() { /** @var Uri $uri */ - $uri = self::$grav['uri']; + $uri = self::getGrav()['uri']; if ($this->url() == $uri->url()) { return true; } @@ -1434,8 +1434,8 @@ class Page public function activeChild() { /** @var Uri $uri */ - $uri = self::$grav['uri']; - $config = self::$grav['config']; + $uri = self::getGrav()['uri']; + $config = self::getGrav()['config']; // Special check when item is home if ($this->home()) { @@ -1489,7 +1489,7 @@ class Page public function find($url, $all = false) { /** @var Pages $pages */ - $pages = self::$grav['pages']; + $pages = self::getGrav()['pages']; return $pages->dispatch($url, $all); } @@ -1521,9 +1521,9 @@ class Page // TODO: MOVE THIS INTO SOMEWHERE ELSE? /** @var Uri $uri */ - $uri = self::$grav['uri']; + $uri = self::getGrav()['uri']; /** @var Config $config */ - $config = self::$grav['config']; + $config = self::getGrav()['config']; foreach ((array) $config->get('site.taxonomies') as $taxonomy) { if ($uri->param($taxonomy)) { @@ -1559,7 +1559,7 @@ class Page } /** @var Grav $grav */ - $grav = self::$grav['grav']; + $grav = self::getGrav()['grav']; // New Custom event to handle things like pagination. $grav->fireEvent('onCollectionProcessed', new Event(['collection' => $collection])); @@ -1639,7 +1639,7 @@ class Page // @taxonomy: { category: [ blog, featured ], level: 1 } /** @var Taxonomy $taxonomy_map */ - $taxonomy_map = self::$grav['taxonomy']; + $taxonomy_map = self::getGrav()['taxonomy']; if (!empty($parts)) { $params = [implode('.', $parts) => $params]; @@ -1715,7 +1715,7 @@ class Page // Do reordering. if ($reorder && $this->order() != $this->_original->order()) { /** @var Pages $pages */ - $pages = self::$grav['pages']; + $pages = self::getGrav()['pages']; $parent = $this->parent(); diff --git a/system/src/Grav/Common/User/User.php b/system/src/Grav/Common/User/User.php index 8da0896fe..80c0f9a0f 100644 --- a/system/src/Grav/Common/User/User.php +++ b/system/src/Grav/Common/User/User.php @@ -26,7 +26,7 @@ class User extends Data */ public static function load($username) { - $locator = self::$grav['locator']; + $locator = self::getGrav()['locator']; // FIXME: validate directory name $blueprints = new Blueprints('blueprints://user'); diff --git a/system/src/Grav/Console/ConsoleTrait.php b/system/src/Grav/Console/ConsoleTrait.php index 4ad07bc4b..42c65d495 100644 --- a/system/src/Grav/Console/ConsoleTrait.php +++ b/system/src/Grav/Console/ConsoleTrait.php @@ -35,8 +35,8 @@ trait ConsoleTrait */ public function setupConsole(InputInterface $input, OutputInterface $output) { - if (self::$grav) { - self::$grav['config']->set('system.cache.driver', 'default'); + if (self::getGrav()) { + self::getGrav()['config']->set('system.cache.driver', 'default'); } $this->argv = $_SERVER['argv'][0]; diff --git a/system/src/Grav/Console/Gpm/UninstallCommand.php b/system/src/Grav/Console/Gpm/UninstallCommand.php index fdd28a520..085612c4f 100644 --- a/system/src/Grav/Console/Gpm/UninstallCommand.php +++ b/system/src/Grav/Console/Gpm/UninstallCommand.php @@ -140,7 +140,7 @@ class UninstallCommand extends Command */ private function uninstallPackage($package) { - $path = self::$grav['locator']->findResource($package->package_type . '://' . $package->slug); + $path = self::getGrav()['locator']->findResource($package->package_type . '://' . $package->slug); Installer::uninstall($path); $errorCode = Installer::lastErrorCode(); @@ -167,7 +167,7 @@ class UninstallCommand extends Command private function checkDestination($package) { - $path = self::$grav['locator']->findResource($package->package_type . '://' . $package->slug); + $path = self::getGrav()['locator']->findResource($package->package_type . '://' . $package->slug); $questionHelper = $this->getHelper('question'); $skipPrompt = $this->input->getOption('all-yes'); From 50785c24342e1126b678f73969e23ce979b2c9b9 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Thu, 5 Feb 2015 20:59:23 -0700 Subject: [PATCH 11/11] version update --- CHANGELOG.md | 15 +++++++++++++++ system/defines.php | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 67164b01e..a88529ade 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,18 @@ +# v0.9.17 +## 02/05/2015 + +1. [](#new) + * Added **full HHVM support!** Get your speed on with Facebook's crazy fast PHP JIT compiler +2. [](#improved) + * More flexible page summary control + * Support **CamelCase** plugin and theme class names. Replaces dashes and underscores + * Moved summary delimiter into `site.yaml` so it can be configurable + * Various PSR fixes +3. [](#bugfix) + * Fix for `mergeConfig()` not falling back to defaults + * Fix for `addInlineCss()` and `addInlineJs()` Assets not working between Twig tags + * Fix for Markdown adding HTML tags into inline CSS and JS + # v0.9.16 ## 01/30/2015 diff --git a/system/defines.php b/system/defines.php index e55db94b1..562e85140 100644 --- a/system/defines.php +++ b/system/defines.php @@ -2,7 +2,7 @@ // Some standard defines define('GRAV', true); -define('GRAV_VERSION', '0.9.16'); +define('GRAV_VERSION', '0.9.17'); define('DS', '/'); // Directories and Paths