else {
$dir_iterator = new DirectoryIterator($path);
}
+
$entries = array();
foreach ($dir_iterator as $file => $info) {
if (!$info->isDir()) {
$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;
$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;
}
$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);
-
+
?>
<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>
-