title = islands
date = Oct 05 2011, 03:53:55 PM
+tags = writing quote
--
> Imagine that every man's mind is an island, surrounded by ocean. Each seems isolated, yet in reality all are linked by the bedrock from which they spring. If the ocean were to vanish, that would be the end of the islands. They would all be part of one continent, but their individuality would be gone.
title = childhoods end
date = Oct 05 2011, 03:17:57 PM
+tags = india quote
--
> The case of India is particularly instructive. The main difference between us and the British in India was that they had no real motives for going there—no conscious objectives, that is, except such trivial and temporary ones as trade or hostility to other European powers. They found themselves possessors of an empire before they knew what to do with it, and were never really happy until they had got rid of it again.
date = feb 20 2012
title = temple
+tags = photo
--
<a href="http://www.flickr.com/photos/quilime/6914577153/sizes/z/in/photostream/">
<img src="http://farm8.staticflickr.com/7053/6914577153_4c2b7d8a1a_z.jpg">
title = Water Is Life
date = Oct 23 2011 06:04:38 PM
-draft = 1
+tags = water photo
--
<a href="http://www.flickr.com/photos/quilime/6266458764/sizes/l/in/photostream/"><img src="http://farm7.staticflickr.com/6034/6266458764_6f71bd0a7e_z.jpg"></a>
title = mask
date = 2007-07-02
thumb = http://portfolio.quilime.com/2008/mask/thumb.png
+tags = mask painting
--
<img src="http://portfolio.quilime.com/2008/mask/mask.jpg" />
title = prism
date = 2007-08-23
thumb = http://portfolio.quilime.com/2008/prism/thumb.png
+tags = prism painting
--
<img src="http://portfolio.quilime.com/2008/prism/3.jpg" />
--- /dev/null
+{"entries":[{"config":{"date":"feb 20 2012","title":"temple","tags":"photo"},"title":"temple","filename":"temple","path":"\/Users\/gdunne\/_code\/plog\/content\/log\/temple","fileInfo":{},"timestamp":"1329724800","tags":["photo"],"content":"<p><a href=\"http:\/\/www.flickr.com\/photos\/quilime\/6914577153\/sizes\/z\/in\/photostream\/\">\n <img src=\"http:\/\/farm8.staticflickr.com\/7053\/6914577153_4c2b7d8a1a_z.jpg\">\n<\/a><\/p>\n","comments_enabled":false,"comments":{"comments":[],"comments_loc":"\/Users\/gdunne\/_code\/plogcomments\/\/Users\/gdunne\/_code\/plog\/content\/log\/temple\/","fileInfo":{},"_recaptcha_resp":null,"_recaptcha_error":null,"_comment_error":null},"cat":{"name":"og","url":"log\/"},"media":"media\/\/og\/temple\/","thumb":"media\/\/og\/temple\/thumb.png","url":"\/og\/temple"},{"config":{"title":"Water Is Life","date":"Oct 23 2011 06:04:38 PM","tags":"water photo"},"title":"Water Is Life","filename":"water_is_life","path":"\/Users\/gdunne\/_code\/plog\/content\/log\/water_is_life","fileInfo":{},"timestamp":"1319418278","tags":["water","photo"],"content":"<p><a href=\"http:\/\/www.flickr.com\/photos\/quilime\/6266458764\/sizes\/l\/in\/photostream\/\"><img src=\"http:\/\/farm7.staticflickr.com\/6034\/6266458764_6f71bd0a7e_z.jpg\"><\/a><\/p>\n\n<p>near Quotar Minar in Dadabari.<\/p>\n","comments_enabled":false,"comments":{"comments":[],"comments_loc":"\/Users\/gdunne\/_code\/plogcomments\/\/Users\/gdunne\/_code\/plog\/content\/log\/water_is_life\/","fileInfo":{},"_recaptcha_resp":null,"_recaptcha_error":null,"_comment_error":null},"cat":{"name":"og","url":"log\/"},"media":"media\/\/og\/water_is_life\/","thumb":"media\/\/og\/water_is_life\/thumb.png","url":"\/og\/water_is_life"},{"config":{"title":"islands","date":"Oct 05 2011, 03:53:55 PM","tags":"writing quote"},"title":"islands","filename":"islands","path":"\/Users\/gdunne\/_code\/plog\/content\/log\/islands","fileInfo":{},"timestamp":"1317855235","tags":["writing","quote"],"content":"<blockquote>\n <p>Imagine that every man's mind is an island, surrounded by ocean. Each seems isolated, yet in reality all are linked by the bedrock from which they spring. If the ocean were to vanish, that would be the end of the islands. They would all be part of one continent, but their individuality would be gone.<\/p>\n \n <p>—\"The Inspector\" Overlord. <u>Childhoods End<\/u>, Arthur C. Clark. p.176<\/p>\n<\/blockquote>\n","comments_enabled":false,"comments":{"comments":[],"comments_loc":"\/Users\/gdunne\/_code\/plogcomments\/\/Users\/gdunne\/_code\/plog\/content\/log\/islands\/","fileInfo":{},"_recaptcha_resp":null,"_recaptcha_error":null,"_comment_error":null},"cat":{"name":"og","url":"log\/"},"media":"media\/\/og\/islands\/","thumb":"media\/\/og\/islands\/thumb.png","url":"\/og\/islands"},{"config":{"title":"childhoods end","date":"Oct 05 2011, 03:17:57 PM","tags":"india quote"},"title":"childhoods end","filename":"overlords","path":"\/Users\/gdunne\/_code\/plog\/content\/log\/overlords","fileInfo":{},"timestamp":"1317853077","tags":["india","quote"],"content":"<blockquote>\n <p>The case of India is particularly instructive. The main difference between us and the British in India was that they had no real motives for going there—no conscious objectives, that is, except such trivial and temporary ones as trade or hostility to other European powers. They found themselves possessors of an empire before they knew what to do with it, and were never really happy until they had got rid of it again.<\/p>\n \n <p>—\"The Inspector\" Overlord. <u>Childhoods End<\/u>, Arthur C. Clark. p.161<\/p>\n<\/blockquote>\n","comments_enabled":false,"comments":{"comments":[],"comments_loc":"\/Users\/gdunne\/_code\/plogcomments\/\/Users\/gdunne\/_code\/plog\/content\/log\/overlords\/","fileInfo":{},"_recaptcha_resp":null,"_recaptcha_error":null,"_comment_error":null},"cat":{"name":"og","url":"log\/"},"media":"media\/\/og\/overlords\/","thumb":"media\/\/og\/overlords\/thumb.png","url":"\/og\/overlords"},{"config":{"title":"prism","date":"2007-08-23","thumb":"http:\/\/portfolio.quilime.com\/2008\/prism\/thumb.png","tags":"prism painting"},"title":"prism","filename":"prism","path":"\/Users\/gdunne\/_code\/plog\/content\/projects\/prism","fileInfo":{},"timestamp":"1187852400","tags":["prism","painting"],"content":"<p><img src=\"http:\/\/portfolio.quilime.com\/2008\/prism\/3.jpg\" \/><\/p>\n\n<p>oil on canvas. 4' x 3'<\/p>\n","comments_enabled":false,"comments":{"comments":[],"comments_loc":"\/Users\/gdunne\/_code\/plogcomments\/\/Users\/gdunne\/_code\/plog\/content\/projects\/prism\/","fileInfo":{},"_recaptcha_resp":null,"_recaptcha_error":null,"_comment_error":null},"cat":{"name":"rojects","url":"projects\/"},"media":"media\/\/rojects\/prism\/","thumb":"http:\/\/portfolio.quilime.com\/2008\/prism\/thumb.png","url":"\/rojects\/prism"},{"config":{"title":"mask","date":"2007-07-02","thumb":"http:\/\/portfolio.quilime.com\/2008\/mask\/thumb.png","tags":"mask painting"},"title":"mask","filename":"mask","path":"\/Users\/gdunne\/_code\/plog\/content\/projects\/mask","fileInfo":{},"timestamp":"1183359600","tags":["mask","painting"],"content":"<p><img src=\"http:\/\/portfolio.quilime.com\/2008\/mask\/mask.jpg\" \/><\/p>\n\n<p>graphite on plywood. 12\" x 12\"<\/p>\n","comments_enabled":false,"comments":{"comments":[],"comments_loc":"\/Users\/gdunne\/_code\/plogcomments\/\/Users\/gdunne\/_code\/plog\/content\/projects\/mask\/","fileInfo":{},"_recaptcha_resp":null,"_recaptcha_error":null,"_comment_error":null},"cat":{"name":"rojects","url":"projects\/"},"media":"media\/\/rojects\/mask\/","thumb":"http:\/\/portfolio.quilime.com\/2008\/mask\/thumb.png","url":"\/rojects\/mask"}]}
\ No newline at end of file
--- /dev/null
+{"entries":[{"config":{"date":"feb 20 2012","title":"temple","tags":"photo"},"title":"temple","filename":"temple","path":"\/Users\/gdunne\/_code\/plog\/content\/log\/temple","fileInfo":{},"timestamp":"1329724800","tags":["photo"],"content":"<p><a href=\"http:\/\/www.flickr.com\/photos\/quilime\/6914577153\/sizes\/z\/in\/photostream\/\">\n <img src=\"http:\/\/farm8.staticflickr.com\/7053\/6914577153_4c2b7d8a1a_z.jpg\">\n<\/a><\/p>\n","comments_enabled":false,"comments":{"comments":[],"comments_loc":"\/Users\/gdunne\/_code\/plogcomments\/\/Users\/gdunne\/_code\/plog\/content\/log\/temple\/","fileInfo":{},"_recaptcha_resp":null,"_recaptcha_error":null,"_comment_error":null},"cat":{"name":"log","url":"\/log\/"},"media":"media\/\/log\/temple\/","thumb":"media\/\/log\/temple\/thumb.png","url":"\/log\/temple"},{"config":{"title":"Water Is Life","date":"Oct 23 2011 06:04:38 PM","tags":"water photo"},"title":"Water Is Life","filename":"water_is_life","path":"\/Users\/gdunne\/_code\/plog\/content\/log\/water_is_life","fileInfo":{},"timestamp":"1319418278","tags":["water","photo"],"content":"<p><a href=\"http:\/\/www.flickr.com\/photos\/quilime\/6266458764\/sizes\/l\/in\/photostream\/\"><img src=\"http:\/\/farm7.staticflickr.com\/6034\/6266458764_6f71bd0a7e_z.jpg\"><\/a><\/p>\n\n<p>near Quotar Minar in Dadabari.<\/p>\n","comments_enabled":false,"comments":{"comments":[],"comments_loc":"\/Users\/gdunne\/_code\/plogcomments\/\/Users\/gdunne\/_code\/plog\/content\/log\/water_is_life\/","fileInfo":{},"_recaptcha_resp":null,"_recaptcha_error":null,"_comment_error":null},"cat":{"name":"log","url":"\/log\/"},"media":"media\/\/log\/water_is_life\/","thumb":"media\/\/log\/water_is_life\/thumb.png","url":"\/log\/water_is_life"},{"config":{"title":"islands","date":"Oct 05 2011, 03:53:55 PM","tags":"writing quote"},"title":"islands","filename":"islands","path":"\/Users\/gdunne\/_code\/plog\/content\/log\/islands","fileInfo":{},"timestamp":"1317855235","tags":["writing","quote"],"content":"<blockquote>\n <p>Imagine that every man's mind is an island, surrounded by ocean. Each seems isolated, yet in reality all are linked by the bedrock from which they spring. If the ocean were to vanish, that would be the end of the islands. They would all be part of one continent, but their individuality would be gone.<\/p>\n \n <p>—\"The Inspector\" Overlord. <u>Childhoods End<\/u>, Arthur C. Clark. p.176<\/p>\n<\/blockquote>\n","comments_enabled":false,"comments":{"comments":[],"comments_loc":"\/Users\/gdunne\/_code\/plogcomments\/\/Users\/gdunne\/_code\/plog\/content\/log\/islands\/","fileInfo":{},"_recaptcha_resp":null,"_recaptcha_error":null,"_comment_error":null},"cat":{"name":"log","url":"\/log\/"},"media":"media\/\/log\/islands\/","thumb":"media\/\/log\/islands\/thumb.png","url":"\/log\/islands"},{"config":{"title":"childhoods end","date":"Oct 05 2011, 03:17:57 PM","tags":"india quote"},"title":"childhoods end","filename":"overlords","path":"\/Users\/gdunne\/_code\/plog\/content\/log\/overlords","fileInfo":{},"timestamp":"1317853077","tags":["india","quote"],"content":"<blockquote>\n <p>The case of India is particularly instructive. The main difference between us and the British in India was that they had no real motives for going there—no conscious objectives, that is, except such trivial and temporary ones as trade or hostility to other European powers. They found themselves possessors of an empire before they knew what to do with it, and were never really happy until they had got rid of it again.<\/p>\n \n <p>—\"The Inspector\" Overlord. <u>Childhoods End<\/u>, Arthur C. Clark. p.161<\/p>\n<\/blockquote>\n","comments_enabled":false,"comments":{"comments":[],"comments_loc":"\/Users\/gdunne\/_code\/plogcomments\/\/Users\/gdunne\/_code\/plog\/content\/log\/overlords\/","fileInfo":{},"_recaptcha_resp":null,"_recaptcha_error":null,"_comment_error":null},"cat":{"name":"log","url":"\/log\/"},"media":"media\/\/log\/overlords\/","thumb":"media\/\/log\/overlords\/thumb.png","url":"\/log\/overlords"}]}
\ No newline at end of file
--- /dev/null
+{"tags":{"photo":2,"water":1,"writing":1,"quote":2,"india":1}}
\ No newline at end of file
--- /dev/null
+{"entries":[{"config":{"title":"prism","date":"2007-08-23","thumb":"http:\/\/portfolio.quilime.com\/2008\/prism\/thumb.png","tags":"prism painting"},"title":"prism","filename":"prism","path":"\/Users\/gdunne\/_code\/plog\/content\/projects\/prism","fileInfo":{},"timestamp":"1187852400","tags":["prism","painting"],"content":"<p><img src=\"http:\/\/portfolio.quilime.com\/2008\/prism\/3.jpg\" \/><\/p>\n\n<p>oil on canvas. 4' x 3'<\/p>\n","comments_enabled":false,"comments":{"comments":[],"comments_loc":"\/Users\/gdunne\/_code\/plogcomments\/\/Users\/gdunne\/_code\/plog\/content\/projects\/prism\/","fileInfo":{},"_recaptcha_resp":null,"_recaptcha_error":null,"_comment_error":null},"cat":{"name":"projects","url":"\/projects\/"},"media":"media\/\/projects\/prism\/","thumb":"http:\/\/portfolio.quilime.com\/2008\/prism\/thumb.png","url":"\/projects\/prism"},{"config":{"title":"mask","date":"2007-07-02","thumb":"http:\/\/portfolio.quilime.com\/2008\/mask\/thumb.png","tags":"mask painting"},"title":"mask","filename":"mask","path":"\/Users\/gdunne\/_code\/plog\/content\/projects\/mask","fileInfo":{},"timestamp":"1183359600","tags":["mask","painting"],"content":"<p><img src=\"http:\/\/portfolio.quilime.com\/2008\/mask\/mask.jpg\" \/><\/p>\n\n<p>graphite on plywood. 12\" x 12\"<\/p>\n","comments_enabled":false,"comments":{"comments":[],"comments_loc":"\/Users\/gdunne\/_code\/plogcomments\/\/Users\/gdunne\/_code\/plog\/content\/projects\/mask\/","fileInfo":{},"_recaptcha_resp":null,"_recaptcha_error":null,"_comment_error":null},"cat":{"name":"projects","url":"\/projects\/"},"media":"media\/\/projects\/mask\/","thumb":"http:\/\/portfolio.quilime.com\/2008\/mask\/thumb.png","url":"\/projects\/mask"}]}
\ No newline at end of file
--- /dev/null
+{"tags":{"prism":1,"painting":2,"mask":1}}
\ No newline at end of file
--- /dev/null
+{"tags":{"photo":2,"water":1,"writing":1,"quote":2,"india":1,"prism":1,"painting":2,"mask":1}}
\ No newline at end of file
--- /dev/null
+{"tags":{"photo":2,"water":1,"writing":1,"quote":2,"india":1,"prism":1,"painting":2,"mask":1}}
\ No newline at end of file
config_file = config
data_file = data.json
+tags_file = tags.json
fwrite($fp, json_encode(array( 'entries' => $entries )));
fclose($fp);
if (!file_exists( $data_file )) {
- throw new Exception('Error creating tags json. Permissions?');
+ throw new Exception('Error creating data json. Permissions?');
}
}
}
}
+/**
+ * get tags
+ */
+function get_tags($path = "", $args = array() )
+{
+
+ $data_path = rtrim(LOCAL_ROOT . '/' . DATA_DIR . '/' . CONTENT_DIR . '/' . $path, '/');
+ $data_file = rtrim($data_path . '/' . TAGS_FILE, '/');
+
+ if (DEV || !file_exists($data_file)) {
+
+ $create_datafile = true;
+
+ $entries = get_entries($path, $args);
+ $tags = array();
+
+ foreach($entries as $entry) {
+ $entry_tags = isset($entry->tags) && is_array($entry->tags) ? $entry->tags : array();
+ $tags = array_merge($tags, $entry_tags);
+ }
+
+ $tags = array_count_values($tags);
+
+
+ if ($create_datafile) {
+ if (!is_dir($data_path)) {
+ if (!mkdir($data_path, 0777, true)) {
+ throw new Exception('Error making data folder in get_tags(). Permissions?');
+ }
+ }
+ $fp = fopen( $data_file, 'w');
+ fwrite($fp, json_encode(array( 'tags' => $tags )));
+ fclose($fp);
+ if (!file_exists( $data_file )) {
+ throw new Exception('Error creating tags json in get_tags(). Permissions?');
+ }
+ }
+
+
+ // $fp = fopen( $data_file, 'w');
+ // fwrite($fp, json_encode(array( 'tags' => $tags )));
+ // fclose($fp);
+ // if (!file_exists( $data_file)) {
+ // throw new Exception('Error creating tags.json. Permissions?');
+ // }
+ }
+
+ $json = json_decode(file_get_contents($data_file));
+ return (array) $json->tags;
+}
+
+
/**
* @param splFileInfo SPLFileInfo Object
* @param page default is false
define ('DATA_DIR', $_cfg['data']);
define ('MEDIA_DIR', $_cfg['media']);
define ('DATA_FILE', $_cfg['data_file']);
+define ('TAGS_FILE', $_cfg['tags_file']);
define ('TEMPLATE_DIR', $_cfg['templates']);
define ('PAGE_DIR', $_cfg['pages']);
define ('CONFIG_DELIMITER', $_cfg['config_delim']);
function test_GettingEntriesArray() {
$entries = get_entries('/');
$this->assertTrue(is_array($entries));
- }
-
- function test_EntryFolderNotExist() {
$this->expectException( new Exception("Directory does not exist") );
get_entries('sdfs');
}
$this->assertTrue(is_array($dirs));
}
+ function test_GettingTagsArray() {
+ $tags = get_tags();
+ $this->assertTrue(is_array($tags));
+ $tags = get_tags('log/');
+ $this->assertTrue(is_array($tags));
+ $tags = get_tags('projects/');
+ $this->assertTrue(is_array($tags));
+ $this->expectException( new Exception("Directory does not exist") );
+ $tags = get_tags('asdf/');
+ }
+
function test_getEntryIsFileObj() {
$this->assertIsA(get_entry('/projects/prism'), 'stdClass');
}
--- /dev/null
+title = tag
+--
+
+<? if (isset($tag)): ?>
+
+<? $entries = get_entries('/', $args = array('tag' => $tag)); ?>
+<? foreach($entries as $entry): ?>
+<?
+if (isset($entry->content_short))
+$entry->content = $entry->content_short .
+'<br /><a class="more" href="' . $entry->url . '">more →</a><br /><br />';
+?>
+
+<div class="entry">
+<? $this->include_template('entry.html.tpl', array('entry' => $entry)); ?>
+</div>
+
+<? endforeach; ?>
+
+<? else: ?>
+
+
+<ul class="tags">
+<? $tags = get_tags('/'); ksort($tags); ?>
+<? foreach($tags as $tag => $count) : ?>
+<li><a href="/tag/<?=$tag?>"><?=$tag?></a> × <?=$count?></li>
+<? endforeach; ?>
+</ul>
+
+<? endif; ?>