From 2f7fe970fb8213f51921f294a88701bcd7080ea1 Mon Sep 17 00:00:00 2001 From: Gabriel Dunne Date: Sat, 29 May 2010 18:37:31 -0700 Subject: [PATCH] templates --- lib/init.php | 69 ++++------------ lib/output.php | 15 ++++ lib/template.php | 93 +++++++++++++++++++++ lib/templates/404.html | 27 ------ lib/templates/about.html | 27 ------ lib/templates/agg.html | 145 --------------------------------- lib/templates/code.html | 111 ------------------------- lib/templates/css/style.css | 85 ------------------- lib/templates/default.html.tpl | 22 +++++ lib/templates/gallery.html.tpl | 15 ++++ lib/templates/header-src.html | 18 ---- lib/templates/img.html | 49 ----------- lib/templates/index.html | 20 ----- lib/templates/links.html | 78 ------------------ lib/templates/log.html | 111 ------------------------- lib/templates/nav.html | 25 ------ lib/templates/photo.html | 51 ------------ lib/templates/projects.html | 74 ----------------- lib/view.php | 20 ----- public/.htaccess | 6 +- public/index.php | 3 +- 21 files changed, 169 insertions(+), 895 deletions(-) create mode 100644 lib/template.php delete mode 100644 lib/templates/404.html delete mode 100644 lib/templates/about.html delete mode 100644 lib/templates/agg.html delete mode 100644 lib/templates/code.html delete mode 100644 lib/templates/css/style.css create mode 100644 lib/templates/default.html.tpl create mode 100644 lib/templates/gallery.html.tpl delete mode 100644 lib/templates/header-src.html delete mode 100644 lib/templates/img.html delete mode 100644 lib/templates/index.html delete mode 100644 lib/templates/links.html delete mode 100644 lib/templates/log.html delete mode 100644 lib/templates/nav.html delete mode 100644 lib/templates/photo.html delete mode 100644 lib/templates/projects.html delete mode 100644 lib/view.php diff --git a/lib/init.php b/lib/init.php index 3dfaa68..9ec0167 100644 --- a/lib/init.php +++ b/lib/init.php @@ -1,68 +1,33 @@ set_src(TEMPLATE_DIR . '/' . $config['template'] . '.' . $response_format . '.tpl'); - else if (file_exists(CONTENT_SRC)) - $template->set_src(CONTENT_SRC); - -// echo $template->src; - - # content - # images - $images = array(); - foreach(glob(CONTENT_BASEDIR . "{*.jpg,*.gif,*.png}", GLOB_BRACE) as $img) { - $i = array(); - $i['name'] = basename($img); - $i['url'] = str_replace(CONTENT_BASEDIR, CONTENT_WEBROOT, $img); - $images[] = $i; - } - } + $t = get_template_instance(); + + # parse if content dir exists + if (is_dir($t->basedir)) { + $t->parse_assets(); + } # header -// header("Content-Type: {$response_mime_type}; charset=UTF-8"); -// $template->render(); + header("Content-Type: {$response_mime_type}; charset=UTF-8"); + $t->render(join(".", array($t->template, $response_format, "tpl"))); // print_r($_SERVER); - // $images = glob("images/{*.jpg,*.gif,*.png}", GLOB_BRACE); // print_r($images); - - - - -// require_once 'data.php'; -// require_once 'output.php'; - -// define_constants(); +// require_once 'data.php'; +// require_once 'output.php'; +// define_constants(); ?> \ No newline at end of file diff --git a/lib/output.php b/lib/output.php index 7f1c2fe..966575e 100644 --- a/lib/output.php +++ b/lib/output.php @@ -1,5 +1,20 @@ basedir = join(DIRECTORY_SEPARATOR, array($_SERVER['DOCUMENT_ROOT'], 'content', $_SERVER['SCRIPT_URL'] . "/")); + $t->webroot = join("/", array('http://' . $_SERVER['SERVER_NAME'] . "/" , 'content' , $_SERVER['SCRIPT_URL'] . "/")); + $t->url = join("/", array('http://' . $_SERVER['SERVER_NAME'] . "/" , $_SERVER['SCRIPT_URL'] . "/")); + $t->template_dir = join(DIRECTORY_SEPARATOR, array(dirname(__FILE__), 'templates')); + $t->content_file = join(DIRECTORY_SEPARATOR, array( $_SERVER['DOCUMENT_ROOT'], 'content', $_SERVER['SCRIPT_URL'], 'content.php')); + $t->config_file = join(DIRECTORY_SEPARATOR, array( $_SERVER['DOCUMENT_ROOT'], 'content', $_SERVER['SCRIPT_URL'], 'config')); + return $t; + } + + /** * @param string $format "text", "xml", etc. * @param string $default Default format diff --git a/lib/template.php b/lib/template.php new file mode 100644 index 0000000..43e7c34 --- /dev/null +++ b/lib/template.php @@ -0,0 +1,93 @@ +config_file)) + $this->_config_vars = parse_ini_file($this->config_file); + if (!$this->_config_vars['title']) + $this->_config_vars['title'] = $_SERVER['SCRIPT_URL']; + $this->assign('config', $this->_config_vars); + + // template file + if ($this->_config_vars['template']) + $this->template = $this->_config_vars['template']; + + // content file + if (file_exists( $this->content_file )) + $this->assign('content_file', $this->content_file); + + // all files + $files = array(); + foreach(glob($this->basedir . "{*}", GLOB_BRACE|GLOB_MARK) as $file) { + $f = array(); + $f['name'] = basename($file); + $f['url'] = str_replace($this->basedir, $this->webroot, $file); + $files[] = $f; + } + $this->assign('files', $files); + + // images + $images = array(); + foreach(glob($this->basedir . "{*.jpg,*.gif,*.png}", GLOB_BRACE) as $img) { + $i = array(); + $i['name'] = basename($img); + $i['url'] = str_replace($this->basedir, $this->webroot, $img); + $images[] = $i; + } + $this->assign('images', $images); + + // generate thumbs for all images + // print_r($this->_config_vars); + } + + + function render($_template = 'default.html.tpl') + { + // assign locally accessable template var + $t = $this->_tpl_vars; + + // include template file + $template_file = join(DIRECTORY_SEPARATOR, array($this->template_dir, $_template)); + if (is_file($template_file)) + include_once $template_file; + else + include_once join(DIRECTORY_SEPARATOR, array($this->template_dir, "default.html.tpl")); + } + + + function assign($tpl_var, $value = null) + { + if (is_array($tpl_var)) { + foreach ($tpl_var as $key => $val) { + if ($key != '') { + $this->_tpl_vars[$key] = $val; + } + } + } else { + if ($tpl_var != '') + $this->_tpl_vars[$tpl_var] = $value; + } + } +} + +?> \ No newline at end of file diff --git a/lib/templates/404.html b/lib/templates/404.html deleted file mode 100644 index 6cf670a..0000000 --- a/lib/templates/404.html +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - <?php echo SITE_TITLE; ?> :404 - - - - - - - -
- -

