Move content to content-sample

- move the directory content to content-sample
- remove CONTENT_DIR as a define on index.php
- create config value "content_dir" and replace all CONTENT_DIR by it's
correspondent $config['content_dir']
- add the content_dir config on config.php.template
This commit is contained in:
Diogo Oliveira de Melo 2015-03-18 06:32:00 -03:00
parent 0f6a55baa0
commit 196d3cf283
3 changed files with 21 additions and 20 deletions

View file

@ -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
*/
*/

View file

@ -1,7 +1,6 @@
<?php
define('ROOT_DIR', realpath(dirname(__FILE__)) .'/');
define('CONTENT_DIR', ROOT_DIR .'content/');
define('CONTENT_EXT', '.md');
define('LIB_DIR', ROOT_DIR .'lib/');
define('PLUGINS_DIR', ROOT_DIR .'plugins/');

View file

@ -38,11 +38,11 @@ class Pico {
$this->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(