template = projects
+title = projects
+--
+
a.mute {
text-decoration: none ! important; }
a:hover, a.mute:hover {
- border: medium none;
color: #0000FF;
text-decoration: underline; }
.thumb {
width:100px;
height:100px;
- border:1px dotted #000;
overflow:hidden;
-
}
comments = comments/
templates = templates/
pages = pages/
+media = media/
config_file = config
data_file = data.json
if (isset($dir_iterator)) {
foreach ($dir_iterator as $file => $info) {
if (!$info->isDir() && $info->getFilename() != CONFIG_FILE) {
+ // dot files
+ if (substr($info->getFilename(), 0, 1) == '.')
+ continue;
$entry = parse_entry($info);
if (!isset($tag)) {
$entries[] = $entry;
}
if ($create_datafile) {
- try {
- if (!is_dir($data_path)) {
- if (!mkdir($data_path, 0777, true)) {
- throw new Exception('Error making data folder. Permissions?');
- }
+ if (!is_dir($data_path)) {
+ if (!mkdir($data_path, 0777, true)) {
+ throw new Exception('Error making data folder. Permissions?');
}
- $fp = fopen( $data_file, 'w');
- fwrite($fp, json_encode(array( 'entries' => $entries )));
- fclose($fp);
- if (!file_exists( $data_file )) {
- throw new Exception('Error creating tags json. Permissions?');
- }
- } catch (Exception $e) {
- echo 'Caught exception: ', $e->getMessage(), "\n";
+ }
+ $fp = fopen( $data_file, 'w');
+ fwrite($fp, json_encode(array( 'entries' => $entries )));
+ fclose($fp);
+ if (!file_exists( $data_file )) {
+ throw new Exception('Error creating tags json. Permissions?');
}
}
}
$path = $local_content . $path;
$path = str_replace("//", "/", $path);
-
- try {
- if (!is_dir($path)) {
- throw new Exception("no such file or directory: $path", 1);
- }
- if ($recursive) {
- $iterator = new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::KEY_AS_PATHNAME);
- $dir_iterator = new RecursiveIteratorIterator($iterator, RecursiveIteratorIterator::SELF_FIRST);
- }
- else {
- $dir_iterator = new DirectoryIterator($path);
- }
- } catch (Exception $e) {
- echo 'Caught exception: ', $e->getMessage(), "\n";
+ if (!is_dir($path)) {
+ throw new Exception("no such file or directory: $path", 1);
+ }
+ if ($recursive) {
+ $iterator = new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::KEY_AS_PATHNAME);
+ $dir_iterator = new RecursiveIteratorIterator($iterator, RecursiveIteratorIterator::SELF_FIRST);
+ }
+ else {
+ $dir_iterator = new DirectoryIterator($path);
}
+
$dirs = array();
foreach ($dir_iterator as $dir => $info) {
if ($info->isDir() && $info->getFilename() != '.' && $info->getFilename() != '..') {
$d = array();
- $d['url'] = str_replace($path, "", $info->getRealPath());
+ $d['url'] = WEB_ROOT . str_replace($path, "", $info->getRealPath());
if (!CLEAN_URLS)
$d['url'] = WEB_ROOT . '?p=' . $d['url'];
$d['name'] = str_replace($path, "", $info->getRealPath());
$content .= $line;
}
- $f = array();
- try {
- $f['config'] = parse_ini_string($config);
- //if (!$f['config']) {
- //echo $config;
- //throw new Exception('bad ini format');
- //}
- }
- catch (Exception $e) {
- echo 'Caught exception: ', $e->getMessage(), "\n";
- exit;
- }
+ $entry = array();
+ $file['config'] = parse_ini_string($config);
+ $file['title'] = isset($file['config']['title']) ? $file['config']['title'] : $fileInfo->getFilename();
+ $file['filename'] = $fileInfo->getFilename();
+ $file['path'] = $fileInfo->getPath();
+ $file['fileInfo'] = $fileInfo;
+ $file['config']['date'] = isset($file['config']['date']) ? $file['config']['date'] : null;
+ $file['timestamp'] = $file['config']['date'] ? date('U', strtotime( $file['config']['date'])) : $fileInfo->getCTime();
+ $file['tags'] = isset($file['config']['tags']) ? explode(" ", $file['config']['tags']) : null;
+ $file['content'] = Markdown($content);
+
+ if ($passed_more)
+ $file['content_short'] = Markdown($content_short);
+
+ $file['comments_enabled'] = isset($f['config']['comments']) && $f['config']['comments'];
+ $file['comments'] = new Comments($fileInfo);
+
+ $cat = clean_slashes(str_replace(LOCAL_ROOT . '/' . CONTENT_DIR, "", $fileInfo->getPath()));
+
+ $file['cat'] = $page ? null : array('name' => substr($cat, 1), 'url' => $cat.'/' );
- $f['title'] = isset($f['config']['title']) ? $f['config']['title'] : $fileInfo->getFilename() ;
- $f['config']['date'] = isset($f['config']['date']) ? $f['config']['date'] : null;
- $f['timestamp'] = $f['config']['date'] ? date('U', strtotime( $f['config']['date'])) : $fileInfo->getCTime();
- $f['tags'] = isset($f['config']['tags']) ? explode(" ", $f['config']['tags']) : null;
- $f['content'] = Markdown($content);
+ $file['path'] = $fileInfo->getRealPath();
+ $file['media'] = MEDIA_DIR . '/' . ($page ? '' : substr($file['cat']['url'],1)) . $fileInfo->getFilename() . '/';
+ $file['thumb'] = isset($file['config']['thumb']) ? $file['config']['thumb'] : MEDIA_DIR . '/' . substr($file['cat']['url'],1) . $fileInfo->getFilename() . '/thumb.png';
+ $file['url'] = WEB_ROOT . ($page ? '' : substr($file['cat']['url'],1)) . $fileInfo->getFilename();
+ $file['cat'] = (object) $file['cat'];
+ $file['config'] = (object) $file['config'];
- $f['comments_enabled'] = isset($f['config']['comments']) && $f['config']['comments'];
- $f['comments'] = new Comments($fileInfo);
+ return (object) $file;
+
+
+ /*
+ $f['title'] = isset($f['config']['title']) ? $f['config']['title'] : $fileInfo->getFilename() ;
+ $f['config']['date'] = isset($f['config']['date']) ? $f['config']['date'] : null;
+ $f['timestamp'] = $f['config']['date'] ? date('U', strtotime( $f['config']['date'])) : $fileInfo->getCTime();
+ $f['tags'] = isset($f['config']['tags']) ? explode(" ", $f['config']['tags']) : null;
+ $f['content'] = Markdown($content);
+
+ $f['comments_enabled'] = isset($f['config']['comments']) && $f['config']['comments'];
+ $f['comments'] = new Comments($fileInfo);
if ($passed_more)
$f['content_short'] = Markdown($content_short);
- $cat = clean_slashes(str_replace(LOCAL_ROOT . CONTENT_DIR, "", $fileInfo->getPath()));
- $clean_path = str_replace(LOCAL_ROOT . CONTENT_DIR, "", clean_slashes($fileInfo->getPath()));
+ $cat = clean_slashes(str_replace(LOCAL_ROOT . CONTENT_DIR, "", $fileInfo->getPath()));
+ $clean_path = str_replace(LOCAL_ROOT . CONTENT_DIR, "", clean_slashes($fileInfo->getPath()));
+
+ //$f['cat'] = $page ? null : array('name' => $clean_path, 'url' => $clean_path );
+ $f['cat'] = clean_slashes(str_replace(LOCAL_ROOT . CONTENT_DIR, "", $fileInfo->getPath()));
+
+ $f['path'] = $fileInfo->getRealPath();
+ $f['url'] = ($page ? WEB_ROOT : WEB_ROOT . $f['cat']['url'] . '/' ) . $fileInfo->getFilename();
- $f['cat'] = $page ? null : array('name' => $clean_path, 'url' => $clean_path );
- $f['path'] = $fileInfo->getRealPath();
- $f['url'] = ($page ? '' : $f['cat']['url'] . '/' ) . $fileInfo->getFilename();
+ echo $f['url'];
+ echo '<br/>';
if (!CLEAN_URLS) {
- $f['cat']['url'] = WEB_ROOT . '?p=' . $f['cat']['url'];
- $f['url'] = WEB_ROOT . '?p=' . $f['url'];
+ $f['cat']['url'] = WEB_ROOT . '?p=' . $f['cat']['url'];
+ $f['url'] = WEB_ROOT . '?p=' . $f['url'];
}
$f['cat'] = (object) $f['cat'];
$f['config'] = (object) $f['config'];
- return (object) $f;
+ return (object) $f;
+ */
}
function get_comments_location ( &$fileInfo ) {
define ('CONTENT_DIR', $_cfg['content']);
define ('COMMENTS_DIR', $_cfg['comments']);
define ('DATA_DIR', $_cfg['data']);
+define ('MEDIA_DIR', $_cfg['media']);
define ('DATA_FILE', $_cfg['data_file']);
define ('TEMPLATE_DIR', $_cfg['templates']);
define ('PAGE_DIR', $_cfg['pages']);
// prev/next
$entries = get_entries( $request['dirname'] );
for($i = count($entries)-1; $i>=0; $i--) {
- if ($this->entry['url'] == $entries[$i]['url']) {
- $this->entry['prev_entry'] = isset($entries[$i-1]) ? $entries[$i-1] : null;
- $this->entry['next_entry'] = isset($entries[$i+1]) ? $entries[$i+1] : null;
+ if ($this->entry->url == $entries[$i]->url) {
+ $this->entry->prev_entry = isset($entries[$i-1]) ? $entries[$i-1] : null;
+ $this->entry->next_entry = isset($entries[$i+1]) ? $entries[$i+1] : null;
break;
}
}
- $this->entry['is_single'] = true;
+ $this->entry->is_single = true;
$this->template = 'single.' . $this->response_format . '.tpl';
}
+++ /dev/null
-title = aggregate
-template = agg
---
+++ /dev/null
-<html>
-<head>
-
- <?php $this->include_template('head-inc.html.tpl'); ?>
-
- <title><?=SITE_TITLE?>: aggregate</title>
-
-</head>
-<body>
-
- <? $this->include_template('nav.html.tpl') ?>
-
-<div id="content">
-
- <table border="0" id="agg"><tr>
-
- <!-- quilime:aggregate -->
- <td valign="top" class="column">
-
-<?
- $agg = get_rss_feed('http://media.quilime.com/aggregate/index.php?return=rss');
-?>
- <h2><a href="http://media.quilime.com/aggregate/">image</a></h2>
- <ul class="image">
-
-<?
- $count = 10;
- foreach($agg->channel->item as $item) :
- if (!$count--) break;
- ?>
- <li title="<?=$item->title?>">
- <a href="<?=$item->link?>"><img src="<?=$item->thumb?>"></a>
- </li>
- <? endforeach; ?>
- </ul>
-
- <p>
- <a class="rss" href="http://media.quilime.com/aggregate/index.php?return=rss">rss</a>, <a class="more" href="http://media.quilime.com/aggregate" title="via quilime.com/aggregate">more →</a>
- </p>
-
- </td>
-
- <td valign="top" class="column">
- <?php $vid = get_rss_feed('http://quilime.tumblr.com/rss'); ?>
- <h2><a href="http://quilime.tumblr.com/">video</a></h2>
- <script>
- function vtog(count) {
- $('.vid').hide();
- $('#vid_' + count).show();
- }
- </script>
- <ul class="video">
- <?php
-
- $count = 11;
-
- foreach($vid->channel->item as $v) :
- if ($count-- == 0) break;
- ?>
- <li title="<?php echo str_replace('"', '\'', $v->title); ?>">
- <?
- $desc = $v->description;
- $patterns = array('/player.vimeo.com/', '/youtube.com/');
- foreach($patterns as $p) {
- preg_match($p, $desc, $matches);
- echo '<a onClick="vtog('.$count.');" href="#">';
- if (sizeof($matches) > 0) {
- // vimeo
- if ('/'.$matches[0].'/' == $patterns[0]) {
- // get video thumbnail for vimeo
- $pattern = '/http:\/\/player.vimeo.com\/video\/(\\d+)/';
- preg_match($pattern, $desc, $m);
- $video_url = "http://vimeo.com/". $m[1] ;
- $file = fopen($video_url, "r");
- $filedata = stream_get_contents($file);
- $html_content = strpos($filedata,"<meta property=\"og:image\"");
- $link_string = substr($filedata, $html_content + 35, 128);
- $video_id_array = explode("\"", $link_string);
- $thumbnail_url = $video_id_array[0];
- echo '<img style="width:120px; height:90px;" src="'.$thumbnail_url.'">';
- }
- // youtube
- if ('/'.$matches[0].'/' == $patterns[1]) {
- $pattern = '/http:\/\/www.youtube.com\/v\/(.+?)&/';
- preg_match($pattern, $desc, $m);
- echo '<img src="http://i3.ytimg.com/vi/'.$m[1].'/default.jpg" />';
- }
- }
- echo '</a>';
- }
- ?>
- <div class="vid" id="vid_<?=$count?>" style="display:none;">
- <?=$v->description ?>
- </div>
- </li>
- <?
- endforeach;
-
-
-
-/*
-// get video thumbnail for vimeo
-$video_url = "http://vimeo.com/15592943" ;
-$file = fopen($video_url, "r");
-$filedata = stream_get_contents($file);
-$html_content = strpos($filedata,"<meta property=\"og:image\"");
-$link_string = substr($filedata, $html_content + 35, 49);
-$video_id_array = explode("\"", $link_string);
-echo("LINK: " . $link_string);
-$thumbnail_url = $filedata[3];
-// echo $thumbnail_url;
-echo '<img src="'.$link_string.'">';
-
- */
-
-
- ?>
- </ul>
- <p>
- <a class="rss" href="http://quilime.tumblr.com/rss">rss</a>,
- <a class="more" href="http://quilime.tumblr.com" title="via tumblr">more →</a>
- </p>
- </td>
-
-
-<? /*
- <td valign="top" class="column">
- <?php $tube = get_rss_feed('http://gdata.youtube.com/feeds/base/users/quilime/favorites?alt=rss&v=2&orderby=published&client=ytapi-youtube-profile'); ?>
- <h2><a href="http://www.youtube.com/profile?user=kabr&view=favorites">video </a></h2>
- <ul class="video">
- <?php
- $count = 11;
- foreach($tube->channel->item as $tube) :
- if ($count-- == 0) break;
- ?>
- <li title="<?php echo str_replace('"', '\'', $tube->title); ?>">
- <?
- $url = $tube->link;
- $pattern = '/v=(.+?)&/';
- preg_match($pattern, $url, $matches);
- $id = $matches[1];
- ?>
- <a href="<?php echo $tube->link; ?>">
-
- <img src="http://i3.ytimg.com/vi/<?=$id?>/default.jpg" />
- </a>
- </li>
- <? endforeach; ?>
- </ul>
- <p>
- <a class="more" href="http://www.youtube.com/profile?user=quilime&view=favorites" title="via youtube">more →</a>
- </p>
- </td>
-*/ ?>
-<? /*
- <!-- quilime:flickr -->
- <td valign="top" class="column">
- <h3><a href="http://flickr.com/photos/quilime/">flickr</a></h3>
- <ul>
- <? $count = 8; $img = get_rss_feed('http://api.flickr.com/services/feeds/photos_public.gne?id=28394478@N00&lang=en-us&format=rss_200'); ?>
- <?php foreach($img->channel->item as $item) : if (!$count--) break; ?>
- <li>
- <?
- $subject = $item->description;
- $pattern = '/<a href="http:\/\/www\.flickr\.com\/photos\/quilime\/(.*) \/><\/a><\/p>/';
- preg_match($pattern, substr($subject, 3), $matches, PREG_OFFSET_CAPTURE);
- echo $matches[0][0];
- ?>
- </li>
-<?endforeach;?>
- </ul>
- <p>
- <a class="ext" href="http://api.flickr.com/services/feeds/photos_public.gne?id=28394478@N00&lang=en-us&format=rss_200">rss</a>, <a class="more" href="http://flickr.com/photos/quilime/" title="via flickr">more →</a>
- </p>
- </td>
-*/ ?>
-
-
- <!-- quilime:delicious -->
- <td valign="top" class="column">
-
-<?
- $url = 'https://<login>:<pass>@api.del.icio.us/v1/posts/recent';
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
- curl_setopt($ch, CURLOPT_TIMEOUT, 5);
- curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
- $data = curl_exec($ch);
- curl_close($ch);
- $del = new SimpleXMLElement($data);
-?>
-
- <h2><a href="http://delicious.com/quilime/">link</a></h2>
-
- <ul class="bookmarks">
- <?php foreach($del->post as $d) : ?>
- <li>
- <a href="<?=$d['href']?>"><?=$d['description'];?></a>
-
-<? /* <em><? echo get_relative_time(strtotime($d['time'])); ?> </em> */ ?>
-
- <div class="desc"><?=$d['extended'];?></div>
- <small style="color:#aaa;" class="tags"><em><? $t = explode(" ", $d['tag']); echo implode(", ", $t); ;?></em></small>
- </li>
- <? endforeach; ?>
- </ul>
-
- <p>
- <a class="rss" href="http://feeds.delicious.com/v2/rss/quilime?count=15">rss</a>, <a class="more" href="http://delicious.com/quilime/" title="via delicious">more →</a>
- </p>
-
- </td>
-
-
-
-
- </tr></table>
-
- </div>
-
- <? $this->include_template('footer.html.tpl'); ?>
-
-</body>
-</html>
\ No newline at end of file
?>
<? if (isset($single) && $single) : ?>
- <div class="arrow" title="<?=$entry->cat->entry?>">
+ <div class="arrow" title="<?=$entry->cat->name?>">
<a href="<?=$entry->cat->url?>">←</a>
</div>
<? else : ?>
<? $this->include_template('head-inc.html.tpl') ?>
- <title><?=SITE_TITLE?>: <?=$page_title?></title>
+ <title><?=SITE_TITLE?>: <?=$entry->title?></title>
</head>
<body>
<div id="content">
+
<ul class="projects">
<? foreach($entries as $entry): ?>
<li>
<? $this->include_template('head-inc.html.tpl') ?>
- <title><?=$entry['title'];?></title>
+ <title><?=$entry->title;?></title>
</head>
<body>
- <div id="content" class="single">
- <?
- if (isset($entry['config']['template'])) {
- $this->include_template($entry['config']['template'] . '.' . $this->response_format . '.tpl');
- }
- else {
- $this->include_template('entry.' . $this->response_format . '.tpl');
- }
- ?>
+ <? $this->include_template('nav.html.tpl') ?>
+ <div id="content" class="single entry">
+ <div class="entry">
+ <? $this->include_template('entry.html.tpl', array('entry' => $entry, 'single' => true)); ?>
+ </div>
</div>
- <? $this->include_template('nav.html.tpl') ?>
<? $this->include_template('footer.html.tpl') ?>
</body>
class AllTests extends TestSuite {
function AllTests() {
- $this->TestSuite('All tests');
$this->addFile('lib/test/data_test.php');
}
}