]> git.quilime.com - plog.git/commitdiff
Considering moving static pages to content so they're cached.
authorGabriel Dunne <gdunne@quilime.com>
Sat, 8 Sep 2012 20:29:27 +0000 (13:29 -0700)
committerGabriel Dunne <gdunne@quilime.com>
Sat, 8 Sep 2012 20:29:27 +0000 (13:29 -0700)
13 files changed:
content/studio/config
content/tag [new file with mode: 0644]
css/style.css
data/content/data.json
index.php
lib/data.php
lib/init.php
lib/model.php
pages/contact
templates/default.html.tpl
templates/edit.html.tpl
templates/entry.html.tpl
templates/nav.html.tpl

index 6961c44ced59d79cb4e6bd5489619c8bee1c6c71..8401ad64da91879905370fa96213ec69a9c61a9f 100755 (executable)
@@ -2,3 +2,4 @@ title = studio
 --\r
 Studio\r
 \r
+lots to go here.
\ No newline at end of file
diff --git a/content/tag b/content/tag
new file mode 100644 (file)
index 0000000..11a8106
--- /dev/null
@@ -0,0 +1,4 @@
+title = tag
+--
+
+yep.
index 603543bababc6a51a90833e3216c17f73871f33f..b3b8c55efe974a389b240faf541580a7ee2955b0 100644 (file)
@@ -88,9 +88,12 @@ table, td, tr {
 }
 
 
