v0.4.1
[New] Added CONTENT_EXT global [Changed] Use .md files instead of .txt
This commit is contained in:
parent
cc7ceafc1e
commit
8cebbb51f8
7 changed files with 25 additions and 20 deletions
|
@ -1,5 +1,9 @@
|
|||
*** Pico Changelog ***
|
||||
|
||||
2013.05.01 - version 0.4.1
|
||||
* [New] Added CONTENT_EXT global
|
||||
* [Changed] Use .md files instead of .txt
|
||||
|
||||
2013.05.01 - version 0.4
|
||||
* [New] Add get_pages() function for listing content
|
||||
* [New] Added changelog.txt
|
||||
|
|
|
@ -9,11 +9,11 @@ Congratulations you have successfully installed [Pico](http://pico.dev7studios.c
|
|||
|
||||
### Creating Content
|
||||
|
||||
Pico is a flat file CMS, this means there is no administration backend and database to deal with. You simply create `.txt` files in the "content"
|
||||
folder and that becomes a page. For example this file is called `index.txt` and is shown as the main landing page.
|
||||
Pico is a flat file CMS, this means there is no administration backend and database to deal with. You simply create `.md` files in the "content"
|
||||
folder and that becomes a page. For example this file is called `index.md` and is shown as the main landing page.
|
||||
|
||||
If you created folder within the content folder (e.g. `content/sub`) and put an `index.txt` inside it, you can access that folder at the URL
|
||||
`http://yousite.com/sub`. If you want another page within the sub folder, simply create a text file with the corresponding name (e.g. `content/sub/page.txt`)
|
||||
If you created folder within the content folder (e.g. `content/sub`) and put an `index.md` inside it, you can access that folder at the URL
|
||||
`http://yousite.com/sub`. If you want another page within the sub folder, simply create a text file with the corresponding name (e.g. `content/sub/page.md`)
|
||||
and will be able to access it from the URL `http://yousite.com/sub/page`. Below we've shown some examples of content locations and their corresponing URL's:
|
||||
|
||||
<table>
|
||||
|
@ -21,15 +21,15 @@ and will be able to access it from the URL `http://yousite.com/sub/page`. Below
|
|||
<tr><th>Physical Location</th><th>URL</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr><td>content/index.txt</td><td>/</td></tr>
|
||||
<tr><td>content/sub.txt</td><td>/sub</td></tr>
|
||||
<tr><td>content/sub/index.txt</td><td>/sub (same as above)</td></tr>
|
||||
<tr><td>content/sub/page.txt</td><td>/sub/page</td></tr>
|
||||
<tr><td>content/a/very/long/url.txt</td><td>/a/very/long/url</td></tr>
|
||||
<tr><td>content/index.md</td><td>/</td></tr>
|
||||
<tr><td>content/sub.md</td><td>/sub</td></tr>
|
||||
<tr><td>content/sub/index.md</td><td>/sub (same as above)</td></tr>
|
||||
<tr><td>content/sub/page.md</td><td>/sub/page</td></tr>
|
||||
<tr><td>content/a/very/long/url.md</td><td>/a/very/long/url</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
If a file cannot be found, the file `content/404.txt` will be shown.
|
||||
If a file cannot be found, the file `content/404.md` will be shown.
|
||||
|
||||
### Text File Markup
|
||||
|
|
@ -4,7 +4,7 @@ Title: Sub Page Index
|
|||
|
||||
## This is a Sub Page Index
|
||||
|
||||
This is index.txt in the "sub" folder.
|
||||
This is index.md in the "sub" folder.
|
||||
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec ultricies tristique nulla et mattis. Phasellus id massa eget nisl congue blandit sit amet id ligula. Praesent et nulla eu augue tempus sagittis. Mauris faucibus nibh et nibh cursus in vestibulum sapien egestas. Curabitur ut lectus tortor. Sed ipsum eros, egestas ut eleifend non, elementum vitae eros. Mauris felis diam, pellentesque vel lacinia ac, dictum a nunc. Mauris mattis nunc sed mi sagittis et facilisis tortor volutpat. Etiam tincidunt urna mattis erat placerat placerat ac eu tellus. Ut nec velit id nisl tincidunt vehicula id a metus. Pellentesque erat neque, faucibus id ultricies vel, mattis in ante. Donec lobortis, mauris id congue scelerisque, diam nisl accumsan orci, condimentum porta est magna vel arcu. Curabitur varius ante dui. Vivamus sit amet ante ac diam ullamcorper sodales sed a odio.
|
||||
|
|
@ -4,7 +4,7 @@ Title: Sub Page
|
|||
|
||||
## This is a Sub Page
|
||||
|
||||
This is page.txt in the "sub" folder.
|
||||
This is page.md in the "sub" folder.
|
||||
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec ultricies tristique nulla et mattis. Phasellus id massa eget nisl congue blandit sit amet id ligula. Praesent et nulla eu augue tempus sagittis. Mauris faucibus nibh et nibh cursus in vestibulum sapien egestas. Curabitur ut lectus tortor. Sed ipsum eros, egestas ut eleifend non, elementum vitae eros. Mauris felis diam, pellentesque vel lacinia ac, dictum a nunc. Mauris mattis nunc sed mi sagittis et facilisis tortor volutpat. Etiam tincidunt urna mattis erat placerat placerat ac eu tellus. Ut nec velit id nisl tincidunt vehicula id a metus. Pellentesque erat neque, faucibus id ultricies vel, mattis in ante. Donec lobortis, mauris id congue scelerisque, diam nisl accumsan orci, condimentum porta est magna vel arcu. Curabitur varius ante dui. Vivamus sit amet ante ac diam ullamcorper sodales sed a odio.
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
define('ROOT_DIR', realpath(dirname(__FILE__)) .'/');
|
||||
define('CONTENT_DIR', ROOT_DIR .'content/');
|
||||
define('CONTENT_EXT', '.md');
|
||||
define('LIB_DIR', ROOT_DIR .'lib/');
|
||||
define('THEMES_DIR', ROOT_DIR .'themes/');
|
||||
define('CACHE_DIR', LIB_DIR .'cache/');
|
||||
|
|
16
lib/pico.php
16
lib/pico.php
|
@ -6,7 +6,7 @@
|
|||
* @author Gilbert Pellegrom
|
||||
* @link http://pico.dev7studios.com/
|
||||
* @license http://opensource.org/licenses/MIT
|
||||
* @version 0.4
|
||||
* @version 0.4.1
|
||||
*/
|
||||
class Pico {
|
||||
|
||||
|
@ -29,12 +29,12 @@ class Pico {
|
|||
else $file = CONTENT_DIR .'index';
|
||||
|
||||
// Load the file
|
||||
if(is_dir($file)) $file = CONTENT_DIR . $url .'/index.txt';
|
||||
else $file .= '.txt';
|
||||
if(is_dir($file)) $file = CONTENT_DIR . $url .'/index'. CONTENT_EXT;
|
||||
else $file .= CONTENT_EXT;
|
||||
|
||||
if(file_exists($file)) $content = file_get_contents($file);
|
||||
else {
|
||||
$content = file_get_contents(CONTENT_DIR .'404.txt');
|
||||
$content = file_get_contents(CONTENT_DIR .'404'. CONTENT_EXT);
|
||||
header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found');
|
||||
}
|
||||
|
||||
|
@ -139,10 +139,10 @@ class Pico {
|
|||
*/
|
||||
function get_pages($base_url)
|
||||
{
|
||||
$pages = $this->glob_recursive(CONTENT_DIR .'*.txt');
|
||||
$pages = $this->glob_recursive(CONTENT_DIR .'*'. CONTENT_EXT);
|
||||
foreach($pages as $key=>$page){
|
||||
// Skip 404
|
||||
if(basename($page) == '404.txt'){
|
||||
if(basename($page) == '404'. CONTENT_EXT){
|
||||
unset($pages[$key]);
|
||||
continue;
|
||||
}
|
||||
|
@ -151,8 +151,8 @@ class Pico {
|
|||
$page_content = file_get_contents($page);
|
||||
$page_meta = $this->read_file_meta($page_content);
|
||||
$url = str_replace(CONTENT_DIR, $base_url .'/', $page);
|
||||
$url = str_replace('index.txt', '', $url);
|
||||
$url = str_replace('.txt', '', $url);
|
||||
$url = str_replace('index'. CONTENT_EXT, '', $url);
|
||||
$url = str_replace(CONTENT_EXT, '', $url);
|
||||
$pages[$key] = array(
|
||||
'title' => $page_meta['title'],
|
||||
'url' => $url
|
||||
|
|
Loading…
Reference in a new issue