oops

- -

- 404 -

- -
- - - - \ No newline at end of file diff --git a/lib/templates/about.html b/lib/templates/about.html deleted file mode 100644 index 81ba936..0000000 --- a/lib/templates/about.html +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - <?php echo SITE_TITLE ?> - about - - - - - - - -
- - © 1997— gabriel dunne. All rights reserved. -
-
- email: gdunne@quilime.com - - -
- - - - \ No newline at end of file diff --git a/lib/templates/agg.html b/lib/templates/agg.html deleted file mode 100644 index 2dea6e8..0000000 --- a/lib/templates/agg.html +++ /dev/null @@ -1,145 +0,0 @@ - - - - - - - <?php echo SITE_TITLE; ?> - aggregate - - - - - - - - - -
- - - - - - - - -

video

- -

- more → -

- -*/ ?> - - - - - - - - - -

reader

- -

- more → -

- - - */ - ?> - - - - -
- -

image aggregate

-
    - - channel->item as $item) : - if ($count-- == 0) break; - ?> -
  • - - - -
  • - -
-

- more → -

- -
- -

bookmarks

-
    - post as $d) : ?> -
  • - -
    - - -
  • - -
-

- more → -

-
- -
- - - - - \ No newline at end of file diff --git a/lib/templates/code.html b/lib/templates/code.html deleted file mode 100644 index 9a16cbb..0000000 --- a/lib/templates/code.html +++ /dev/null @@ -1,111 +0,0 @@ - - - - - - - - <?php echo SITE_TITLE; ?> - code<?php if (sizeof($items) > 0 ) : ?>: <?echo strtolower($items['title']); ?> [<?php echo $items['medium']; ?>]<?php endif; ?> - - - - - - - -
- - - -

