From ebe007bd7833239d51e2303015cba4b4f3eb399a Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Mon, 2 Nov 2015 19:48:58 +0100 Subject: [PATCH] Guess content directory As pointed out by @Lomanic (see https://github.com/picocms/Pico/pull/260#issuecomment-153091890; thank you btw\!) we actually have to explain users how to change the content directory. This runs contrary to our "stupidly simple" claim. So Pico now simply uses the `content` directory when it exists... --- lib/Pico.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/Pico.php b/lib/Pico.php index 13194c4..a0eec93 100644 --- a/lib/Pico.php +++ b/lib/Pico.php @@ -437,7 +437,7 @@ class Pico 'twig_config' => array('cache' => false, 'autoescape' => false, 'debug' => false), 'pages_order_by' => 'alpha', 'pages_order' => 'asc', - 'content_dir' => $this->getRootDir() . 'content-sample/', + 'content_dir' => null, 'content_ext' => '.md', 'timezone' => '' ); @@ -453,7 +453,14 @@ class Pico if (empty($this->config['base_url'])) { $this->config['base_url'] = $this->getBaseUrl(); } - if (!empty($this->config['content_dir'])) { + if (empty($this->config['content_dir'])) { + // try to guess the content directory + if (is_dir($this->getRootDir() . 'content')) { + $this->config['content_dir'] = $this->getRootDir() . 'content/'; + } else { + $this->config['content_dir'] = $this->getRootDir() . 'content-sample/'; + } + } else { $this->config['content_dir'] = $this->getAbsolutePath($this->config['content_dir']); } if (!empty($this->config['timezone'])) {