]> git.quilime.com - plog.git/commitdiff
Updated entries to use cache properly with featured and tagged views.
authorGabriel Dunne <gdunne@quilime.com>
Sun, 16 Jun 2013 01:04:14 +0000 (18:04 -0700)
committerGabriel Dunne <gdunne@quilime.com>
Sun, 16 Jun 2013 01:04:14 +0000 (18:04 -0700)
css/style.css
index.php
lib/config.ini
lib/data.php
lib/model.php
templates/all.html.tpl
templates/index.html.tpl

index daeed78a5c37085f65de3b0e30e9146715f2b5e2..0bc36c04e18ae3f4de33f7cbd06df123f77c9c3c 100644 (file)
@@ -239,6 +239,9 @@ table, td, tr {
   padding-bottom:3em;
   height:350px;
 }
+.entries.projects.featured li {
+  height:200px;
+}
 .entries.projects ul.tags li {
   height:1.5em;
   margin:0;
index 83b1f66485840b59f04578c0a40b284f084e4326..5080f822cf16911f27557d3467f6c85fccbe3532 100644 (file)
--- a/index.php
+++ b/index.php
@@ -13,7 +13,7 @@ $v->assign('request', $request);
 if ($m->is_multiple()) {
     $v->assign('pagination', $m->pagination);
     $v->assign('entries', $m->entries);
-    // $v->assign('entry', $m->entry);
+    $v->assign('entry', $m->entry);
 }
 
 if ($m->is_single() || $m->is_page()) {
index dedd0543fe1aacf7614cad304ab9569176aeb8ca..b38be6745f31fe0d29044409c30fd0d4ec4ebafa 100644 (file)
@@ -32,5 +32,5 @@ file_ignores[] = config
 file_ignores[] = .DS_Store
 
 ; dev
-dev = 0
+dev = 1
 edit = 0
index 1fce12770cb526f32d3c8cd4f322f6429c61fd62..4a1f99feb00fc9741bdb9bedee5d26eaa3f90e77 100644 (file)
@@ -33,31 +33,17 @@ function get_entries( $path = "", $args = array() )
         }
         
         $entries = array();
-
-
         if (isset($dir_iterator)) {
             foreach ($dir_iterator as $file => $info) {
                 // skip dot files
                 if (substr($info->getFilename(), 0, 1) == '.') 
                     continue;                
-                // parse only specific files
+                // parse only config files
                 if ($info->isFile() && $info->getFilename() == CONTENT_CONFIG_FILE) {
-                    $entry = parse_entry($info);
-                    if ($show_featured && empty($tag)) {
-                        if (isset($entry->featured)) {
-                            $entries[] = $entry;
-                        }
-                    }
-                    else if (empty($tag)) {
-                        $entries[] = $entry;
-                    }
-                    else if ($tag && in_array($tag, isset($entry->tags) && is_array($entry->tags) ? $entry->tags : array())) {
-                        $entries[] = $entry;
-                    }
+                    $entries[] = parse_entry($info);
                 }
             }
         }
-
         $entries = sort_entries($entries, $order_by, $order);
 
         if ($create_datafile) {
@@ -76,8 +62,28 @@ function get_entries( $path = "", $args = array() )
         }
     }
 
-    $json = json_decode(file_get_contents( $data_file ));
-    return $json->entries;
+    $data = json_decode(file_get_contents( $data_file ));
+
+    // parse JSON with tags and such
+    if ($show_featured) {
+        foreach ($data->entries as $i => $entry) {
+            if (!$entry->featured) {
+                unset($data->entries[$i]);
+            }
+        }
+    }    
+    if (isset($tag)) {
+        foreach ($data->entries as $i => $entry) {
+            if (
+                !is_array($entry->tags) || 
+                !in_array($tag, $entry->tags)
+                ) {
+                unset($data->entries[$i]);
+            }
+        }
+    }
+
+    return $data->entries;
 }
 
 
index 1d38e80cbc6bdc29c4f65bbb7296d1fa97dd83ee..e897ff842324bd2492770a263afc47e9095f2a44 100644 (file)
@@ -80,8 +80,11 @@ class Model
                $this->entry = $this->config;
                $this->page_title = preg_replace('{^/|/$}', '', $this->request['path']);
 
-               $entries_args = array('tag' => $this->tag);
-               if (isset($this->config->config->show_featured)) {
+               $entries_args = array();
+               if ($this->tag) {
+                       $entries_args = array('tag' => $this->tag);
+               }
+               if (isset($this->config->config->show_featured) && !$this->tag) {
                        $entries_args['show_featured'] = true;
                }
                $this->entries = get_entries( $request['path'], $entries_args);
index 234e0f183cd3668945791d21aeb259eb6cdc25e6..162f1b13a47ba1afabba55301e951e26d5fd3feb 100644 (file)
@@ -32,7 +32,7 @@
                     <? for($i = 0; $i < sizeof($entry->tags); $i++) : $tag = $entry->tags[$i]; ?>
                         <li class="tag"><a href="<?=WEB_ROOT.'tag/'.$tag?>"><?=$tag?></a></li>
                     <? endfor; ?>
-                    </ul>                    
+                </ul>                
         </li>
     <? endforeach; ?>
     </ul>
index 7cc59f719a073754e990bb8911860b750d4c05e7..e8ea1c0c51890e7e1a8a784f8d5a9cb514d2f2e0 100644 (file)
@@ -8,7 +8,7 @@
 <? $this->include_template('nav.html.tpl', array('index' => true)) ?>
 
 <div id="content">
-    <ul class="entries projects <?=isset($tag)?'tagged':''; ?>">
+    <ul class="entries projects <?=isset($tag)&&$tag!==""?'tagged':''; ?> <? if ($entry->config->show_featured && !isset($tag)): ?>featured<? endif;?>">
     <? foreach($entries as $entry): ?>
         <li class="<?=$entry->cat->name?>">
             <a href="<?=$entry->url;?>">
                 <br />
                 <strong><?=$entry->title;?></strong>
                 </a>
-                <? if (isset($tag)) : ?>                    
-                    <br />&mdash;<br />
-                    <ul class="tags">
-                        <? for($i = 0; $i < sizeof($entry->tags); $i++) : $tag = $entry->tags[$i]; ?>
-                            <li class="tag"><a href="<?=WEB_ROOT.'tag/'.$tag?>"><?=$tag?></a></li>
-                        <? endfor; ?>
-                        </ul>                    
-                    <? endif; ?>
+                <? if (!isset($entry->config->show_featured) && isset($tag)): ?>
+                <br />
+                &mdash;
+                <br />
+                <ul class="tags">
+                    <? for($i = 0; $i < sizeof($entry->tags); $i++) : $tag = $entry->tags[$i]; ?>
+                        <li class="tag"><a href="<?=WEB_ROOT.'tag/'.$tag?>"><?=$tag?></a></li>
+                    <? endfor; ?>
+                </ul>                     
+                <? endif ;?>
         </li>
     <? endforeach; ?>
     </ul>