diff --git a/changelog.txt b/changelog.txt
new file mode 100644
index 0000000..2186a97
--- /dev/null
+++ b/changelog.txt
@@ -0,0 +1,19 @@
+*** Pico Changelog ***
+
+2013.05.01 - version 0.4
+ * [New] Add get_pages() function for listing content
+ * [New] Added changelog.txt
+ * [Changed] Updated default theme
+ * [Changed] Updated documentation
+
+2013.04.27 - version 0.3
+ * [Fixed] get_config() function
+
+2013.04.26 - version 0.2
+ * [Changed] Updated Twig
+ * [Changed] Better checking for HTTPS
+ * [Fixed] Add 404 header to 404 page
+ * [Fixed] Case sensitive folder bug
+
+2012.04.04 - version 0.1
+ * Initial release
\ No newline at end of file
diff --git a/content/index.txt b/content/index.txt
index bb8e918..e9078eb 100644
--- a/content/index.txt
+++ b/content/index.txt
@@ -3,13 +3,11 @@ Title: Welcome
Description: This description will go in the meta description tag
*/
-Welcome to Pico
-===============
+## Welcome to Pico
Congratulations you have successfully installed [Pico](http://pico.dev7studios.com). Pico is a stupidly simple, blazing fast, flat file CMS.
-Creating Content
-----------------
+### 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.
@@ -33,8 +31,7 @@ and will be able to access it from the URL `http://yousite.com/sub/page`. Below
If a file cannot be found, the file `content/404.txt` will be shown.
-Text File Markup
-----------------
+### Text File Markup
Text files are marked up using [Markdown](http://daringfireball.net/projects/markdown/syntax). They can also contain regular HTML.
@@ -50,10 +47,9 @@ These values will be contained in the `{{ meta }}` variable in themes (see below
There are also certain variables that you can use in your text files:
-* %base_url% - The URL to your Pico site
+* %base_url% - The URL to your Pico site
-Themes
-------
+### Themes
You can create themes for your Pico installation and in the "themes" folder. Check out the default theme for an example of a theme. Pico uses
[Twig](http://twig.sensiolabs.org/documentation) for it's templating engine. You can select your theme by setting the `$config['theme']` variable
@@ -69,9 +65,15 @@ All themes must include an `index.html` file to define the HTML structure of the
* `{{ site_title }}` - Shortcut to the site title (defined in config.php)
* `{{ meta }}` - Contains the meta values from the current page (e.g. `{{ meta.title }}`, `{{ meta.description }}`, `{{ meta.robots }}`)
* `{{ content }}` - The content of the current page (after it has been processed through Markdown)
+* `{{ pages }}` - A collection of all the content in your site. Use it like:
-Config
-------
+
+
+### Config
You can override the default Pico settings (and add your own custom settings) by editing config.php in the root Pico directory. The config.php file
list all of the settings and their defaults. To override a setting simply uncomment it in config.php and set your custom value.
diff --git a/content/sub/index.txt b/content/sub/index.txt
index 1d9ce83..e2866b9 100644
--- a/content/sub/index.txt
+++ b/content/sub/index.txt
@@ -2,5 +2,10 @@
Title: Sub Page Index
*/
-This is a Sub Page Index
-========================
\ No newline at end of file
+## This is a Sub Page Index
+
+This is index.txt 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.
+
+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.
\ No newline at end of file
diff --git a/content/sub/page.txt b/content/sub/page.txt
index bcccd41..6cdfee7 100644
--- a/content/sub/page.txt
+++ b/content/sub/page.txt
@@ -2,5 +2,10 @@
Title: Sub Page
*/
-This is a Sub Page
-==================
\ No newline at end of file
+## This is a Sub Page
+
+This is page.txt 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.
+
+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.
\ No newline at end of file
diff --git a/lib/pico.php b/lib/pico.php
index ee68312..e6286f0 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.3
+ * @version 0.4
*/
class Pico {
@@ -46,6 +46,9 @@ class Pico {
$settings = $this->get_config();
$env = array('autoescape' => false);
if($settings['enable_cache']) $env['cache'] = CACHE_DIR;
+
+ // Get all the pages
+ $pages = $this->get_pages($settings['base_url']);
// Load the theme
Twig_Autoloader::register();
@@ -59,7 +62,8 @@ class Pico {
'theme_url' => $settings['base_url'] .'/'. basename(THEMES_DIR) .'/'. $settings['theme'],
'site_title' => $settings['site_title'],
'meta' => $meta,
- 'content' => $content
+ 'content' => $content,
+ 'pages' => $pages
));
}
@@ -126,6 +130,37 @@ class Pico {
return $config;
}
+
+ /**
+ * Get a list of pages
+ *
+ * @param string $base_url the base URL of the site
+ * @return array $pages an array of pages
+ */
+ function get_pages($base_url)
+ {
+ $pages = $this->glob_recursive(CONTENT_DIR .'*.txt');
+ foreach($pages as $key=>$page){
+ // Skip 404
+ if(basename($page) == '404.txt'){
+ unset($pages[$key]);
+ continue;
+ }
+
+ // Get title and format $page
+ $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);
+ $pages[$key] = array(
+ 'title' => $page_meta['title'],
+ 'url' => $url
+ );
+ }
+
+ return $pages;
+ }
/**
* Helper function to work out the base URL
@@ -156,6 +191,22 @@ class Pico {
preg_match("|^HTTP[S]?|is",$_SERVER['SERVER_PROTOCOL'],$m);
return strtolower($m[0]);
}
+
+ /**
+ * Helper function to make glob recursive
+ *
+ * @param string $pattern glob pattern
+ * @param int $flags glob flags
+ * @return array the matched files/directories
+ */
+ function glob_recursive($pattern, $flags = 0)
+ {
+ $files = glob($pattern, $flags);
+ foreach(glob(dirname($pattern).'/*', GLOB_ONLYDIR|GLOB_NOSORT) as $dir){
+ $files = array_merge($files, $this->glob_recursive($dir.'/'.basename($pattern), $flags));
+ }
+ return $files;
+ }
}
diff --git a/themes/default/index.html b/themes/default/index.html
index 7669cb1..37cd9ba 100644
--- a/themes/default/index.html
+++ b/themes/default/index.html
@@ -1,23 +1,45 @@
-
-
- {% if meta.title %}{{ meta.title }} | {% endif %}{{ site_title }}
- {% if meta.description %}{% endif %}
- {% if meta.robots %}{% endif %}
-
-
-
-
-
+
+
+ {% if meta.title %}{{ meta.title }} | {% endif %}{{ site_title }}
+{% if meta.description %}
+
+{% endif %}{% if meta.robots %}
+
+{% endif %}
+
+
+
+
+
- {{ content }}
+
+