From: Gabriel Dunne Date: Sun, 11 Jul 2010 07:35:28 +0000 (-0700) Subject: merge from master branch X-Git-Url: https://git.quilime.com/?a=commitdiff_plain;h=4b9dc7ff36ef537e398649a0921e1985d7f11619;p=plog.git merge from master branch --- diff --git a/content/log/2010-07-01_icosi b/content/log/2010-07-01_icosi new file mode 100644 index 0000000..ef966c3 --- /dev/null +++ b/content/log/2010-07-01_icosi @@ -0,0 +1,5 @@ +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 diff --git a/lib/data.php b/lib/data.php index e20e402..9bee7ea 100644 --- a/lib/data.php +++ b/lib/data.php @@ -19,9 +19,10 @@ function get_entries( $path = "", $args = array()) 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); } } @@ -77,7 +78,10 @@ function get_dirs( $path = "", $args = array()) $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; @@ -108,14 +112,14 @@ function parse_entry($fileInfo, $page = 0) $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; } diff --git a/lib/init.php b/lib/init.php index fdb82c0..0dd8647 100644 --- a/lib/init.php +++ b/lib/init.php @@ -5,13 +5,15 @@ 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'; diff --git a/lib/output.php b/lib/output.php index 6866c6c..a7e88e6 100644 --- a/lib/output.php +++ b/lib/output.php @@ -60,7 +60,7 @@ if( !function_exists('parse_ini_string') ) { /** - * removes double slashes + * removes double slashes in path * @param path */ function clean_slashes($path) @@ -69,6 +69,15 @@ 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" @@ -148,8 +157,8 @@ function get_url_parts() 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() . '/')); } diff --git a/lib/template.php b/lib/template.php index a4558e9..c470488 100644 --- a/lib/template.php +++ b/lib/template.php @@ -39,20 +39,17 @@ class Template 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'] : ""; } } diff --git a/public/css/style.css b/public/css/style.css index 9488175..bc8109a 100644 --- a/public/css/style.css +++ b/public/css/style.css @@ -21,7 +21,7 @@ a:hover, a.mute:hover { color:#d15; text-decoration:none; } 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; } @@ -80,7 +80,7 @@ table.archive td {padding-right:20px; } .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; } diff --git a/public/index.php b/public/index.php index e8b9d9f..fbb2931 100644 --- a/public/index.php +++ b/public/index.php @@ -2,42 +2,52 @@ 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); - + ?> diff --git a/templates/404.html.tpl b/templates/404.html.tpl new file mode 100644 index 0000000..a0ed8af --- /dev/null +++ b/templates/404.html.tpl @@ -0,0 +1,23 @@ + + + + include_template('head-inc.html.tpl') ?> + + <?=SITE_TITLE?>: 404 + + + + + include_template('nav.html.tpl') ?> + +
+ + oops

+ 404 + +
+ + include_template('footer.html.tpl') ?> + + + diff --git a/templates/default.html.tpl b/templates/default.html.tpl index d366eb7..7972f03 100644 --- a/templates/default.html.tpl +++ b/templates/default.html.tpl @@ -3,7 +3,7 @@ include_template('head-inc.html.tpl') ?> - <?=$this->page_title('; ');?> + <?=SITE_TITLE?><?=$this->page_title(TITLE_DELIMITER);?> diff --git a/templates/entry.html.tpl b/templates/entry.html.tpl index 6994474..cd68910 100644 --- a/templates/entry.html.tpl +++ b/templates/entry.html.tpl @@ -2,23 +2,21 @@

- ">

-
- posted in
+ posted + in +
- - diff --git a/templates/head-inc.html.tpl b/templates/head-inc.html.tpl index a204510..698331f 100644 --- a/templates/head-inc.html.tpl +++ b/templates/head-inc.html.tpl @@ -1,17 +1,15 @@ - - - - - - - + + + + + + diff --git a/templates/index.html.tpl b/templates/index.html.tpl new file mode 100644 index 0000000..964b92d --- /dev/null +++ b/templates/index.html.tpl @@ -0,0 +1,22 @@ + + + + include_template('head-inc.html.tpl') ?> + + <?=SITE_TITLE?> + + + + + include_template('nav.html.tpl') ?> + +
+ + this is the index template + +
+ + include_template('footer.html.tpl') ?> + + + diff --git a/templates/nav.html.tpl b/templates/nav.html.tpl index 0c33098..c3f612a 100644 --- a/templates/nav.html.tpl +++ b/templates/nav.html.tpl @@ -4,19 +4,16 @@
-

content

- 0)); ?> - -
  • + 0)); ?> + +

  • -

    pages

    - - -
  • + +
  • diff --git a/templates/page.html.tpl b/templates/page.html.tpl index 295ad02..699aae9 100644 --- a/templates/page.html.tpl +++ b/templates/page.html.tpl @@ -3,7 +3,7 @@ include_template('head-inc.html.tpl') ?> - <?=SITE_TITLE?>, <?=$data['title']?> + <?=SITE_TITLE?><?=TITLE_DELIMITER?> <?=$data['title']?> @@ -11,8 +11,6 @@ include_template('nav.html.tpl') ?>
    - -

    diff --git a/templates/single.html.tpl b/templates/single.html.tpl index e169285..91a416f 100644 --- a/templates/single.html.tpl +++ b/templates/single.html.tpl @@ -3,7 +3,7 @@ include_template('head-inc.html.tpl') ?> - <?=SITE_TITLE?>, <?=$data['title'];?> + <?=SITE_TITLE?><?=TITLE_DELIMITER?> <?=$data['title'];?> diff --git a/templates/test.html.tpl b/templates/test.html.tpl new file mode 100644 index 0000000..d71de86 --- /dev/null +++ b/templates/test.html.tpl @@ -0,0 +1,22 @@ + + + + include_template('head-inc.html.tpl') ?> + + <?=SITE_TITLE?><?=$this->page_title(TITLE_DELIMITER);?> + + + + + include_template('nav.html.tpl') ?> + +
    + + this is the TEST TEST TEST template + +
    + + include_template('footer.html.tpl') ?> + + +