]> git.quilime.com - plog.git/commitdiff
merges from master branch
authorGabriel Dunne <gdunne@quilime.com>
Sun, 11 Jul 2010 01:24:14 +0000 (18:24 -0700)
committerGabriel Dunne <gdunne@quilime.com>
Sun, 11 Jul 2010 01:24:14 +0000 (18:24 -0700)
lib/data.php
public/index.php
templates/entry.html.tpl

index e20e40274b29bbadc54905efacb3f7afa0396524..05bb0810d72d0e802e4ffa69f0c57073bda91936 100644 (file)
@@ -19,6 +19,7 @@ function get_entries( $path = "", $args = array())
        else {
                $dir_iterator = new DirectoryIterator($path);
        }
+       
        $entries = array();
        foreach ($dir_iterator as $file => $info) {
                if (!$info->isDir()) {
@@ -77,7 +78,10 @@ function get_dirs( $path = "", $args = array())
        $dirs = array();
        foreach ($dir_iterator as $dir => $info) {
                if ($info->isDir() && $info->getFilename() != '.' && $info->getFilename() != '..') {
-                       $dirs[] = str_replace($path, "",  $info->getRealPath());
+            $d = array();
+            $d['url'] = str_replace($path, "",  $info->getRealPath()) . '/';
+            $d['name'] = substr(str_replace($path, "",  $info->getRealPath()),1);
+                       $dirs[] = $d;
                }
        }
        return $dirs;           
@@ -108,14 +112,14 @@ function parse_entry($fileInfo, $page = 0)
 
        $file = array();
        $file['config'] = parse_ini_string($config);
-               
        $file['title'] = $file['config']['title'];
        $file['timestamp'] = $file['config']['date'] ? date('U', strtotime( $file['config']['date'])) : $fileInfo->getCTime();
        $file['tags'] = $file['config']['tags'] ? explode(" ", $file['config']['tags']) : null;
        $file['content'] = Markdown($content);
-       $file['cat'] = $page? null : substr(clean_slashes(str_replace(LOCAL_ROOT . CONTENT_DIR, "", $fileInfo->getPath())),1);
+       $cat = clean_slashes(str_replace(LOCAL_ROOT . CONTENT_DIR, "", $fileInfo->getPath()));
+       $file['cat'] = $page ? null : array('name' => substr($cat,1), 'url' => $cat.'/' );
        $file['path'] = $fileInfo->getRealPath();
-       $file['url'] = WEB_ROOT . ($page ? '' : $file['cat'] . '/' ) . $fileInfo->getFilename();
+       $file['url'] = WEB_ROOT . ($page ? '' : substr($file['cat']['url'],1)) . $fileInfo->getFilename() . '/';
 
        return $file;
 }
index b942251e2b0e213e5baf2dcb79e8e886534eabcd..70f255006cc8d8392468d5decfdb7ad78b39c02c 100644 (file)
@@ -4,33 +4,24 @@
 
     $url_parts = get_url();
 
-    list($response_format, $response_mime_type) = parse_format($url_parts['extension'], 'html');    
-    
+    list($response_format, $response_mime_type) = parse_format($url_parts['extension'], 'html');
+
     # setup template
-    $t = get_template_instance();    
+    $t = get_template_instance();
     $t->response_format = $response_format;
     $t->assign('view', $_GET['v']);
-    
+
     # is folder
     if (is_dir(LOCAL_ROOT . CONTENT_DIR . $url_parts['url']) && $url_parts['url'] != "/") {
         list($data, $total) = get_entries($url_parts['url']);
-        $t->assign('page_title', preg_replace('{^/|/$}', '', $url_parts['url']));        
         $t->assign('data', $data);
-        
-        if ($url_parts['url'] == '/projects/')
-            $template = 'projects.' . $response_format . '.tpl';
+        $t->assign('page_title', preg_replace('{^/|/$}', '', $url_parts['url']));
     }
     # is file
-    else if (is_file( LOCAL_ROOT . CONTENT_DIR . $url_parts['url'])) {
-        $t->assign('single', true);        
-        $entry = parse_entry(new SplFileInfo(LOCAL_ROOT . CONTENT_DIR . $url_parts['url']));
-        $t->assign('data', $entry);
-        
-        
-        if ($entry['cat'] == 'projects')
-            $template = 'project.'.$response_format.'.tpl';
-        else
-            $template = 'single.'.$response_format.'.tpl';
+    else if (is_file( LOCAL_ROOT . CONTENT_DIR . $url_parts['dirname'] . '/' . $url_parts['filename'])) {
+        $t->assign('data', parse_entry(new SplFileInfo(LOCAL_ROOT . CONTENT_DIR . $url_parts['dirname'] . '/' . $url_parts['filename'])));
+        $t->assign('single', true);
+        $template = 'single.'.$response_format.'.tpl';
     }
     # is page
     else if (is_file( LOCAL_ROOT . PAGE_DIR . DIRECTORY_SEPARATOR . $url_parts['filename'])) {
         $t->assign('data', $page);
         $template = $page['config']['template'] ? $page['config']['template'] . '.' . $response_format . '.tpl' : 'page.' . $response_format . '.tpl';
     }
-    # default
+    # default (all entries)
     else {
         list($data, $total) = get_entries();
-        $t->assign('data', $data);        
-        $template = 'index.html.tpl';
+        $t->assign('data', $data);
     }
-    
+
     # render
-    $t->assign('total', $total);    
+    $t->assign('total', $total);
     header("Content-Type: {$response_mime_type}; charset=UTF-8");
     $t->render($template);
-    
+
 ?>
index a7b8813ab165c56d055a439e6397ae3a884b2bbd..cd68910536f0576362329eede767826fe0613762 100644 (file)
@@ -2,23 +2,21 @@
 
        <h2>
                <a title="posted on <?=$data['date']?>" href="<?=$data['url']?>"><?=$data['title']?></a>
-               <span class="title-date" title="<?=date("F d, Y", $data['timestamp'])?>"><?=get_relative_time($data['timestamp']);?></span>             
        </h2>
 
        <div class="content">
                <?=$data['content']?>
        </div>
 
-       <? //if ($single) :?>
        <div class="metadata">
-               posted <?=date("F d, Y", $data['timestamp'])?> in <a href="<?=get_base_dir();?>/<?=$data['cat'];?>"><?=$data['cat'];?></a><br/>
+               posted <abbr title="<?=get_relative_time($data['timestamp']);?>"><?=date("F d, Y", $data['timestamp'])?></abbr> 
+               in <a href="<?=$data['cat']['url'];?>"><?=$data['cat']['name'];?></a>
+               <br/>
                <ul class="tags">
-               <? if (sizeof($data['tags']) > 0) foreach($data['tags'] as $tag) : ?>
+               <? if ($data['tags']) foreach($data['tags'] as $tag) : ?>
                <li>#<?=$tag?></li>
                <? endforeach; ?>
                </ul>
        </div>
-       <? //endif; ?>
 
 </div>
-