From 8cebbb51f817a7e016c7905ec19c1999358a44f4 Mon Sep 17 00:00:00 2001 From: Gilbert Pellegrom Date: Wed, 1 May 2013 15:52:18 +0100 Subject: [PATCH] v0.4.1 [New] Added CONTENT_EXT global [Changed] Use .md files instead of .txt --- changelog.txt | 4 ++++ content/{404.txt => 404.md} | 0 content/{index.txt => index.md} | 20 ++++++++++---------- content/sub/{index.txt => index.md} | 2 +- content/sub/{page.txt => page.md} | 2 +- index.php | 1 + lib/pico.php | 16 ++++++++-------- 7 files changed, 25 insertions(+), 20 deletions(-) rename content/{404.txt => 404.md} (100%) rename content/{index.txt => index.md} (83%) rename content/sub/{index.txt => index.md} (95%) rename content/sub/{page.txt => page.md} (95%) diff --git a/changelog.txt b/changelog.txt index 2186a97..1f0187a 100644 --- a/changelog.txt +++ b/changelog.txt @@ -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 diff --git a/content/404.txt b/content/404.md similarity index 100% rename from content/404.txt rename to content/404.md diff --git a/content/index.txt b/content/index.md similarity index 83% rename from content/index.txt rename to content/index.md index e9078eb..0cdfb3b 100644 --- a/content/index.txt +++ b/content/index.md @@ -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: @@ -21,15 +21,15 @@ and will be able to access it from the URL `http://yousite.com/sub/page`. Below - - - - - + + + + +
Physical LocationURL
content/index.txt/
content/sub.txt/sub
content/sub/index.txt/sub (same as above)
content/sub/page.txt/sub/page
content/a/very/long/url.txt/a/very/long/url
content/index.md/
content/sub.md/sub
content/sub/index.md/sub (same as above)
content/sub/page.md/sub/page
content/a/very/long/url.md/a/very/long/url
-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 diff --git a/content/sub/index.txt b/content/sub/index.md similarity index 95% rename from content/sub/index.txt rename to content/sub/index.md index e2866b9..517e191 100644 --- a/content/sub/index.txt +++ b/content/sub/index.md @@ -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. diff --git a/content/sub/page.txt b/content/sub/page.md similarity index 95% rename from content/sub/page.txt rename to content/sub/page.md index 6cdfee7..2e2aebd 100644 --- a/content/sub/page.txt +++ b/content/sub/page.md @@ -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. diff --git a/index.php b/index.php index c5ed9e6..0058f14 100644 --- a/index.php +++ b/index.php @@ -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/'); diff --git a/lib/pico.php b/lib/pico.php index e6286f0..5a5d305 100644 --- a/lib/pico.php +++ b/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