From fe025eb4ed3133d28245cddb203da7eb7615165d Mon Sep 17 00:00:00 2001 From: Gabriel Dunne Date: Fri, 9 Jul 2010 18:14:58 -0700 Subject: [PATCH] new templates, new index file --- public/index.php | 36 ++++++++++++++++++++---------------- templates/default.html.tpl | 4 ++-- templates/default.txt.tpl | 2 +- templates/page.html.tpl | 4 +++- templates/single.html.tpl | 2 +- 5 files changed, 27 insertions(+), 21 deletions(-) diff --git a/public/index.php b/public/index.php index d7221da..f73f29e 100644 --- a/public/index.php +++ b/public/index.php @@ -6,35 +6,39 @@ 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']); - # is folder - if (is_dir(LOCAL_ROOT . CONTENT_DIR . $url_parts['url']) && $url_parts['url'] != "/") { - list($data, $total) = get_entries($url_parts['url']); + # 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'])); + $t->assign('page_title', preg_replace('{^/|/$}', '', $url_parts['url'])); $t->assign('data', $data); } - # 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']))); + # 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'])); $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); - $t->assign('data', $page); - $template = $page['config']['template'] ? $page['config']['template'] . '.' . $response_format . '.tpl' : 'page.' . $response_format . '.tpl'; + # page + else if (is_file( LOCAL_ROOT . PAGE_DIR . DIRECTORY_SEPARATOR . $url_parts['filename'] )) { + $t->assign('data', parse_file(LOCAL_ROOT . PAGE_DIR . DIRECTORY_SEPARATOR . $url_parts['filename'])); + $template = 'page.' . $response_format . '.tpl'; } - # default (all entries) + # 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) else { - list($data, $total) = get_entries(); + list($data, $total) = get_data(); $t->assign('data', $data); } - # render + + # render template $t->assign('total', $total); header("Content-Type: {$response_mime_type}; charset=UTF-8"); $t->render($template); diff --git a/templates/default.html.tpl b/templates/default.html.tpl index 678ebc3..f5f9572 100644 --- a/templates/default.html.tpl +++ b/templates/default.html.tpl @@ -3,7 +3,7 @@ include_template('head-inc.html.tpl') ?> - <?=SITE_TITLE?><?=$this->title();?> + <?=SITE_TITLE?>, <?=$page_title?> @@ -12,7 +12,7 @@
- 0) foreach($data as $entry): ?> + include_template('entry.html.tpl', array('data' => $entry)); ?> diff --git a/templates/default.txt.tpl b/templates/default.txt.tpl index bfef63c..eac9fb2 100644 --- a/templates/default.txt.tpl +++ b/templates/default.txt.tpl @@ -1,4 +1,4 @@ -title : title()."\n"; ?> +title : , author : gabriel dunne email : gdunne at quilime dot com copyright : 1997 - diff --git a/templates/page.html.tpl b/templates/page.html.tpl index 159c659..295ad02 100644 --- a/templates/page.html.tpl +++ b/templates/page.html.tpl @@ -3,7 +3,7 @@ include_template('head-inc.html.tpl') ?> - <?=SITE_TITLE?><?=$this->title();?> + <?=SITE_TITLE?>, <?=$data['title']?> @@ -12,6 +12,8 @@
+

+
diff --git a/templates/single.html.tpl b/templates/single.html.tpl index ccb8623..e169285 100644 --- a/templates/single.html.tpl +++ b/templates/single.html.tpl @@ -3,7 +3,7 @@ include_template('head-inc.html.tpl') ?> - <?=SITE_TITLE?><?=$this->title(); ?> + <?=SITE_TITLE?>, <?=$data['title'];?> -- 2.34.1