+.edit,
+.edit textarea {
+  background:#111;
+}
 .edit {
   box-sizing: border-box;
-  background:#005;
   position:fixed;
   width:100%;
   bottom:0;
@@ -102,7 +105,6 @@ table, td, tr {
   }
   .edit textarea {
     font-family: monaco, monospace;
-    background:#005;
     padding:5px;
     border:0;
     width:100%;
@@ -110,6 +112,9 @@ table, td, tr {
     color:#eee;
     height:200px;
   }
+  textarea:focus {
+    outline: none;
+  }
 .edit_button {
     /*
     position:fixed;
index 6f073b554453a1c1b76cf6093cdda358ceeeea38..c4b484d6485a31118d046e2bdb52e905786c888b 100644 (file)
@@ -1 +1 @@
-{"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","edit_url":"\/edit\/\/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","edit_url":"\/edit\/\/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>&mdash;\"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","edit_url":"\/edit\/\/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\u2014no 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>\u2014\"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","edit_url":"\/edit\/\/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","edit_url":"\/edit\/\/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","edit_url":"\/edit\/\/rojects\/mask"}]}
\ No newline at end of file
+{"entries":[{"config":{"title":"tag","date":null},"title":"tag","filename":"tag","path":"\/Users\/gdunne\/_code\/plog\/content\/tag","fileInfo":{},"timestamp":1347134885,"tags":null,"content":"<p>yep.<\/p>\n","comments_enabled":false,"comments":{"comments":[],"comments_loc":"\/Users\/gdunne\/_code\/plogcomments\/\/Users\/gdunne\/_code\/plog\/content\/tag\/","fileInfo":{},"_recaptcha_resp":null,"_recaptcha_error":null,"_comment_error":null},"cat":{"name":false,"url":"\/"},"media":"media\/\/tag\/","thumb":"media\/\/tag\/thumb.png","url":"\/tag","edit_url":"\/edit\/\/tag"}]}
\ No newline at end of file
index 4325e40786cb80ab633ee58f2578417ab272a6fd..32f5b87599af8689cb2569c234d3e8de614bec57 100644 (file)
--- a/index.php
+++ b/index.php
@@ -14,7 +14,6 @@ if ($m->is_multiple())
 if ($m->is_single() || $m->is_page() || $m->is_multiple())
     $v->assign('entry', $m->entry);
 
-$v->assign('is_edit', $m->is_edit);
 
 header("Content-Type: {$m->response_mime_type}; charset=UTF-8");
 $v->render( $m->template, $m->response_format );
index 24ec42f146de6ee907afac45d65190e8e2a1e51e..aa53b3a28250215a43d26dfb370cc7130de01e07 100644 (file)
@@ -120,10 +120,11 @@ function get_dirs( $path = "", $args = array())
             if (substr($info->getFilename(), 0, 1) == '.') 
                 continue;
             $d = array();
-            $d['url'] = WEB_ROOT . str_replace($path, "",  $info->getRealPath());
+            $d['url'] = rtrim(WEB_ROOT . str_replace($path, "",  $info->getRealPath()), "/") . "/";
             if (!CLEAN_URLS)
                $d['url'] = WEB_ROOT . '?p=' . $d['url'];
             $d['name'] = str_replace($path, "",  $info->getRealPath());
+            $d['title'] = $d['name'];
                        $dirs[] = (object) $d;
                }
        }
@@ -242,14 +243,14 @@ function parse_entry($fileInfo, $page = false)
     $file['comments_enabled'] = isset($f['config']['comments']) && $f['config']['comments'];
     $file['comments'] = new Comments($fileInfo);  
 
-    $cat = clean_slashes(str_replace(LOCAL_ROOT . '/' . CONTENT_DIR, "", $fileInfo->getPath()));
+    $cat = clean_slashes(str_replace(rtrim(LOCAL_ROOT . '/' . CONTENT_DIR, "/"), "", $fileInfo->getPath()));
     
     $file['cat'] = $page ? null : array('name' => substr($cat, 1), 'url' => $cat.'/' );
 
     $file['path'] = $fileInfo->getRealPath();
     $file['media'] = MEDIA_DIR . '/' . ($page ? '' : substr($file['cat']['url'],1)) . $fileInfo->getFilename() . '/';
     $file['thumb'] = isset($file['config']['thumb']) ? $file['config']['thumb'] : MEDIA_DIR . '/' . substr($file['cat']['url'],1) . $fileInfo->getFilename() . '/thumb.png';
-    $file['url'] = WEB_ROOT . ($page ? '' : substr($file['cat']['url'],1)) . $fileInfo->getFilename();
+    $file['url'] = WEB_ROOT . ($page ? '' : substr($file['cat']['url'], 1)) . $fileInfo->getFilename();
     $file['edit_url'] = WEB_ROOT . 'edit/' . $file['url'];
     $file['cat'] = (object) $file['cat'];
     $file['config'] = (object) $file['config'];
index b071f3fb1782ac17af118a6e9fc5e133cbd8d9d1..7f6f0cef23e968b80d0d73c6b25179e41a00eb27 100644 (file)
@@ -8,9 +8,17 @@
  */
 
 
-# error reporting (turn this off for production)
-error_reporting(E_ALL);
-ini_set("display_errors", 1);
+$_INI_LOC = 'lib/config.ini';
+
+
+
+# recaptcha for comments
+//require_once 'recaptchalib.php';
+// Get a key from https://www.google.com/recaptcha/admin/create
+//$captcha_publickey  = "6Lek-MkSAAAAAAZknQQGSx9DiCqm_wAiFGytc37d";
+//$captcha_privatekey = "6Lek-MkSAAAAAK4FAaPKO0Cwp-iHa0OcUaqipee4";
+
+
 
 # timezone
 putenv("TZ=America/Los_Angeles");
@@ -26,7 +34,7 @@ if (!is_dir(LOCAL_ROOT)) {
 
 define ('LOG_FILE', LOCAL_ROOT . '/plog.log');
 
-$_cfg = parse_ini_file('lib/config.ini');
+$_cfg = parse_ini_file($_INI_LOC);
 define ('WEB_ROOT', $_cfg['web_root']);
 define ('CLEAN_URLS', $_cfg['clean_urls']);
 define ('LIMIT', $_cfg['limit']);
@@ -43,19 +51,17 @@ define ('CONFIG_DELIMITER', $_cfg['config_delim']);
 define ('CONFIG_FILE', $_cfg['config_file']);
 define ('MORE_DELIM', $_cfg['more_delim']);
 define ('TITLE_DELIMITER', $_cfg['title_delim']);
-define ('ENTRY_DATE_FORMAT', $_cfg['date_format']);
+define ('DATE_FORMAT', $_cfg['date_format']);
 define ('DEV', $_cfg['dev']);
 define ('EDIT', $_cfg['edit']);
 $_FILE_IGNORES = $_cfg['file_ignores'];
 
 
-
-
-# recaptcha for comments
-//require_once 'recaptchalib.php';
-// Get a key from https://www.google.com/recaptcha/admin/create
-//$captcha_publickey  = "6Lek-MkSAAAAAAZknQQGSx9DiCqm_wAiFGytc37d";
-//$captcha_privatekey = "6Lek-MkSAAAAAK4FAaPKO0Cwp-iHa0OcUaqipee4";
+# error reporting (turn this off for production)
+if (DEV) {
+    error_reporting(E_ALL);
+    ini_set("display_errors", 1);
+}
 
 
 
index d9524417b03872ba381f675d225bc955d5a45b00..6baedc24bce8150141af627edb0c1a6ad38056bd 100644 (file)
@@ -20,18 +20,10 @@ class Model
        function __construct( $req )
        {
                $this->request = $req;
-
-               // TODO: clean request to make sure there's no ../'s
-
                if (EDIT) {
-                       $this->is_edit = strpos($this->request['path'], 'edit/') !== false ? true : false;
-                       $this->request['dirname'] = str_replace('edit/', '', $this->request['dirname']);
-                       $this->request['path'] = str_replace('edit/', '', $this->request['path']);
                        if ($_SERVER['REQUEST_METHOD'] == 'POST') 
                                $this->process_edit_post_request();
                }
-
-
                list($this->response_format, $this->response_mime_type) = parse_format($this->request['extension']);    
                $this->template = 'default.' . $this->response_format . '.tpl';
                $this->parse_request( $this->request );
@@ -103,7 +95,7 @@ class Model
        }       
 
        function process_edit_post_request() {
-               if ($this->is_edit && isset($_POST['edited_file_contents'])) {
+               if (EDIT && isset($_POST['edited_file_contents'])) {
                    try {
                        if (!is_writable( $this->get_filename() )) {
                            throw new Exception('Error editing file. Permissions?');
index 3997433c6367d27f885d6fd093d153f8d83dd764..8ce9bca85d2c0395af6dee0dc857bd13fd3f5aac 100755 (executable)
@@ -1,35 +1,30 @@
---
-
-Gabriel Dunne  
-1242 Market St
-Floor 2  
-San Francisco, CA USA 94102  
-
-studio at gabrieldunne dot com   
-
-\+ 1 415 493 8496
-
-<br />
-
-<form>
-
-<p>
-<lable>name</label><br />
-<input type="text" name="name">
-</p>
-
-<p>
-<lable>email</label><br />
-<input type="text" name="email">
-</p>
-
-<p>
-<lable>message</label><br />
-<textarea style="width:250px;height:100px;"></textarea>
-</p>
-
-<p>
-<input type="submit" value="send">
-</p>
-
-</form>
+--\r
+\r
+Gabriel Dunne  \r
+1242 Market St\r
+Floor 2  \r
+San Francisco, CA USA 94102  \r
+\r
+studio at gabrieldunne dot com   \r
+\r
+\+ 1 415 493 8496  \r
+\r
+<br />\r
+\r
+<form>\r
+\r
+<p>\r
+<lable>name</label><br />\r
+<input type="text" name="name">\r
+</p>\r
+\r
+<p>\r
+<lable>email</label><br />\r
+<input type="text" name="email">\r
+</p>\r
+\r
+<p>\r
+<lable>message</label><br />\r
+<textarea style="width:250px;height:100px;"></textarea>\r
+\r
+\r
index 7281930a0e130b506f374a8ba30e810494160b05..35f9b302d4dc593fcee1e4038a03e730f882847e 100644 (file)
 
     <? if (isset($entry->content)): ?>
         <? eval('?>' . $entry->content); ?>
-
-        <? if (EDIT): ?>
-            <?=$this->edit_button;?>
-        <? endif; ?>
-
     <? endif; ?>
 
     <? $entry = 0; foreach($entries as $entry): ?>
index 751ccde304f27e594c7902a803bb38a5ce46fce0..86492384a87673bbb1bb2634830bb6196b611b68 100644 (file)
@@ -1,9 +1,12 @@
+
+<? if(isset($entry->fileInfo) && $f = file_get_contents($entry->fileInfo)) : ?>
 <div class="edit">
     <form action="" method="POST">
         <div class="ctrl">
             <input type="button" onClick="window.location = '<?=$entry->url?>'"value="cancel">
             <input type="submit" value="save">
         </div>
-        <textarea name="edited_file_contents"><?=file_get_contents($entry->fileInfo);?></textarea>
+        <textarea name="edited_file_contents"><?=$f;?></textarea>
     </form>
 </div>
+<? endif; ?>
index d21b21055b83d5a135ccf22cb863a17e4de18795..608692e72ffaa4d6f885f6c09f940e0575e28c2f 100644 (file)
        <? endif; ?>
 </div>
 
-<? 
-/*
-
-       <div class="metadata">
-               <a href="/<?=$entry['url']?>">#</a>
-               <br />
-               <span title="<?=get_relative_time($entry['timestamp']);?>"><?=date("F d, Y", $entry['timestamp'])?></span> in
-               <a href="/<?=$entry['cat']['url'];?>">/<?=$entry['cat']['url'];?></a><? if ($entry['tags']) echo '<br/>' . implode(', ', $entry['tags']); ?>
-       </div> 
-*/
-?>
-
-<? if (isset($single) && $single) : ?>
+<? if (!empty($single)) : ?>
        <div class="arrow" title="<?=$entry->cat->name?>">
                <a href="<?=$entry->cat->url?>">&larr;</a>
        </div>
 <? 
 if (isset($entry->is_single) && $entry->is_single && $entry->comments_enabled)
        $this->include_template('comments.html.tpl', array('entry' => $entry));
-?>     
-
-
-<? if (EDIT) : ?>
-<a class="edit_button" href="<?=WEB_ROOT?>edit<?=$entry->cat->url.$entry->filename?>">edit</a>
-<? endif; ?>
-
+?>
 
 </div>
 
index 95eb2b57e2db6c3f69999ef0a66e53cf0a023e78..27a45b5eab1ccf2f2fa7c421383b85108a4258a0 100644 (file)
@@ -4,6 +4,17 @@
 
     <li class="spacer">&nbsp;</li>    
 
+    <? $e = get_entries('', $args = array('recursive' => false) ); ?>
+    <? foreach($e as $dir) : 
+    // echo '<pre>';
+    // print_r($e);
+    ?>
+    <li><a href="<?=$dir->url?>"><?=$dir->title?></a></li>
+    <? endforeach; ?>    
+
+
+
+
     <? $dirs = get_dirs('', $args = array('recursive' => false) ); ?>
     <? foreach($dirs as $dir) : ?>
     <li><a href="<?=$dir->url?>"><?=$dir->name?></a></li>