From: Gabriel Dunne Date: Sun, 16 Jun 2013 01:04:14 +0000 (-0700) Subject: Updated entries to use cache properly with featured and tagged views. X-Git-Url: https://git.quilime.com/?a=commitdiff_plain;h=4d659cfc323b4d5520403f488a7a24113f5f507e;p=plog.git Updated entries to use cache properly with featured and tagged views. --- diff --git a/css/style.css b/css/style.css index daeed78..0bc36c0 100644 --- a/css/style.css +++ b/css/style.css @@ -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; diff --git a/index.php b/index.php index 83b1f66..5080f82 100644 --- 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()) { diff --git a/lib/config.ini b/lib/config.ini index dedd054..b38be67 100644 --- a/lib/config.ini +++ b/lib/config.ini @@ -32,5 +32,5 @@ file_ignores[] = config file_ignores[] = .DS_Store ; dev -dev = 0 +dev = 1 edit = 0 diff --git a/lib/data.php b/lib/data.php index 1fce127..4a1f99f 100644 --- a/lib/data.php +++ b/lib/data.php @@ -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; } diff --git a/lib/model.php b/lib/model.php index 1d38e80..e897ff8 100644 --- a/lib/model.php +++ b/lib/model.php @@ -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); diff --git a/templates/all.html.tpl b/templates/all.html.tpl index 234e0f1..162f1b1 100644 --- a/templates/all.html.tpl +++ b/templates/all.html.tpl @@ -32,7 +32,7 @@ tags); $i++) : $tag = $entry->tags[$i]; ?>
  • - + diff --git a/templates/index.html.tpl b/templates/index.html.tpl index 7cc59f7..e8ea1c0 100644 --- a/templates/index.html.tpl +++ b/templates/index.html.tpl @@ -8,7 +8,7 @@ include_template('nav.html.tpl', array('index' => true)) ?>
    -