]> git.quilime.com - plog.git/commitdiff
fixed trailing slashes for categories
authorGabriel Dunne <gdunne@quilime.com>
Sun, 11 Jul 2010 01:17:12 +0000 (18:17 -0700)
committerGabriel Dunne <gdunne@quilime.com>
Sun, 11 Jul 2010 01:17:12 +0000 (18:17 -0700)
lib/data.php
public/index.php
templates/default.html.tpl
templates/entry.html.tpl
templates/nav.html.tpl
templates/page.html.tpl
templates/single.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 ba03ff2f2d9e767a5cd03a151be2a7b12f9613a6..70f255006cc8d8392468d5decfdb7ad78b39c02c 100644 (file)
@@ -4,24 +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);        
+        $t->assign('data', $data);
+        $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);        
-        $t->assign('data', parse_entry(new SplFileInfo(LOCAL_ROOT . CONTENT_DIR . $url_parts['url'])));
-        $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'])) {
     # default (all entries)
     else {
         list($data, $total) = get_entries();
-        $t->assign('data', $data);        
+        $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 d366eb78e45ef2945a49890aae8ff2e7d58c3835..f353bb4494103bda34729d054e58c394b1465aa6 100644 (file)
@@ -3,7 +3,7 @@
     
     <? $this->include_template('head-inc.html.tpl') ?>
     
-    <title><?=$this->page_title('; ');?></title>
+    <title><?=$this->page_title(TITLE_DELIMITER);?></title>
     
 </head>
 <body>
index aa618b9e1a8c721910148177cebcf024eff9f9ea..cd68910536f0576362329eede767826fe0613762 100644 (file)
@@ -10,7 +10,7 @@
 
        <div class="metadata">
                posted <abbr title="<?=get_relative_time($data['timestamp']);?>"><?=date("F d, Y", $data['timestamp'])?></abbr> 
-               in <a href="<?=get_base_dir();?>/<?=$data['cat'];?>"><?=$data['cat'];?></a>
+               in <a href="<?=$data['cat']['url'];?>"><?=$data['cat']['name'];?></a>
                <br/>
                <ul class="tags">
                <? if ($data['tags']) foreach($data['tags'] as $tag) : ?>
index c423896fdafc090e44cca3a8f566055c81a8bfa1..4d0aa9960e7c5b88eb2cc2025fe44ee4c5b7883f 100644 (file)
@@ -4,11 +4,11 @@
        
        <br />
        
-       <h3>categories</h3>
+       <h3>content</h3>
        
        <? $dirs = get_dirs(); ?>
        <? foreach($dirs as $dir) : ?>
-       <li><a href="<?=$dir?>"><?=$dir?></a></li>
+       <li><a href="<?=$dir['url']?>"><?=$dir['name']?></a></li>
        <? endforeach; ?>
        
        <br />
index 295ad02302bae5e7ad086fb2eb42900460fde509..699aae90737f5035587f849ce9b393c883451cd2 100644 (file)
@@ -3,7 +3,7 @@
     
     <? $this->include_template('head-inc.html.tpl') ?>
     
-    <title><?=SITE_TITLE?>, <?=$data['title']?></title>
+    <title><?=SITE_TITLE?><?=TITLE_DELIMITER?> <?=$data['title']?></title>
     
 </head>
 <body>
@@ -11,8 +11,6 @@
     <? $this->include_template('nav.html.tpl') ?>
     
 <div id="content">
-       
-       <h1><?=$data['title']?></h1>
 
        <?=$data['content'];?>
        
index e169285f49edcd4c73bb434c801687931adffdcc..91a416ff850592211133e44eb87112af0eaa5573 100644 (file)
@@ -3,7 +3,7 @@
     
     <? $this->include_template('head-inc.html.tpl') ?>
     
-    <title><?=SITE_TITLE?>, <?=$data['title'];?></title>
+    <title><?=SITE_TITLE?><?=TITLE_DELIMITER?> <?=$data['title'];?></title>
     
 </head>
 <body>