From 80d08eace7a0668ec884c16b2c97f619a62e1ae1 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Fri, 5 Sep 2014 20:52:46 -0600 Subject: [PATCH 1/4] fixes for themes streams and such --- system/src/Grav/Common/Themes.php | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/system/src/Grav/Common/Themes.php b/system/src/Grav/Common/Themes.php index 17d4040f8..6de6b5735 100644 --- a/system/src/Grav/Common/Themes.php +++ b/system/src/Grav/Common/Themes.php @@ -13,9 +13,11 @@ use Grav\Component\Filesystem\ResourceLocator; class Themes extends Iterator { protected $grav; + protected $config; public function __construct(Grav $grav) { $this->grav = $grav; + $this->config = $grav['config']; } /** @@ -23,10 +25,10 @@ class Themes extends Iterator * * @return array|Data[] */ - public static function all() + public function all() { $list = array(); - $iterator = new \DirectoryIterator('themes:///'); + $iterator = new \DirectoryIterator('theme:///'); /** @var \DirectoryIterator $directory */ foreach ($iterator as $directory) { @@ -50,7 +52,7 @@ class Themes extends Iterator * @return Data * @throws \RuntimeException */ - public static function get($name) + public function get($name) { if (!$name) { throw new \RuntimeException('Theme name not provided.'); @@ -60,13 +62,11 @@ class Themes extends Iterator $blueprint = $blueprints->get('blueprints'); $blueprint->name = $name; - /** @var Config $config */ - $config = $this->grav['config']; - // Find thumbnail. - $thumb = "theme://{$name}/thumbnail.jpg"; + $thumb = "theme:///{$name}/thumbnail.jpg"; + if (file_exists($thumb)) { - $blueprint->set('thumbnail', $config->get('system.base_url_relative') . "/user/themes/{$name}/thumbnail.jpg"); + $blueprint->set('thumbnail', $this->config->get('system.base_url_relative') . "/user/themes/{$name}/thumbnail.jpg"); } // Load default configuration. @@ -85,24 +85,19 @@ class Themes extends Iterator public function current($name = null) { - /** @var Config $config */ - $config = $this->grav['config']; if (!$name) { - $name = $config->get('system.pages.theme'); + $name = $this->config->get('system.pages.theme'); } return $name; } - public function load($name = null) + function load($name = null) { $name = $this->current($name); $grav = $this->grav; - /** @var Config $config */ - $config = $grav['config']; - /** @var ResourceLocator $locator */ $locator = $grav['locator']; @@ -115,13 +110,13 @@ class Themes extends Iterator $className = '\\Grav\\Theme\\' . ucfirst($name); if (class_exists($className)) { - $class = new $className($grav, $config, $name); + $class = new $className($grav, $this->config, $name); } } } if (empty($class)) { - $class = new Theme($grav, $config, $name); + $class = new Theme($grav, $this->config, $name); } return $class; @@ -131,7 +126,7 @@ class Themes extends Iterator $name = $this->current($name); /** @var Config $config */ - $config = $this->grav['config']; + $config = $this->config; $themeConfig = File\Yaml::instance("theme://{$name}/{$name}" . YAML_EXT)->content(); From 0fec4c003bcf82199252eab2d1aef16041aa9bb2 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Fri, 5 Sep 2014 22:25:13 -0600 Subject: [PATCH 2/4] getList was returning nothing --- system/src/Grav/Common/Page/Pages.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/src/Grav/Common/Page/Pages.php b/system/src/Grav/Common/Page/Pages.php index 39a201d7a..39aa9d487 100644 --- a/system/src/Grav/Common/Page/Pages.php +++ b/system/src/Grav/Common/Page/Pages.php @@ -300,7 +300,7 @@ class Pages $list[$current->route()] = str_repeat('  ', ($level-1)*2) . $current->title(); } - foreach ($current as $next) { + foreach ($current->children() as $next) { $list = array_merge($list, $this->getList($next, $level + 1)); } From 7a38ac0810fd5516150af09a2bdb33f0893dbc6b Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Fri, 5 Sep 2014 22:25:48 -0600 Subject: [PATCH 3/4] override modified only if a non-markdown file was modified --- system/src/Grav/Common/Page/Pages.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/system/src/Grav/Common/Page/Pages.php b/system/src/Grav/Common/Page/Pages.php index 39aa9d487..fb45bc897 100644 --- a/system/src/Grav/Common/Page/Pages.php +++ b/system/src/Grav/Common/Page/Pages.php @@ -426,17 +426,13 @@ class Pages throw new \RuntimeException('Fatal error when creating page instances.'); } - $last_modified = 0; + // set current modified of page + $last_modified = $page->modified(); /** @var \DirectoryIterator $file */ foreach ($iterator as $file) { $name = $file->getFilename(); - $date = $file->getMTime(); - if ($date > $last_modified) { - $last_modified = $date; - } - if ($file->isFile() && Utils::endsWith($name, CONTENT_EXT)) { $page->init($file); @@ -471,12 +467,16 @@ class Pages if ($config->get('system.pages.events.page')) { $this->grav->fireEvent('onFolderProcessed', new Event(['page' => $page])); } + } else { + $date = $file->getMTime(); + if ($date > $last_modified) { + $last_modified = $date; + } } } - // Override the modified and ID so that it takes the latest change - // into account + // Override the modified and ID so that it takes the latest change into account $page->modified($last_modified); $page->id($last_modified.md5($page->filePath())); From 95a806c8f8214e1e73da8a042994250528652647 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Fri, 5 Sep 2014 22:41:48 -0600 Subject: [PATCH 4/4] removed stray test page --- user/pages/02.test/default.md | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 user/pages/02.test/default.md diff --git a/user/pages/02.test/default.md b/user/pages/02.test/default.md deleted file mode 100644 index 54cb70b34..000000000 --- a/user/pages/02.test/default.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -title: Test ---- - -# Testing