--- /dev/null
+title = a generic entry
+date = 2009-06-05
+tags = generic entry
+--
+the actual entry for this generic entry
+
+it's multi line
+
+`and it's got code!`
+
+wow.
\ No newline at end of file
--- /dev/null
+title = a mel entry
+tags = some tags for this mel entry
+--
+the actual entry
\ No newline at end of file
+++ /dev/null
-title = Luminosity at UV coord
-date = 2009/02/15
-medium = maya/mel
+++ /dev/null
-<p>
-Get luminosity of texture at UV coord in Maya with custom rgbToHsv node.
-</p>
-
-<pre class="prettyprint lang-mel">
-global proc float getLuminosityAtUVCoord(string $texture, float $U, float $V)
-{
- $id = "lum"; // unique identifier in case there are duplicate nodes
- $rgbToHsv = "rgbToHsv_" + $id ; // create rgbToHSV node if necesarry
- if(!`objExists $rgbToHsv`) {
- createNode rgbToHsv -n $rgbToHsv;
- }
-
- vector $color = `colorAtPoint -o RGB -u $U -v $V $texture`;
-
- setAttr ($rgbToHsv+".ir") ($color.x);
- setAttr ($rgbToHsv+".ig") ($color.y);
- setAttr ($rgbToHsv+".ib") ($color.z);
-
- return `getAttr ($rgbToHsv+".ov")`;
-}
-</pre>
-
-<h3>to use</h3>
-<pre class="prettyprint lang-mel">
-// returns luminosity value of 0.5 U 0.5 V on texture file_seq
-$value = getLuminosityAtUVCoord("file_seq", 0.5, 0.5);
-</pre>
-
-</pre>
\ No newline at end of file
+++ /dev/null
-title = Sphere Intersect
-date = 2009-06-12
-medium = maya/mel
\ No newline at end of file
+++ /dev/null
-<p>
-Function to return location of intersect with poly mesh and spherical object moving in the positive direction on the Y axis.
-<br/>
-</p>
-
-<h2>
-mel source
-</h2>
-<pre class="prettyprint lang-mel">
-
-global proc intersectSphereY()
-{
- print(". . . . . go go go\n");
-
- int $iter = 50;
- float $start[3] = {0, -0.5, 0};
- float $limit[3] = {0, 5.0, 0};
- $mesh = "test_mesh";
- $tmpCN = "cpom";
-
-
- $obj = "rod1";
- float $radius = 0.5;
- float $curPos[3] = {0, 0, 0};
-
- for ($i = 0; $i <= $iter; $i++)
- {
- $mesh = "test_mesh";
- $shape = `listRelatives -shapes $mesh`;
-
- createNode -n $tmpCN closestPointOnMesh;
- connectAttr -f ($shape[0] + ".outMesh") ($tmpCN + ".inMesh");
- setAttr ($tmpCN + ".inPosition") $curPos[0] $curPos[1] $curPos[2];
-
- $cpom = `getAttr ($tmpCN + ".position")`;
-
- if ( pointDist($curPos, $cpom) <= $radius ) {
- return ". . bonk\n";
- }
-
- $curPos[1] = ($limit.y) / $iter * $i;
- setAttr ($obj + ".translateY") $curPos[1];
-
- delete $tmpCN;
- }
- return ". nope\n";
-}
-
-global proc float pointDist(float $p1[], float $p2[])
-{
- return sqrt(
- (($p1[0] - $p2[0]) * ($p1[0] - $p2[0])) +
- (($p1[1] - $p2[1]) * ($p1[1] - $p2[1])) +
- (($p1[2] - $p2[2]) * ($p1[2] - $p2[2])));
-}
-
-intersectSphereY;
-
-</pre>
-
-
-
-
-
-<img src="http://media.quilime.com/files/img/sphere_intersect.png">
\ No newline at end of file
--- /dev/null
+title = a test entry in category 1
+--
+the actual entry of this test entry
\ No newline at end of file
--- /dev/null
+title = wow another test
+--
+woot woot!
\ No newline at end of file
--- /dev/null
+title = again!
+--
+yeah, again, that's right
\ No newline at end of file
--- /dev/null
+title = Installation Project
+tags = install project
+--
+an installation project
\ No newline at end of file
--- /dev/null
+title = project 1
+tags = what what what
+--
+some content
\ No newline at end of file
--- /dev/null
+title = "project2"
+tags = what the eff
+--
+project 2
\ No newline at end of file
<?php
/**
- * get data
+ * return entries of a folder
+ * @param path: the path to search. defaults to the CONTENT_DIR
+ * @param args array
*/
-function get_data( $sources = array(), $params = array())
+function get_entries( $path = "", $args = array())
{
- // if no set sources, grab everything in the content folder
- if (sizeof($sources) == 0)
- $sources = get_content_folders();
-
- $result = array();
- $result_total = 0;
- foreach ($sources as $dir) {
-
- if (is_array($dir) && isset($dir['basename']))
- $dir = $dir['basename'];
-
- $contents = glob(LOCAL_ROOT . CONTENT_DIR . DIRECTORY_SEPARATOR . $dir . '/*');
-
- if (sizeof($contents) <= 0) continue;
-
- foreach ($contents as $f) {
- if (is_file($f)) {
-
- if ($params['name']) {
- if (basename($f) != $params['name'])
- continue;
- }
-
- $parsed = parse_file($f);
-
- if ($parsed['draft'])
- continue;
-
- $result[] = $parsed;
- $result_total++;
- }
+ $recursive = isset($args['recursive']) ? $args['recursive'] : 1;
+ $order_by = empty($args['order_by']) ? null : $args['order_by'];
+ $order = empty($args['order']) ? SORT_DESC : $args['order'];
+
+ $path = LOCAL_ROOT . CONTENT_DIR . $path;
+ if ($recursive) {
+ $iterator = new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::KEY_AS_PATHNAME);
+ $dir_iterator = new RecursiveIteratorIterator($iterator, RecursiveIteratorIterator::SELF_FIRST);
+ }
+ else {
+ $dir_iterator = new DirectoryIterator($path);
+ }
+ $entries = array();
+ foreach ($dir_iterator as $file => $info) {
+ if (!$info->isDir()) {
+ $entries[] = parse_entry($info);
}
}
-
- // order by date
- foreach ($result as $key => $row) {
- $time[$key] = $row['timestamp'];
+
+ switch ($order_by)
+ {
+ default :
+ foreach ($entries as $key => $row)
+ $time[$key] = $row['timestamp'];
+ if ($time)
+ array_multisort($time, $order, $entries);
}
- if ($time)
- array_multisort($time, SORT_DESC, $result);
-
- return array($result, $result_total);
+
+ return array($entries, sizeof($entries));
}
/**
- * parse data file
+ * get pages
*/
-function parse_file($f)
+function get_pages()
{
- $pathparts = explode("/", dirname($f));
-
- $file_contents = explode("\n", file_get_contents($f, FILE_USE_INCLUDE_PATH));
- $cc = "";
- $content = "";
- $conf = true;
- foreach ( $file_contents as $fc ) {
- if ($fc == CONFIG_DELIMITER) {
- $conf = false;
- continue;
- }
- if ($conf) $cc .= $fc . "\n";
- else $content .= $fc . "\n";
+ $path = LOCAL_ROOT . PAGE_DIR;
+ $dir_iterator = new DirectoryIterator($path);
+ $pages = array();
+ foreach($dir_iterator as $page) {
+ if ($page->isDir()) continue;
+ $arr = parse_entry($page, 1);
+ $arr['is_page'] = 1;
+ $pages[] = $arr;
}
-
- $config = parse_ini_string($cc);
-
- $res = $config;
-
- $res['url'] = $res['is_page'] == 1 ? get_base_dir() . '/' . basename($f) . '/' : get_base_dir() . '/' . $pathparts[sizeof($pathparts)-1] . '/' . basename($f);
- $res['timestamp'] = date('U', strtotime( $config['date'] ? $config['date'] : filemtime($f)));
- $res['cat'] = $pathparts[sizeof($pathparts)-1];
- $res['content'] = Markdown($content);
- $res['tags'] = explode(' ', $config['tags']);
-
- return $res;
+ return $pages;
}
/**
- * get content folders
+ * returns directories of a folder
+ * @param path the path to search. defaults to the CONTENT_DIR
+ * @param recursive default is true
*/
-function get_content_folders()
+function get_dirs( $path = "", $args = array())
{
- $folders = glob(LOCAL_ROOT . CONTENT_DIR . DIRECTORY_SEPARATOR . '/*', GLOB_ONLYDIR);
- $content_folders = array();
- foreach($folders as $folder)
- $content_folders[] = array(
- 'basename' => basename($folder),
- 'title' => basename($folder),
- 'url' => get_base_dir() . '/' . basename($folder) . '/'
- );
- return $content_folders;
+ $recursive = isset($args['recursive']) ? $args['recursive'] : 1;
+ $path = LOCAL_ROOT . CONTENT_DIR . $path;
+
+ 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() != '..') {
+ $dirs[] = str_replace($path, "", $info->getRealPath());
+ }
+ }
+ return $dirs;
}
/**
- * get pages
+ * @param splFileInfo SPLFileInfo Object
+ * @param include_drafts default is false
*/
-function get_pages()
+function parse_entry($fileInfo, $page = 0)
{
- $page_files = glob(LOCAL_ROOT . PAGE_DIR . DIRECTORY_SEPARATOR . '/*');
- $pages = array();
- foreach($page_files as $page) {
- $arr = parse_file($page);
- $arr['is_page'] = 1;
- $pages[] = $arr;
+ $config = "";
+ $content = "";
+ $passed_config = false;
+ $file_contents = file($fileInfo->getRealPath(), FILE_USE_INCLUDE_PATH);
+ foreach ( $file_contents as $line ) {
+ if (trim($line) == CONFIG_DELIMITER) {
+ $passed_config = true;
+ continue;
+ }
+ if (!$passed_config) {
+ $config .= $line;
+ continue;
+ }
+ $content .= $line;
}
- return $pages;
+
+ $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);
+ $file['path'] = $fileInfo->getRealPath();
+ $file['url'] = WEB_ROOT . $file['cat'] . $fileInfo->getFilename();
+
+ return $file;
}
+
?>
define ('SITE_TITLE', 'quilime');
define ('LOCAL_ROOT', '/home/quilime/quilime-site/' );
- define ('WEB_ROOT', 'http://py.quilime.com/' );
+ 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', '--');
require_once 'data.php';
}
+/**
+ * removes double slashes
+ */
+function clean_slashes($path)
+{
+ return preg_replace('/\/+/', '/', $path);
+}
+
+
/**
* @param int $seconds Number of seconds to convert into a human-readable timestamp
* @return tring Human-readable approximate timestamp like "2 hours"
--- /dev/null
+title = agg
+template = agg
+--
list($response_format, $response_mime_type) = parse_format($url_parts['extension'], 'html');
+ # setup template
$t = get_template_instance();
$t->response_format = $response_format;
$t->assign('view', $_GET['v']);
- # content folder
- if (is_dir(LOCAL_ROOT . CONTENT_DIR . DIRECTORY_SEPARATOR . $url_parts['url']) && $url_parts['url'] != "/") {
- list($data, $total) = get_data(array($url_parts['url']));
+ # 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('data', $data);
}
- # single file
- else if (is_file( LOCAL_ROOT . CONTENT_DIR . $url_parts['dirname'] . DIRECTORY_SEPARATOR . $url_parts['filename'])) {
- $t->assign('single', true);
- $t->assign('data', parse_file(LOCAL_ROOT . CONTENT_DIR . $url_parts['dirname'] . DIRECTORY_SEPARATOR . $url_parts['filename']));
+ # 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';
}
- # page
- else if (is_file( LOCAL_ROOT . PAGE_DIR . DIRECTORY_SEPARATOR . $url_parts['filename'] )) {
- $page = parse_file(LOCAL_ROOT . PAGE_DIR . DIRECTORY_SEPARATOR . $url_parts['filename']);
+ # 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);
$t->assign('data', $page);
- $template = $page['template'] ? $page['template'] . '.' . $response_format . '.tpl' : 'page.' . $response_format . '.tpl';
+ $template = $page['config']['template'] ? $page['config']['template'] . '.' . $response_format . '.tpl' : 'page.' . $response_format . '.tpl';
}
- # direct template
- else if (is_file( LOCAL_ROOT . TEMPLATE_DIR . DIRECTORY_SEPARATOR . $url_parts['filename'] .'.'. $response_format . '.tpl')) {
- $template = $url_parts['filename'] . '.' . $response_format . '.tpl';
- }
- # default (index)
+ # default (all entries)
else {
- list($data, $total) = get_data();
+ list($data, $total) = get_entries();
$t->assign('data', $data);
}
-
- # render template
+ # render
$t->assign('total', $total);
header("Content-Type: {$response_mime_type}; charset=UTF-8");
$t->render($template);
<div id="content">
- <? foreach($data as $entry): ?>
+ <? if (sizeof($data) > 0) foreach($data as $entry): ?>
<? $this->include_template('entry.html.tpl', array('data' => $entry)); ?>
<? endforeach; ?>
<? if ($single) :?>
<div class="metadata">
- posted <?=date("F d, Y", $data['timestamp'])?> in <a href="/<?=$data['cat'];?>/"><?=$data['cat'];?></a><br/>
+ posted <?=date("F d, Y", $data['timestamp'])?> in <a href="<?=get_base_dir();?>/<?=$data['cat'];?>"><?=$data['cat'];?></a><br/>
<ul class="tags">
- <? foreach($data['tags'] as $tag) : ?>
+ <? if (sizeof($data['tags']) > 0) foreach($data['tags'] as $tag) : ?>
<li>#<?=$tag?></li>
<? endforeach; ?>
</ul>
<? endif; ?>
</div>
+
<br />
- <? $categories = get_content_folders(); ?>
- <? foreach($categories as $cat) : ?>
- <li><a href="<?=$cat['url']?>"><?=$cat['title']?></a></li>
+ <h2>content</h2>
+ <? $dirs = get_dirs("/", array('recursive' => 0)); ?>
+ <? foreach($dirs as $d) : ?>
+ <li><a href="<?=get_base_dir();?>/<?=$d?>"><?=$d?></a></li>
<? endforeach; ?>
<br />
- <li><a href="/agg/">aggregate</a></li>
- <li><a href="/links/">links</a></li>
- <li><a href="/about/">about</a></li>
+ <h2>pages</h2>
+
+ <? $pages = get_pages(); ?>
+ <? foreach($pages as $p) : ?>
+ <li><a href="<?=$p['url']?>"><?=$p['title']?></a></li>
+ <? endforeach; ?>
</ul>