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

@ -15,6 +15,7 @@ $config['twig_config'] = array( // Twig settings
$config['pages_order_by'] = 'alpha'; // Order pages by "alpha" or "date" $config['pages_order_by'] = 'alpha'; // Order pages by "alpha" or "date"
$config['pages_order'] = 'asc'; // Order pages "asc" or "desc" $config['pages_order'] = 'asc'; // Order pages "asc" or "desc"
$config['excerpt_length'] = 50; // The pages excerpt length (in words) $config['excerpt_length'] = 50; // The pages excerpt length (in words)
$config['content_dir'] = 'content-sample/'; // Content directory.
// To add a custom config setting: // To add a custom config setting:

View File

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

View File

@ -38,11 +38,11 @@ class Pico {
$this->run_hooks('request_url', array(&$url)); $this->run_hooks('request_url', array(&$url));
// Get the file path // Get the file path
if($url) $file = CONTENT_DIR . $url; if($url) $file = $settings['content_dir'] . $url;
else $file = CONTENT_DIR .'index'; else $file = $settings['content_dir'] .'index';
// Load the file // 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; else $file .= CONTENT_EXT;
$this->run_hooks('before_load_content', array(&$file)); $this->run_hooks('before_load_content', array(&$file));
@ -50,7 +50,7 @@ class Pico {
$content = file_get_contents($file); $content = file_get_contents($file);
} else { } else {
$this->run_hooks('before_404_load_content', array(&$file)); $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'); header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found');
$this->run_hooks('after_404_load_content', array(&$file, &$content)); $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), 'twig_config' => array('cache' => false, 'autoescape' => false, 'debug' => false),
'pages_order_by' => 'alpha', 'pages_order_by' => 'alpha',
'pages_order' => 'asc', 'pages_order' => 'asc',
'excerpt_length' => 50 'excerpt_length' => 50,
'content_dir' => 'content-sample/',
); );
if(is_array($config)) $config = array_merge($defaults, $config); if(is_array($config)) $config = array_merge($defaults, $config);
@ -217,7 +218,7 @@ class Pico {
{ {
global $config; global $config;
$pages = $this->get_files(CONTENT_DIR, CONTENT_EXT); $pages = $this->get_files($config['content_dir'], CONTENT_EXT);
$sorted_pages = array(); $sorted_pages = array();
$date_id = 0; $date_id = 0;
foreach($pages as $key=>$page){ foreach($pages as $key=>$page){
@ -236,7 +237,7 @@ class Pico {
$page_content = file_get_contents($page); $page_content = file_get_contents($page);
$page_meta = $this->read_file_meta($page_content); $page_meta = $this->read_file_meta($page_content);
$page_content = $this->parse_content($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('index'. CONTENT_EXT, '', $url);
$url = str_replace(CONTENT_EXT, '', $url); $url = str_replace(CONTENT_EXT, '', $url);
$data = array( $data = array(