diff --git a/config.php.template b/config.php.template index 341539d..f9f2209 100644 --- a/config.php.template +++ b/config.php.template @@ -3,21 +3,22 @@ /* // Override any of the default settings below: -$config['site_title'] = 'Pico'; // Site title -$config['base_url'] = ''; // Override base URL (e.g. http://example.com) -$config['theme'] = 'default'; // Set the theme (defaults to "default") -$config['date_format'] = 'jS M Y'; // Set the PHP date format -$config['twig_config'] = array( // Twig settings - 'cache' => false, // To enable Twig caching change this to CACHE_DIR - 'autoescape' => false, // Autoescape Twig vars - 'debug' => false // Enable Twig debug +$config['site_title'] = 'Pico'; // Site title +$config['base_url'] = ''; // Override base URL (e.g. http://example.com) +$config['theme'] = 'default'; // Set the theme (defaults to "default") +$config['date_format'] = 'jS M Y'; // Set the PHP date format +$config['twig_config'] = array( // Twig settings + 'cache' => false, // To enable Twig caching change this to CACHE_DIR + 'autoescape' => false, // Autoescape Twig vars + 'debug' => false // Enable Twig debug ); -$config['pages_order_by'] = 'alpha'; // Order pages by "alpha" or "date" -$config['pages_order'] = 'asc'; // Order pages "asc" or "desc" -$config['excerpt_length'] = 50; // The pages excerpt length (in words) +$config['pages_order_by'] = 'alpha'; // Order pages by "alpha" or "date" +$config['pages_order'] = 'asc'; // Order pages "asc" or "desc" +$config['excerpt_length'] = 50; // The pages excerpt length (in words) +$config['content_dir'] = 'content-sample/'; // Content directory. // To add a custom config setting: $config['custom_setting'] = 'Hello'; // Can be accessed by {{ config.custom_setting }} in a theme -*/ \ No newline at end of file +*/ diff --git a/index.php b/index.php index c0f0ef3..1a26424 100644 --- a/index.php +++ b/index.php @@ -1,7 +1,6 @@ run_hooks('request_url', array(&$url)); // Get the file path - if($url) $file = CONTENT_DIR . $url; - else $file = CONTENT_DIR .'index'; + if($url) $file = $settings['content_dir'] . $url; + else $file = $settings['content_dir'] .'index'; // Load the file - if(is_dir($file)) $file = CONTENT_DIR . $url .'/index'. CONTENT_EXT; + if(is_dir($file)) $file = $settings['content_dir'] . $url .'/index'. CONTENT_EXT; else $file .= CONTENT_EXT; $this->run_hooks('before_load_content', array(&$file)); @@ -50,7 +50,7 @@ class Pico { $content = file_get_contents($file); } else { $this->run_hooks('before_404_load_content', array(&$file)); - $content = file_get_contents(CONTENT_DIR .'404'. CONTENT_EXT); + $content = file_get_contents($settings['content_dir'] .'404'. CONTENT_EXT); header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found'); $this->run_hooks('after_404_load_content', array(&$file, &$content)); } @@ -196,7 +196,8 @@ class Pico { 'twig_config' => array('cache' => false, 'autoescape' => false, 'debug' => false), 'pages_order_by' => 'alpha', 'pages_order' => 'asc', - 'excerpt_length' => 50 + 'excerpt_length' => 50, + 'content_dir' => 'content-sample/', ); if(is_array($config)) $config = array_merge($defaults, $config); @@ -217,7 +218,7 @@ class Pico { { global $config; - $pages = $this->get_files(CONTENT_DIR, CONTENT_EXT); + $pages = $this->get_files($config['content_dir'], CONTENT_EXT); $sorted_pages = array(); $date_id = 0; foreach($pages as $key=>$page){ @@ -236,7 +237,7 @@ class Pico { $page_content = file_get_contents($page); $page_meta = $this->read_file_meta($page_content); $page_content = $this->parse_content($page_content); - $url = str_replace(CONTENT_DIR, $base_url .'/', $page); + $url = str_replace($config['content_dir'], $base_url .'/', $page); $url = str_replace('index'. CONTENT_EXT, '', $url); $url = str_replace(CONTENT_EXT, '', $url); $data = array(