$url_parts = get_url();
-// print_r($url_parts);
-
-// echo "<br/><br/>";
-
list($response_format, $response_mime_type) = parse_format($url_parts['extension'], 'html');
$t = get_template_instance();
-
- $view = isset($_GET['v']) ? $_GET['v'] : 'inline';
-
- if (is_string($url_parts['basename']))
- {
-
- # base content folder
- if (is_dir ( CONTENT_DIR . DIRECTORY_SEPARATOR . $url_parts['basename'])) {
-
- list($items, $total) = get_data(array($url_parts['basename']));
- $t->assign('items', $items);
- $t->assign('total', $total);
- $t->assign('view', $view);
- $t->render($url_parts['basename'] . '.' . $response_format . '.tpl');
- exit;
- }
+ $t->response_format = $response_format;
- # single entry
- else if ($url_parts['dirname'] != '.' && is_dir(CONTENT_DIR . $url_parts['dirname'])) {
+ $t->assign('view', $_GET['v']);
+
+
+ # content folder
+ if (is_dir(CONTENT_DIR . DIRECTORY_SEPARATOR . $url_parts['url']) && $url_parts['basename']) {
+ list($data, $total) = get_data(array($url_parts['basename']));
+ $t->assign('data', $data);
+ $template = $url_parts['basename'] . '.' . $response_format . '.tpl';
+ }
- $t->assign('single', true);
- $t->assign('item', parse_config(CONTENT_DIR . $url_parts['dirname'] . DIRECTORY_SEPARATOR . $url_parts['filename']));
- $t->assign('content', $url_parts['dirname'] . DIRECTORY_SEPARATOR . $url_parts['filename']);
-
- $t->render($url_parts['dirname'] . '.' . $response_format . '.tpl');
- exit;
- }
+
+ # single file
+ else if (is_file( CONTENT_DIR . $url_parts['dirname'] . DIRECTORY_SEPARATOR . $url_parts['filename'])) {
+ $t->assign('single', true);
+ $t->assign('data', parse_config(CONTENT_DIR . $url_parts['dirname'] . DIRECTORY_SEPARATOR . $url_parts['filename']));
+ $t->assign('content', $url_parts['dirname'] . DIRECTORY_SEPARATOR . $url_parts['filename']);
+ $template = $url_parts['dirname'] . '.' . $response_format . '.tpl';
+ }
+
+
+ # direct template
+ else if (is_file( TEMPLATE_DIR . DIRECTORY_SEPARATOR . $url_parts['filename'] .'.'. $response_format . '.tpl'))
+ {
+ $template = $url_parts['filename'] . '.' . $response_format . '.tpl';
+ }
- # not found
- else {
- $t->render('404.'.$response_format.'.tpl');
- exit;
- }
- }
+ # 404
+ else if ($url_parts['basename']) {
+ $template = '404.'.$response_format.'.tpl';
+ }
- # render all entries inline
- list($entries, $total) = get_inline_entries(array('log', 'code'));
+ # default (index)
+ else {
+ list($data, $total) = get_data();
+ $t->assign('data', $data);
+ $template = 'default.'.$response_format.'.tpl';
+ }
- $t->assign('entries', $entries);
- $t->assign('total', $total);
- $t->render('index.'.$response_format.'.tpl');
-
+
+
+
+ # render template
+ $t->assign('total', $total);
+ header("Content-Type: {$response_mime_type}; charset=UTF-8");
+ $t->render($template);
?>
<?php
-
-# parse inline content
-function get_data( $sources, $params = array() )
+// parse inline content
+function get_data( $sources = array(), $params = array())
{
+ // if no set sources, grab everything in content folder
+ if (sizeof($sources) == 0)
+ $sources = glob(LOCAL_ROOT . CONTENT_DIR . DIRECTORY_SEPARATOR . '/*');
+
$result = array();
$result_total = 0;
foreach ($sources as $dir) {
+
+ $dir = basename($dir);
+
$contents = glob(LOCAL_ROOT . CONTENT_DIR . DIRECTORY_SEPARATOR . $dir . '/*');
+
+ if (sizeof($contents) <= 0) continue;
+
foreach ($contents as $f) {
- if (!is_dir($f)) {
+ if (is_file($f)) {
if ($params['name']) {
if (basename($f) != $params['name'])
}
$config = parse_ini_string($cc);
+
+ if ($config['draft'])
+ continue;
$config['url'] = WEB_ROOT . DIRECTORY_SEPARATOR . $dir . DIRECTORY_SEPARATOR . basename($f);
- $config['timestamp'] = mktime($config['date']);
+ $config['timestamp'] = $config['date'] ? mktime($config['date']) : mktime(filemtime($f));
$config['category'] = $dir;
$config['content'] = $content;
$config['tags'] = explode(' ', $config['tags']);
// order by date
foreach ($result as $key => $row) {
- $time[$key] = $row['date'];
+ $time[$key] = $row['timestamp'];
}
- array_multisort($time, SORT_DESC, $result);
+ if ($time)
+ array_multisort($time, SORT_DESC, $result);
return array($result, $result_total);
}
-
function list_content($path, $args="")
{
list($list, $total) = get_content($path, $args);
}
if ($break) {
- $config['inline_content'] .= $c;
+ $config['inline_content'] .= $c . "\n";
}
else {
$conf = explode("=", $c);
function get_url()
{
- return pathinfo($_SERVER['SCRIPT_URL']); //substr($_SERVER['SCRIPT_URL'], strlen(get_base_dir() . '/'));
+ $path_info = pathinfo($_SERVER['SCRIPT_URL']);
+ $path_info['url'] = $_SERVER['SCRIPT_URL'];
+ return $path_info; //substr($_SERVER['SCRIPT_URL'], strlen(get_base_dir() . '/'));
}
class Template
{
var $template_dir = 'templates';
+ var $response_format = 'html';
var $_tpl_vars = array();
public function render( $template )
{
- extract( $this->_tpl_vars );
- include( $this->template_dir . DIRECTORY_SEPARATOR . $template );
+ extract( $this->_tpl_vars );
+
+ if (is_file($this->template_dir . DIRECTORY_SEPARATOR . $template))
+ include( $this->template_dir . DIRECTORY_SEPARATOR . $template );
+ else
+ include( $this->template_dir . DIRECTORY_SEPARATOR . 'default.'.$this->response_format.'.tpl' );
+
}
}
<head>
- <?php include_template( 'header-src.html' ); ?>
+ <?php $this->include_template( 'head-inc.html.tpl' ); ?>
<title><?php echo SITE_TITLE ?> - about</title>
-<?php
-
-
- $items = array();
- $single = false;
-
- if (is_dir(CONTENT_DIR . $url_string) && !is_file(CONTENT_DIR . $url_string . '/config') ) {
- list($items, $total) = get_inline_entries(array('code'));
- // list($items_list, $total) = get_content(basename($url_string));
- }
- else {
- list($items, $total) = get_inline_entries(array('code'), array('name'=>basename($url_string)));
- $items = $items[0];
- $single = true;
- }
-
- $inline = isset($_GET['inline']) ? true : false;
-
- $page = "code";
-
-
-?>
<html>
<head>
- <?php include_template('header-src.html'); ?>
- <script src="/js/jquery-1.3.2.min.js"></script>
-
- <title><?php echo SITE_TITLE; ?> - code<?php if (sizeof($items) > 0 ) : ?>: <?echo strtolower($items['title']); ?> [<?php echo $items['medium']; ?>]<?php endif; ?></title>
+
+ <? $this->include_template('head-inc.html.tpl') ?>
+ <title>
+ <?=SITE_TITLE; ?>
+ <? if ($single): ?>
+ - code: <?= $data['title']; ?>
+ [<?=date("Y M d", strtotime($data['date']));?>]
+ <? else: ?>
+ - code
+ <? endif; ?>
+ </title>
+
</head>
<body>
<?php if ($single) : ?>
- <h2><?=$items['title']?> [<?=$items['date']?>]</h2>
+ <h2><?=$data['title']?> [<?=$data['date']?>]</h2>
<div class="content">
<?php
- print ($items['content']);
+ echo ($data['inline_content']);
?>
</div>
<div class="func"><a href="/code/">list</a></div>
<ul class="inline_content">
- <?php foreach($items_list as $items): ?>
+ <?php foreach($data as $items): ?>
<li>
<h3>
<a href="<?php echo $items['href']?>"><?php echo $items['title']; ?></a>
<?php
$c = 1;
- foreach($items as $item):
+ foreach($data as $item):
// print_r($item);
<div id="content">
- <? foreach($entries as $entry): ?>
+ <? foreach($data as $entry): ?>
<? $this->include_template('entry.html.tpl', array('entry' => $entry)); ?>
<? endforeach; ?>
+ <? if ($view == "archive") : ?>
+ <a href="<?=$list_url?>">view list</a>
+ <? else : ?>
+ <a href="<?=$archive_url?>">view archive</a>
+ <? endif; ?>
+
</div>
+
<? $this->include_template('footer.html.tpl') ?>
</body>
-
<div class="entry">
<h2>
<?=$entry['content']?>
</div>
+
</div>
+++ /dev/null
-<html>
-
-<head>
-
- <?php include_template('header-src.html'); ?>
-
- <title><?php echo SITE_TITLE; ?></title>
-
-</head>
-
-<body>
-
- <? include_template('nav.html'); ?>
-
-<div id="content">
-<--- nav
-</body>
-</html>
<head>
- <?php include_template('header-src.html'); ?>
+ <?php $this->include_template('header-src.html'); ?>
<title><?php echo SITE_TITLE ?> - links</title>
function linklist($links)
{ ?>
<?php foreach($links as $l) : ?>
- <li><a href="http://<?php echo $l[0];?>"><?php echo $l[1];?></a></li>
+ <li><a href="http://<?php echo $l[0];?>"><?php echo $l[1];?></a> →</li>
<?php endforeach; ?>
<?php
}
array('digitanalog.net', 'marc nimoy'),
array('makaga.com', 'matthew gale'),
array('fredericeyl.de', 'frédéric eyl'),
- array('thegreeneyl.com', 'the green eyl'),
- array('local.wasp.uwa.edu.au/~pbourke/', '')
+ array('thegreeneyl.com', 'the green eyl')
+// array('local.wasp.uwa.edu.au/~pbourke/', '')
);
?>
-<?php
-/*
- $items = array();
- $single = false;
-
- if (is_dir(CONTENT_DIR . $url_string) && !is_file(CONTENT_DIR . $url_string . '/config') ) {
- list($items, $total) = get_inline_entries(array('log'));
- //list($log_list, $total) = get_content(basename($url_string), "type=flat");
- }
- else {
- $config = parse_config(CONTENT_DIR . $url_string);
- $log = $config;
- $base_dir = $log['base_dir'];
- $single = true;
- }
-
- $list = isset($_GET['list']) ? $_GET['list'] : false;
-
- $page = "/log";
-*/
-?>
<html>
<head>
<title>
<?=SITE_TITLE; ?>
<? if ($single): ?>
- - log: <?= $entry['title']; ?>
- [<?=date("Y M d", strtotime($entry['date']));?>]
+ - log: <?= $data['title']; ?>
+ [<?=date("Y M d", strtotime($data['date']));?>]
<? else: ?>
- log
<? endif; ?>
<body>
- <?php include('nav.html'); ?>
+ <?php $this->include_template('nav.html'); ?>
<div id="content">
<?php if ($single) : ?>
+
+ <? //$this->include_template('entry.html.tpl', array('entry' => $item)); ?>
<h2>
- <a title="posted <?php echo get_relative_time($item['timestamp']); ?>" href="<?php echo $item['url'];?>">
- <?php echo $item['title']; ?>
- </a><small>[<?php echo date("Y M d", strtotime($item['date']));?>]</small>
- </h2>
-
-
+ <a title="posted <?php echo get_relative_time($data['timestamp']); ?>" href="<?php echo $data['url'];?>">
+ <?php echo $data['title']; ?>
+ </a><small>[<?php echo date("Y M d", strtotime($data['date']));?>]</small>
+ </h2>
<div class="content">
- <?=$item['inline_content'];?>
- </div>
-
+ <?=$data['inline_content'];?>
+ </div>
+
<?php elseif ($view == 'archive'): ?>
<table class="archive" cellspacing="0" cellpadding="0">
</td>
<?php
$c = 1;
- foreach($items as $log):
+ foreach($data as $log):
?>
<tr>
<td style="text-align:right; padding-right:1em;">
</td>
<td>
<strong>
- <a onmouseout="$('.c_pop').hide();" onmouseover="$('.c_pop').hide(); $('#c_<?php echo $c; ?>').show();" href="<?php echo $log['href']?>"><?php echo $log['title']; ?></a>
+ <a onmouseout="$('.c_pop').hide();" onmouseover="$('.c_pop').hide(); $('#c_<?php echo $c; ?>').show();" href="<?php echo $log['url']?>"><?php echo $log['title']; ?></a>
</strong>
<div id="c_<?php echo $c; ?>" class="c_pop">
<?=$log['content']; ?>
<?php else: ?>
<ul class="inline_content log">
- <?php foreach($items as $log): ?>
+ <?php foreach($data as $log): ?>
<li>
<h3>