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);
+ $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);
-
+
?>
<? $this->include_template('head-inc.html.tpl') ?>
- <title><?=$this->page_title('; ');?></title>
+ <title><?=$this->page_title(TITLE_DELIMITER);?></title>
</head>
<body>
<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) : ?>
<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 />
<? $this->include_template('head-inc.html.tpl') ?>
- <title><?=SITE_TITLE?>, <?=$data['title']?></title>
+ <title><?=SITE_TITLE?><?=TITLE_DELIMITER?> <?=$data['title']?></title>
</head>
<body>
<? $this->include_template('nav.html.tpl') ?>
<div id="content">
-
- <h1><?=$data['title']?></h1>
<?=$data['content'];?>
<? $this->include_template('head-inc.html.tpl') ?>
- <title><?=SITE_TITLE?>, <?=$data['title'];?></title>
+ <title><?=SITE_TITLE?><?=TITLE_DELIMITER?> <?=$data['title'];?></title>
</head>
<body>