--- /dev/null
+title = icosi fabrication progress
+date = 2010-07-07
+tags = icosi fabrication
+--
+[![img](http://farm5.static.flickr.com/4140/4773799092_75e68e4e66.jpg)](http://www.flickr.com/photos/quilime/4773799092/)
\ No newline at end of file
else {
$dir_iterator = new DirectoryIterator($path);
}
+
$entries = array();
foreach ($dir_iterator as $file => $info) {
- if (!$info->isDir()) {
+ if (!$info->isDir() && $info->getFilename() != CONFIG_FILE) {
$entries[] = parse_entry($info);
}
}
$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;
}
ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . dirname(realpath(__FILE__)));
define ('SITE_TITLE', 'quilime');
- define ('LOCAL_ROOT', '/home/quilime/quilime-site/' );
- define ('WEB_ROOT', 'http://quilime.com/' );
+ define ('LOCAL_ROOT', '/home/quilime/plog/plog/');
+ define ('WEB_ROOT', 'http://dev.quilime.com/');
define ('CONTENT_DIR', 'content');
- define ('PAGE_DIR', 'pages');
define ('TEMPLATE_DIR', 'templates');
+ define ('PAGE_DIR', 'pages');
define ('CONFIG_DELIMITER', '--');
+ define ('TITLE_DELIMITER', ': ');
+ define ('CONFIG_FILE', 'config');
require_once 'data.php';
require_once 'output.php';
/**
- * removes double slashes
+ * removes double slashes in path
* @param path
*/
function clean_slashes($path)
}
+/**
+ * makes sure path is valid
+ */
+function validate_path()
+{
+
+}
+
+
/**
* @param int $seconds Number of seconds to convert into a human-readable timestamp
* @return tring Human-readable approximate timestamp like "2 hours"
function get_url()
{
-$path_info = pathinfo($_SERVER['SCRIPT_URL']);
-$path_info['url'] = $_SERVER['SCRIPT_URL'];
+ $path_info = pathinfo($_SERVER['SCRIPT_URL']);
+ $path_info['url'] = preg_match("/\.\.\//", $_SERVER['SCRIPT_URL']) ? '/' : $_SERVER['SCRIPT_URL'];
return $path_info; //substr($_SERVER['SCRIPT_URL'], strlen(get_base_dir() . '/'));
}
public function render( $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');
-
-
}
public function page_title($delim)
{
- return SITE_TITLE . (isset($this->_tpl_vars['page_title']) ? $delim . $this->_tpl_vars['page_title'] : "");
+ return isset($this->_tpl_vars['page_title']) ? $delim . $this->_tpl_vars['page_title'] : "";
}
}
h1, h2, h3, h4, h5, h6 { font-size:1em; }
h1 a, h2 a, h3 a, h4 a, h5 a, h6 a { }
h1 { margin:0 0 3em 0; }
-h2 { margin:0 0 0.5em 0; }
+h2 { margin:0 0 0.5em 0; }
h3 { margin:0 0 0 0; }
ol li { list-style-type:decimal; }
.indent { text-indent:3em; }
.entry { margin-bottom:100px; }
-.entry h2 { border-bottom:1px solid #ddd; padding-bottom:4px; }
+.entry h2 { padding-bottom:4px; font-size:1.3em; }
.entry h2 .title-date { font-weight:normal; color:#bbb; }
.entry .metadata { margin-top:20px; font-style:italic; color:#aaa; }
.entry .metadata .tags li { display:inline-block; margin-right:1em; }
require_once '../lib/init.php';
- $url_parts = get_url();
+ $url = get_url();
+
+ list($response_format, $response_mime_type) = parse_format($url['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);
+
+ $content_request = LOCAL_ROOT . CONTENT_DIR . $url['dirname'] . '/' . $url['filename'];
+ $page_request = LOCAL_ROOT . PAGE_DIR . DIRECTORY_SEPARATOR . $url['filename'];
+
+ # content exists, and is a folder
+ if (is_dir($content_request)) {
+ # get config in folder, if exists
+ if (is_file($content_request . '/' . CONFIG_FILE )) {
+ $config = parse_entry(new SplFileInfo($content_request . '/' . CONFIG_FILE));
+ $template = $config['config']['template'] . '.' . $response_format . '.tpl' ;
+ }
+ list($data, $total) = get_entries($url['dirname'] . '/' . $url['filename']);
+ $t->assign('data', $data);
+ $t->assign('page_title', preg_replace('{^/|/$}', '', $url['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';
+
+ # content exists, and is a single entry
+ else if (is_file($content_request)) {
+ $t->assign('data', parse_entry(new SplFileInfo($content_request)));
+ $t->assign('single', true);
+ $template = 'single.'.$response_format.'.tpl';
}
- # is page
- else if (is_file( LOCAL_ROOT . PAGE_DIR . $url_parts['url'])) {
- $page = parse_entry(new SplFileInfo(LOCAL_ROOT . PAGE_DIR . $url_parts['url']), 1);
+
+ # content exists, and is a page
+ else if (is_file($page_request)) {
+ $page = parse_entry(new SplFileInfo($page_request), 1);
$t->assign('data', $page);
$template = $page['config']['template'] ? $page['config']['template'] . '.' . $response_format . '.tpl' : 'page.' . $response_format . '.tpl';
}
- # default (all entries)
+
+ # 404
else {
- list($data, $total) = get_entries();
- $t->assign('data', $data);
+ $template = '404.html.tpl';
}
-
+
# render
- $t->assign('total', $total);
+ $t->assign('total', $total);
header("Content-Type: {$response_mime_type}; charset=UTF-8");
$t->render($template);
-
+
?>
--- /dev/null
+<html>
+<head>
+
+ <? $this->include_template('head-inc.html.tpl') ?>
+
+ <title><?=SITE_TITLE?>: 404</title>
+
+</head>
+<body>
+
+ <? $this->include_template('nav.html.tpl') ?>
+
+<div id="content">
+
+ oops <br /><br />
+ 404
+
+</div>
+
+ <? $this->include_template('footer.html.tpl') ?>
+
+</body>
+</html>
<? $this->include_template('head-inc.html.tpl') ?>
- <title><?=$this->page_title('; ');?></title>
+ <title><?=SITE_TITLE?><?=$this->page_title(TITLE_DELIMITER);?></title>
</head>
<body>
<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>
-
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="alternate" type="application/rss+xml" title="RSS" href="<?= get_base_dir(); ?>/.rss" />
-
<link rel="stylesheet" href="<?= get_base_dir(); ?>/css/style.css" type="text/css">
-<link href="<?= get_base_dir(); ?>/js/prettify/prettify.css" type="text/css" rel="stylesheet" />
-
-<script type="text/javascript" src="<?= get_base_dir(); ?>/js/jquery-1.3.2.min.js"></script>
-<script type="text/javascript" src="<?= get_base_dir(); ?>/js/prettify/prettify.js"></script>
-
-
+<link href="<?= get_base_dir(); ?>/js/prettify/prettify.css" type="text/css" rel="stylesheet" />
+ <script type="text/javascript" src="<?= get_base_dir(); ?>/js/jquery-1.3.2.min.js"></script>
+<script type="text/javascript" src="<?= get_base_dir(); ?>/js/prettify/prettify.js"></script>
+
<script>
$(document).ready(function() {
prettyPrint();
});
-</script>
+</script>
+
--- /dev/null
+<html>
+<head>
+
+ <? $this->include_template('head-inc.html.tpl') ?>
+
+ <title><?=SITE_TITLE?></title>
+
+</head>
+<body>
+
+ <? $this->include_template('nav.html.tpl') ?>
+
+<div id="content">
+
+ this is the index template
+
+</div>
+
+ <? $this->include_template('footer.html.tpl') ?>
+
+</body>
+</html>
<br />
- <h2>content</h2>
- <? $dirs = get_dirs("/", array('recursive' => 0)); ?>
- <? foreach($dirs as $d) : ?>
- <li><a href="<?=get_base_dir();?>/<?=$d?>"><?=$d?></a></li>
+ <? $dirs = get_dirs("", array('recursive' => 0)); ?>
+ <? foreach($dirs as $dir) : ?>
+ <li><a href="<?=$dir['url']?>"><?=$dir['name']?></a></li>
<? endforeach; ?>
<br />
- <h2>pages</h2>
-
<? $pages = get_pages(); ?>
- <? foreach($pages as $p) : ?>
- <li><a href="<?=$p['url']?>"><?=$p['title']?></a></li>
+ <? foreach($pages as $page) : ?>
+ <li><a href="<?=$page['url']?>"><?=$page['title']?></a></li>
<? endforeach; ?>
</ul>
<? $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>
--- /dev/null
+<html>
+<head>
+
+ <? $this->include_template('head-inc.html.tpl') ?>
+
+ <title><?=SITE_TITLE?><?=$this->page_title(TITLE_DELIMITER);?></title>
+
+</head>
+<body>
+
+ <? $this->include_template('nav.html.tpl') ?>
+
+<div id="content">
+
+ this is the TEST TEST TEST template
+
+</div>
+
+ <? $this->include_template('footer.html.tpl') ?>
+
+</body>
+</html>