code / []

- - -
- -
- - - - -

code (view list)

- - - - - - - - - - - -

code (view inline)

- - - - - - - - - -
- - - - - -
- -
-
- - - -
- - - - \ No newline at end of file diff --git a/lib/templates/css/style.css b/lib/templates/css/style.css deleted file mode 100644 index 2e11517..0000000 --- a/lib/templates/css/style.css +++ /dev/null @@ -1,85 +0,0 @@ - -body { margin:10px 100px 50px 40px; } -html, body, table { font-family: helvetica; font-size:11px; line-height:1.5em; color:#222; } - -/*selection*/ -::-moz-selection {background: #08f !important; color:#fff;} -::selection {background: #08f !important; color:#fff;} - -/*links*/ -a { color:#07e; border:0; text-decoration:none; } -a img { border:0; } -a.mute { color:#555; } -a:hover, a.mute:hover { color:#fa4; background:#ffa; text-decoration:none; } -.caption a { color:#888;} -.caption a:hover { color:#905;} - -/*headings*/ -h1, h2, h3, h4, h5, h6 { color:#444; font-size:1em; } -h1 a, h2 a, h3 a, h4 a, h5 a, h6 a { background:#ffe; } -h1 { margin:0 0 3em 0; } -h2 { margin:4em 0 0.5em 0; } -h3 { font-size:1em; margin:0; margin-bottom:0.5em; } - -/*code -pre, .code { font-family: Monaco, monospace; font-size:11px; line-height:1.4em; background:#212121; color:#0f4; padding:1em 2em; } -span.code { padding:0.5em 1em; } -*/ - -blockquote { font-family:times; background:#000; color:#aaa; -margin:0; font-size:15px; line-height:1.4em; padding:2em 4em; font-style:italic; line-height:1.45em; max-width:600px;} - -p { max-width:720px; } - -ul { margin:0; padding:0; list-style-type:none; } -li { margin-bottom:1px; padding:1px; } -table { margin:0; padding:0; border:0; } -table .column { padding-right:100px; min-width:120px; max-width:275px; } -table .column h2 a { text-decoration:none; } -table h2, table h3 { margin-bottom:2em;} -table .video li, table .image li { margin-bottom:2em; } -table .reader li, table .bookmarks li { margin-bottom:1em; padding-bottom:1em; border-bottom:1px dotted #ddd; } -.reader_links li, .bookmark_links li { padding-top:.75em; margin-bottom:.75em; } -.bookmark_links li a { display:block; } -.bookmark_links li span { font-style: italic; color:#444; } -.image li a { background:none;} - -.c_pop { position:absolute; background:#fff; display:none; border:5px outset #000; padding:1em 2em; left:260px; z-index:5; } - -.func { font-weight:bold; color:#444; } - -#home_arrow { position: absolute; top:11px; left:23px; margin-left:250px; text-decoration:none; } - -#content { margin-left:120px; min-width:500px; } - #content p { } - ul.inline_content { } - ul.inline_content li { margin:0 0 50px 0; padding-bottom:75px; } - ul.thumbnails { } - ul.thumbnails li { display:inline-block; margin: 0px 60px 60px 0px; } - ul.thumbnails .thumbnail { width:160px; height:120px; text-align:center; background:#888; } - ul.thumbnails a:hover img { - filter:alpha(opacity=75); - -moz-opacity:0.75; - -khtml-opacity: 0.75; - opacity: 0.75; - } - ul.thumbnails a { text-decoration:none; } - ul.thumbnails .title { } - - .date { font-weight:bold; } - - .text { font-family:serif; font-size:15px; line-height:2.2em; margin-top:80px;} - .indent { text-indent:3em; } - -.nav { position:fixed; top:1em; left:1em; line-height:1.1em;} -.nav ul { margin-left:1em; } -.nav li a { background:#ffe; font-weight:bold; } -.nav h3 { margin-bottom:0.4em; } - - -.caption { font-style:italic; margin-top:5px; color:#444; } -.more, .home { text-decoration:none; color:#000; font-weight:bold; } - -#footer { margin-top:120px; } -#footer .copy a { text-decoration:none; } - diff --git a/lib/templates/default.html.tpl b/lib/templates/default.html.tpl new file mode 100644 index 0000000..0c07c15 --- /dev/null +++ b/lib/templates/default.html.tpl @@ -0,0 +1,22 @@ +

+

+

+		
+		
+		
+	
+

+ +

all files

+ + +

images

+ \ No newline at end of file diff --git a/lib/templates/gallery.html.tpl b/lib/templates/gallery.html.tpl new file mode 100644 index 0000000..eebbdaf --- /dev/null +++ b/lib/templates/gallery.html.tpl @@ -0,0 +1,15 @@ +

+ +

all files

+ + +

images

+ \ No newline at end of file diff --git a/lib/templates/header-src.html b/lib/templates/header-src.html deleted file mode 100644 index 05d8973..0000000 --- a/lib/templates/header-src.html +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/lib/templates/img.html b/lib/templates/img.html deleted file mode 100644 index b467cfa..0000000 --- a/lib/templates/img.html +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - <?php echo SITE_TITLE; ?> - img - - - - - - - - - -
- -
- - more → - - - - - - \ No newline at end of file diff --git a/lib/templates/index.html b/lib/templates/index.html deleted file mode 100644 index eea502f..0000000 --- a/lib/templates/index.html +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - <?php echo SITE_TITLE; ?> - - - - - - - -
- projects, process log, experiments, code, reference, inspiration, aggregate -
- - - diff --git a/lib/templates/links.html b/lib/templates/links.html deleted file mode 100644 index 94bfa6c..0000000 --- a/lib/templates/links.html +++ /dev/null @@ -1,78 +0,0 @@ - - - - - - - <?php echo SITE_TITLE ?> - links - - - - - - - -
- - - -
  • - - - - - - - - -

    links

    - - -
    - - - - \ No newline at end of file diff --git a/lib/templates/log.html b/lib/templates/log.html deleted file mode 100644 index 6a61f25..0000000 --- a/lib/templates/log.html +++ /dev/null @@ -1,111 +0,0 @@ - - - - - - - - - <?php echo SITE_TITLE; ?><?php if ($single) : ?> - log: <?echo strtolower($log['title']); ?> [<?php echo date("Y M d", strtotime($log['date']));?>]<? else: ?> - log<? endif; ?> - - - - - - - - - -
    - - - -

    log /

    - -
    - -
    - - - - - - - - - - - - - - -
    - - -
    - - - - - -
    - -
    -
    - -
    - - view inline - - - - - - - - - -
    - vew archive - - - - -
    - - - - \ No newline at end of file diff --git a/lib/templates/nav.html b/lib/templates/nav.html deleted file mode 100644 index 8c91bdb..0000000 --- a/lib/templates/nav.html +++ /dev/null @@ -1,25 +0,0 @@ - diff --git a/lib/templates/photo.html b/lib/templates/photo.html deleted file mode 100644 index e74efc5..0000000 --- a/lib/templates/photo.html +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - - - <?php echo SITE_TITLE; ?> :photo - - - - - - - - - -
    - -

    images

    - -
    - - more via flickr → - - - - - - \ No newline at end of file diff --git a/lib/templates/projects.html b/lib/templates/projects.html deleted file mode 100644 index 6e80fd0..0000000 --- a/lib/templates/projects.html +++ /dev/null @@ -1,74 +0,0 @@ - - - - - - - - <?php echo SITE_TITLE; ?> - projects<?php if (sizeof($projects) > 0 ) : ?>: <?echo strtolower($project['title']); ?> [<?php echo $project['medium']; ?>]<?php endif; ?> - - - - - - - -
    - - - - -

    projects /

    - - - - - -

    - current
    - 2008
    - 2007
    - 2004 - 2006 -

    - - - - - -
    - - - - \ No newline at end of file diff --git a/lib/view.php b/lib/view.php deleted file mode 100644 index e709477..0000000 --- a/lib/view.php +++ /dev/null @@ -1,20 +0,0 @@ -src = $template_src; - } - - function render() - { - echo "test"; - echo $this->src; - } - } - -?> \ No newline at end of file diff --git a/public/.htaccess b/public/.htaccess index 7ca81dd..7c2959e 100644 --- a/public/.htaccess +++ b/public/.htaccess @@ -1,8 +1,12 @@ - + RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f #RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . index.php [L] + + RewriteCond %{REQUEST_URI} ^(.*)//(.*)$ + RewriteRule . %1/%2 [R=301,L] + diff --git a/public/index.php b/public/index.php index a9be48a..e5dc778 100644 --- a/public/index.php +++ b/public/index.php @@ -1,5 +1,6 @@ -- 2.34.1