]> git.quilime.com - plog.git/commitdiff
Getting up to speed with new changes.
authorGabriel Dunne <gdunne@quilime.com>
Mon, 3 Sep 2012 23:01:11 +0000 (16:01 -0700)
committerGabriel Dunne <gdunne@quilime.com>
Mon, 3 Sep 2012 23:01:11 +0000 (16:01 -0700)
12 files changed:
content/projects/config
css/style.css
lib/config.ini
lib/data.php
lib/init.php
lib/model.php
pages/agg [deleted file]
templates/agg.html.tpl [deleted file]
templates/entry.html.tpl
templates/projects.html.tpl
templates/single.html.tpl
test.php

index 0ceefdf63227632d46c74d68173ba5a603712fa3..b7c6b35bf778c07b7a2773a0b30b77da5a95dc16 100644 (file)
@@ -1 +1,4 @@
 template = projects
+title = projects
+--
+
index 39be341975cd7a1ffd9e19bc5ff827f99dd02944..3aae4aae049199fd1a827baa8e8e07fe13a801fe 100644 (file)
@@ -17,7 +17,6 @@ a {
   a.mute {
   text-decoration: none ! important; }
   a:hover, a.mute:hover {
-    border: medium none;
     color: #0000FF;
     text-decoration: underline; }
 
@@ -170,9 +169,7 @@ table, td, tr {
 .thumb {
   width:100px;
   height:100px;
-  border:1px dotted #000;
   overflow:hidden;
-
 }
 
 
index a93354d4ea49c3f61bb67d68e8d28072ce54c11d..0e5b84af544eb550264f53ea4397565a6c6e77bb 100644 (file)
@@ -15,6 +15,7 @@ content     = content/
 comments    = comments/
 templates   = templates/
 pages       = pages/
+media       = media/
 
 config_file = config
 data_file   = data.json
index ad26ae50af8c70110eaf07272852f3014acddc78..87fb90a38223369c9edde3a383e15e6cf833da1c 100644 (file)
@@ -41,6 +41,9 @@ function get_entries( $path = "", $args = array() )
         if (isset($dir_iterator)) {
         foreach ($dir_iterator as $file => $info) {
             if (!$info->isDir() && $info->getFilename() != CONFIG_FILE) {
+                // dot files
+                if (substr($info->getFilename(), 0, 1) == '.') 
+                    continue;
                 $entry = parse_entry($info);
                 if (!isset($tag)) {
                     $entries[] = $entry;
@@ -62,20 +65,16 @@ function get_entries( $path = "", $args = array() )
         }
 
         if ($create_datafile) {
-            try {
-                if (!is_dir($data_path)) {
-                    if (!mkdir($data_path, 0777, true)) {
-                        throw new Exception('Error making data folder. Permissions?');
-                    }
+            if (!is_dir($data_path)) {
+                if (!mkdir($data_path, 0777, true)) {
+                    throw new Exception('Error making data folder. Permissions?');
                 }
-                $fp = fopen( $data_file, 'w');
-                fwrite($fp, json_encode(array( 'entries' => $entries )));
-                fclose($fp);
-                if (!file_exists( $data_file )) {
-                    throw new Exception('Error creating tags json. Permissions?');
-                }
-            } catch (Exception $e) {
-                echo 'Caught exception: ',  $e->getMessage(), "\n";
+            }
+            $fp = fopen( $data_file, 'w');
+            fwrite($fp, json_encode(array( 'entries' => $entries )));
+            fclose($fp);
+            if (!file_exists( $data_file )) {
+                throw new Exception('Error creating tags json. Permissions?');
             }
         }
     }
@@ -103,26 +102,22 @@ function get_dirs( $path = "", $args = array())
        $path = $local_content . $path;
        $path = str_replace("//", "/", $path);
 
-
-       try {
-               if (!is_dir($path)) {
-                       throw new Exception("no such file or directory: $path", 1);
-               }
-               if ($recursive) {
-                       $iterator = new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::KEY_AS_PATHNAME);
-                       $dir_iterator = new RecursiveIteratorIterator($iterator, RecursiveIteratorIterator::SELF_FIRST);
-               }
-               else {
-                       $dir_iterator = new DirectoryIterator($path);
-               }
-       } catch (Exception $e) {
-               echo 'Caught exception: ',  $e->getMessage(), "\n";
+       if (!is_dir($path)) {
+               throw new Exception("no such file or directory: $path", 1);
+       }
+       if ($recursive) {
+               $iterator = new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::KEY_AS_PATHNAME);
+               $dir_iterator = new RecursiveIteratorIterator($iterator, RecursiveIteratorIterator::SELF_FIRST);
+       }
+       else {
+               $dir_iterator = new DirectoryIterator($path);
        }
+
        $dirs = array();
        foreach ($dir_iterator as $dir => $info) {
                if ($info->isDir() && $info->getFilename() != '.' && $info->getFilename() != '..') {
             $d = array();
-            $d['url'] = str_replace($path, "",  $info->getRealPath());
+            $d['url'] = WEB_ROOT . str_replace($path, "",  $info->getRealPath());
             if (!CLEAN_URLS)
                $d['url'] = WEB_ROOT . '?p=' . $d['url'];
             $d['name'] = str_replace($path, "",  $info->getRealPath());
@@ -180,47 +175,72 @@ function parse_entry($fileInfo, $page = false)
                $content .= $line;
        }
 
-       $f = array();
-       try {
-               $f['config'] = parse_ini_string($config);
-               //if (!$f['config']) {
-                       //echo $config;
-                       //throw new Exception('bad ini format');
-               //}
-       }
-       catch (Exception $e) {
-               echo 'Caught exception: ',  $e->getMessage(), "\n";
-               exit;
-       }
+    $entry = array();
+    $file['config'] = parse_ini_string($config);
+    $file['title'] = isset($file['config']['title']) ? $file['config']['title'] : $fileInfo->getFilename();
+    $file['filename'] = $fileInfo->getFilename();
+    $file['path'] = $fileInfo->getPath();
+    $file['fileInfo'] = $fileInfo;
+    $file['config']['date'] = isset($file['config']['date']) ? $file['config']['date'] : null;
+    $file['timestamp'] = $file['config']['date'] ? date('U', strtotime( $file['config']['date'])) : $fileInfo->getCTime();
+    $file['tags'] = isset($file['config']['tags']) ? explode(" ", $file['config']['tags']) : null;
+    $file['content'] = Markdown($content);
+
+    if ($passed_more)
+      $file['content_short'] = Markdown($content_short);
+
+    $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()));
+    
+    $file['cat'] = $page ? null : array('name' => substr($cat, 1), 'url' => $cat.'/' );
 
-       $f['title'] = isset($f['config']['title']) ? $f['config']['title'] : $fileInfo->getFilename() ;
-       $f['config']['date'] = isset($f['config']['date']) ? $f['config']['date'] : null;
-       $f['timestamp'] = $f['config']['date'] ? date('U', strtotime( $f['config']['date'])) : $fileInfo->getCTime();
-       $f['tags'] = isset($f['config']['tags']) ? explode(" ", $f['config']['tags']) : null;
-       $f['content'] = Markdown($content);
+    $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['cat']    = (object) $file['cat'];
+    $file['config'] = (object) $file['config'];
 
-       $f['comments_enabled'] = isset($f['config']['comments']) && $f['config']['comments'];
-       $f['comments'] = new Comments($fileInfo);
+    return (object) $file;  
+
+
+      /*
+    $f['title'] = isset($f['config']['title']) ? $f['config']['title'] : $fileInfo->getFilename() ;
+    $f['config']['date'] = isset($f['config']['date']) ? $f['config']['date'] : null;
+    $f['timestamp'] = $f['config']['date'] ? date('U', strtotime( $f['config']['date'])) : $fileInfo->getCTime();
+    $f['tags'] = isset($f['config']['tags']) ? explode(" ", $f['config']['tags']) : null;
+    $f['content'] = Markdown($content);
+
+    $f['comments_enabled'] = isset($f['config']['comments']) && $f['config']['comments'];
+    $f['comments'] = new Comments($fileInfo);
 
     if ($passed_more)
       $f['content_short'] = Markdown($content_short);
 
-       $cat = clean_slashes(str_replace(LOCAL_ROOT . CONTENT_DIR, "", $fileInfo->getPath()));
-       $clean_path = str_replace(LOCAL_ROOT . CONTENT_DIR, "", clean_slashes($fileInfo->getPath()));
+    $cat = clean_slashes(str_replace(LOCAL_ROOT . CONTENT_DIR, "", $fileInfo->getPath()));
+    $clean_path = str_replace(LOCAL_ROOT . CONTENT_DIR, "", clean_slashes($fileInfo->getPath()));
+
+    //$f['cat'] = $page ? null : array('name' => $clean_path, 'url' => $clean_path );
+    $f['cat'] = clean_slashes(str_replace(LOCAL_ROOT . CONTENT_DIR, "", $fileInfo->getPath()));
+
+    $f['path'] = $fileInfo->getRealPath();
+    $f['url'] = ($page ? WEB_ROOT : WEB_ROOT . $f['cat']['url'] . '/' ) . $fileInfo->getFilename();
 
-       $f['cat'] = $page ? null : array('name' => $clean_path, 'url' => $clean_path );
-       $f['path'] = $fileInfo->getRealPath();
-       $f['url'] = ($page ? '' : $f['cat']['url'] . '/' ) . $fileInfo->getFilename();
+    echo $f['url'];
+    echo '<br/>';
 
     if (!CLEAN_URLS) {
-       $f['cat']['url'] = WEB_ROOT . '?p=' . $f['cat']['url'];
-       $f['url'] = WEB_ROOT . '?p=' . $f['url'];
+        $f['cat']['url'] = WEB_ROOT . '?p=' . $f['cat']['url'];
+        $f['url'] = WEB_ROOT . '?p=' . $f['url'];
     }
 
     $f['cat']    = (object) $f['cat'];
     $f['config'] = (object) $f['config'];    
 
-       return (object) $f;
+    return (object) $f;
+    */
 }
 
 function get_comments_location ( &$fileInfo ) {
index 2d3bcd25e050da92482f60de512e67b53ed73921..7533d5627a2604f17647890ace95e8ec640a6f70 100644 (file)
@@ -34,6 +34,7 @@ define ('SITE_TITLE', $_cfg['site_title']);
 define ('CONTENT_DIR', $_cfg['content']);
 define ('COMMENTS_DIR', $_cfg['comments']);
 define ('DATA_DIR', $_cfg['data']);
+define ('MEDIA_DIR', $_cfg['media']);
 define ('DATA_FILE', $_cfg['data_file']);
 define ('TEMPLATE_DIR', $_cfg['templates']);
 define ('PAGE_DIR', $_cfg['pages']);
index abf9f627b71d7d23a13c56a5bfc744cd85da1051..44cf54b9aab6ce3d5105c0b5ece01b825674b345 100644 (file)
@@ -53,14 +53,14 @@ class Model
                        // prev/next
                        $entries = get_entries( $request['dirname'] );
                        for($i = count($entries)-1; $i>=0; $i--) {
-                               if ($this->entry['url'] == $entries[$i]['url']) {
-                                       $this->entry['prev_entry'] = isset($entries[$i-1]) ? $entries[$i-1] : null;
-                                       $this->entry['next_entry'] = isset($entries[$i+1]) ? $entries[$i+1] : null;
+                               if ($this->entry->url == $entries[$i]->url) {
+                                       $this->entry->prev_entry = isset($entries[$i-1]) ? $entries[$i-1] : null;
+                                       $this->entry->next_entry = isset($entries[$i+1]) ? $entries[$i+1] : null;
                                        break;
                                }
                        }
 
-                       $this->entry['is_single'] = true;
+                       $this->entry->is_single = true;
                        $this->template = 'single.' . $this->response_format . '.tpl';
                }
 
diff --git a/pages/agg b/pages/agg
deleted file mode 100644 (file)
index c299cf6..0000000
--- a/pages/agg
+++ /dev/null
@@ -1,3 +0,0 @@
-title = aggregate
-template = agg
---
diff --git a/templates/agg.html.tpl b/templates/agg.html.tpl
deleted file mode 100644 (file)
index 4ecf916..0000000
+++ /dev/null
@@ -1,228 +0,0 @@
-<html>
-<head>
-
-    <?php $this->include_template('head-inc.html.tpl'); ?>
-
-    <title><?=SITE_TITLE?>: aggregate</title>
-
-</head>
-<body>
-
-    <? $this->include_template('nav.html.tpl') ?>
-
-<div id="content">
-
-       <table border="0" id="agg"><tr>
-
-       <!-- quilime:aggregate -->
-       <td valign="top" class="column">
-
-<?
-       $agg = get_rss_feed('http://media.quilime.com/aggregate/index.php?return=rss');
-?>
-       <h2><a href="http://media.quilime.com/aggregate/">image</a></h2>
-       <ul class="image">
-
-<?
-       $count = 10;
-       foreach($agg->channel->item as $item) :
-       if (!$count--) break;
-       ?>
-       <li title="<?=$item->title?>">
-               <a href="<?=$item->link?>"><img src="<?=$item->thumb?>"></a>
-       </li>
-       <? endforeach; ?>
-       </ul>
-
-       <p>
-       <a class="rss" href="http://media.quilime.com/aggregate/index.php?return=rss">rss</a>, <a class="more" href="http://media.quilime.com/aggregate" title="via quilime.com/aggregate">more &rarr;</a>
-       </p>
-
-       </td>
-
-               <td valign="top" class="column">
-               <?php $vid = get_rss_feed('http://quilime.tumblr.com/rss'); ?>
-               <h2><a href="http://quilime.tumblr.com/">video</a></h2>
-               <script>
-                function vtog(count) {
-                    $('.vid').hide();
-                    $('#vid_' + count).show();                    
-                }    
-               </script>
-               <ul class="video">
-               <?php
-
-               $count = 11;
-               
-               foreach($vid->channel->item as $v) :
-               if ($count-- == 0) break;
-               ?>
-               <li title="<?php echo str_replace('"', '\'', $v->title); ?>">
-                   <?
-                $desc = $v->description;
-                $patterns = array('/player.vimeo.com/', '/youtube.com/');
-                foreach($patterns as $p) {
-                   preg_match($p, $desc, $matches);
-                    echo '<a onClick="vtog('.$count.');" href="#">';                       
-                   if (sizeof($matches) > 0) {
-                           // vimeo
-                       if ('/'.$matches[0].'/' == $patterns[0]) {
-                            // get video thumbnail for vimeo                               
-                            $pattern = '/http:\/\/player.vimeo.com\/video\/(\\d+)/';                               
-                           preg_match($pattern, $desc, $m);
-                            $video_url = "http://vimeo.com/". $m[1]  ;
-                            $file = fopen($video_url, "r");
-                            $filedata = stream_get_contents($file);
-                            $html_content = strpos($filedata,"<meta property=\"og:image\"");
-                            $link_string = substr($filedata, $html_content + 35, 128);
-                            $video_id_array = explode("\"", $link_string);
-                            $thumbnail_url = $video_id_array[0];
-                            echo '<img style="width:120px; height:90px;" src="'.$thumbnail_url.'">';
-                           }
-                           // youtube
-                       if ('/'.$matches[0].'/' == $patterns[1]) {
-                            $pattern = '/http:\/\/www.youtube.com\/v\/(.+?)&/';
-                           preg_match($pattern, $desc, $m);
-                            echo '<img src="http://i3.ytimg.com/vi/'.$m[1].'/default.jpg" />';
-                           }
-                    }
-                    echo '</a>';                    
-                }
-                   ?>
-                <div class="vid" id="vid_<?=$count?>" style="display:none;">
-                <?=$v->description ?>
-                </div>
-               </li>
-               <? 
-               endforeach;
-               
-               
-               
-/*
-// get video thumbnail for vimeo
-$video_url = "http://vimeo.com/15592943"  ;
-$file = fopen($video_url, "r");
-$filedata = stream_get_contents($file);
-$html_content = strpos($filedata,"<meta property=\"og:image\"");
-$link_string = substr($filedata, $html_content + 35, 49);
-$video_id_array = explode("\"", $link_string);
-echo("LINK: " . $link_string);
-$thumbnail_url = $filedata[3];
-//               echo $thumbnail_url;
-echo '<img src="'.$link_string.'">';
-
-               */
-
-
-               ?>
-               </ul>
-               <p>
-                   <a class="rss" href="http://quilime.tumblr.com/rss">rss</a>, 
-                   <a class="more" href="http://quilime.tumblr.com" title="via tumblr">more &rarr;</a>
-               </p>
-               </td>
-
-
-<? /*
-               <td valign="top" class="column">
-               <?php $tube = get_rss_feed('http://gdata.youtube.com/feeds/base/users/quilime/favorites?alt=rss&v=2&orderby=published&client=ytapi-youtube-profile'); ?>
-               <h2><a href="http://www.youtube.com/profile?user=kabr&view=favorites">video </a></h2>
-               <ul class="video">
-               <?php
-               $count = 11;
-               foreach($tube->channel->item as $tube) :
-               if ($count-- == 0) break;
-               ?>
-               <li title="<?php echo str_replace('"', '\'', $tube->title); ?>">
-                   <?
-                   $url = $tube->link;
-                   $pattern = '/v=(.+?)&/';
-                   preg_match($pattern, $url, $matches);
-                   $id = $matches[1];
-                   ?>
-                   <a href="<?php echo $tube->link; ?>">
-
-                   <img src="http://i3.ytimg.com/vi/<?=$id?>/default.jpg" />
-                   </a>
-               </li>
-               <? endforeach; ?>
-               </ul>
-               <p>
-                   <a class="more" href="http://www.youtube.com/profile?user=quilime&view=favorites" title="via youtube">more &rarr;</a>
-               </p>
-               </td>
-*/ ?>
-<? /*
-       <!-- quilime:flickr -->
-       <td valign="top" class="column">
-               <h3><a  href="http://flickr.com/photos/quilime/">flickr</a></h3>
-               <ul>
-               <?      $count = 8; $img = get_rss_feed('http://api.flickr.com/services/feeds/photos_public.gne?id=28394478@N00&lang=en-us&format=rss_200');  ?>
-        <?php foreach($img->channel->item as $item) : if (!$count--) break; ?>
-        <li>
-            <?
-                $subject = $item->description;
-               $pattern = '/<a href="http:\/\/www\.flickr\.com\/photos\/quilime\/(.*) \/><\/a><\/p>/';
-                preg_match($pattern, substr($subject, 3), $matches, PREG_OFFSET_CAPTURE);
-                echo $matches[0][0];
-            ?>
-        </li>
-<?endforeach;?>
-       </ul>
-       <p>
-       <a class="ext" href="http://api.flickr.com/services/feeds/photos_public.gne?id=28394478@N00&lang=en-us&format=rss_200">rss</a>, <a class="more" href="http://flickr.com/photos/quilime/" title="via flickr">more &rarr;</a>
-       </p>
-       </td>
-*/ ?>
-
-
-       <!-- quilime:delicious -->
-       <td valign="top" class="column">
-
-<?
-       $url = 'https://<login>:<pass>@api.del.icio.us/v1/posts/recent';
-       $ch = curl_init();
-       curl_setopt($ch, CURLOPT_URL, $url);
-       curl_setopt($ch, CURLOPT_POST, 1);
-       curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
-       curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
-       curl_setopt($ch, CURLOPT_TIMEOUT, 5);
-       curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
-       curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
-       $data = curl_exec($ch);
-       curl_close($ch);
-       $del = new SimpleXMLElement($data);
-?>
-
-       <h2><a  href="http://delicious.com/quilime/">link</a></h2>
-
-       <ul class="bookmarks">
-       <?php foreach($del->post as $d) : ?>
-               <li>
-                       <a href="<?=$d['href']?>"><?=$d['description'];?></a>
-
-<? /* <em><? echo get_relative_time(strtotime($d['time'])); ?> </em> */ ?>
-
-                       <div class="desc"><?=$d['extended'];?></div>
-            <small style="color:#aaa;" class="tags"><em><? $t = explode(" ", $d['tag']); echo implode(", ", $t); ;?></em></small>
-               </li>
-       <? endforeach; ?>
-       </ul>
-
-       <p>
-       <a class="rss" href="http://feeds.delicious.com/v2/rss/quilime?count=15">rss</a>, <a class="more" href="http://delicious.com/quilime/" title="via delicious">more &rarr;</a>
-       </p>
-
-       </td>
-
-
-
-
-       </tr></table>
-
-       </div>
-
-       <? $this->include_template('footer.html.tpl'); ?>
-
-</body>
-</html>
\ No newline at end of file
index e23d7638b84adcdbe0f9e38faf62250b80e357d1..93876cdf263b791b8deb506419295a594cec3574 100644 (file)
@@ -39,7 +39,7 @@
        ?>
 
 <? if (isset($single) && $single) : ?>
-       <div class="arrow" title="<?=$entry->cat->entry?>">
+       <div class="arrow" title="<?=$entry->cat->name?>">
                <a href="<?=$entry->cat->url?>">&larr;</a>
        </div>
 <? else : ?>
index 7b8bb4b5a04b6d62cfe4b65257a1d3ddc08b1927..ff149e391523e62eb474f147b01bf151d8110428 100644 (file)
@@ -3,7 +3,7 @@
     
     <? $this->include_template('head-inc.html.tpl') ?>
     
-    <title><?=SITE_TITLE?>: <?=$page_title?></title>
+    <title><?=SITE_TITLE?>: <?=$entry->title?></title>
     
 </head>
 <body>
@@ -12,6 +12,7 @@
     
 <div id="content">
 
+
     <ul class="projects">
     <? foreach($entries as $entry): ?>
         <li>
index e511b6cf14b45827cb48b3f474688877c478b5e6..1a175c261eba7609127cf853ca28db0252608a7a 100644 (file)
@@ -3,24 +3,19 @@
 
     <? $this->include_template('head-inc.html.tpl') ?>
 
-    <title><?=$entry['title'];?></title>
+    <title><?=$entry->title;?></title>
 
 </head>
 <body>
 
-       <div id="content" class="single">
-               <?
-               if (isset($entry['config']['template'])) {
-                       $this->include_template($entry['config']['template'] . '.' . $this->response_format . '.tpl');
-               }
-               else {
-                       $this->include_template('entry.' . $this->response_format . '.tpl');
-                       } 
-               ?>
+    <? $this->include_template('nav.html.tpl') ?>
 
+       <div id="content" class="single entry">
+           <div class="entry">
+           <? $this->include_template('entry.html.tpl', array('entry' => $entry, 'single' => true)); ?>
+           </div>
        </div>
 
-       <? $this->include_template('nav.html.tpl') ?>
        <? $this->include_template('footer.html.tpl') ?>
 
 </body>
index 53250175af1008a73abb73a546a966f34e12a29b..9bab04633471551d533e0f6b63284ee164b0ef16 100644 (file)
--- a/test.php
+++ b/test.php
@@ -10,7 +10,6 @@ require 'lib/init.php';
 
 class AllTests extends TestSuite {
     function AllTests() {
-        $this->TestSuite('All tests');
         $this->addFile('lib/test/data_test.php');
     }
 }