From 272cf5abc985ebcd79090c202cfadddb759f0d9d Mon Sep 17 00:00:00 2001 From: Gabriel Dunne Date: Mon, 3 Sep 2012 16:01:11 -0700 Subject: [PATCH] Getting up to speed with new changes. --- content/projects/config | 3 + css/style.css | 3 - lib/config.ini | 1 + lib/data.php | 130 +++++++++++--------- lib/init.php | 1 + lib/model.php | 8 +- pages/agg | 3 - templates/agg.html.tpl | 228 ------------------------------------ templates/entry.html.tpl | 2 +- templates/projects.html.tpl | 3 +- templates/single.html.tpl | 17 +-- test.php | 1 - 12 files changed, 93 insertions(+), 307 deletions(-) delete mode 100644 pages/agg delete mode 100644 templates/agg.html.tpl diff --git a/content/projects/config b/content/projects/config index 0ceefdf..b7c6b35 100644 --- a/content/projects/config +++ b/content/projects/config @@ -1 +1,4 @@ template = projects +title = projects +-- + diff --git a/css/style.css b/css/style.css index 39be341..3aae4aa 100644 --- a/css/style.css +++ b/css/style.css @@ -17,7 +17,6 @@ a { a.mute { text-decoration: none ! important; } a:hover, a.mute:hover { - border: medium none; color: #0000FF; text-decoration: underline; } @@ -170,9 +169,7 @@ table, td, tr { .thumb { width:100px; height:100px; - border:1px dotted #000; overflow:hidden; - } diff --git a/lib/config.ini b/lib/config.ini index a93354d..0e5b84a 100644 --- a/lib/config.ini +++ b/lib/config.ini @@ -15,6 +15,7 @@ content = content/ comments = comments/ templates = templates/ pages = pages/ +media = media/ config_file = config data_file = data.json diff --git a/lib/data.php b/lib/data.php index ad26ae5..87fb90a 100644 --- a/lib/data.php +++ b/lib/data.php @@ -41,6 +41,9 @@ function get_entries( $path = "", $args = array() ) 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; @@ -62,20 +65,16 @@ function get_entries( $path = "", $args = array() ) } 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?'); } } } @@ -103,26 +102,22 @@ function get_dirs( $path = "", $args = array()) $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()); @@ -180,47 +175,72 @@ function parse_entry($fileInfo, $page = false) $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 '
'; 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 ) { diff --git a/lib/init.php b/lib/init.php index 2d3bcd2..7533d56 100644 --- a/lib/init.php +++ b/lib/init.php @@ -34,6 +34,7 @@ define ('SITE_TITLE', $_cfg['site_title']); 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']); diff --git a/lib/model.php b/lib/model.php index abf9f62..44cf54b 100644 --- a/lib/model.php +++ b/lib/model.php @@ -53,14 +53,14 @@ class Model // 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'; } diff --git a/pages/agg b/pages/agg deleted file mode 100644 index c299cf6..0000000 --- a/pages/agg +++ /dev/null @@ -1,3 +0,0 @@ -title = aggregate -template = agg --- diff --git a/templates/agg.html.tpl b/templates/agg.html.tpl deleted file mode 100644 index 4ecf916..0000000 --- a/templates/agg.html.tpl +++ /dev/null @@ -1,228 +0,0 @@ - - - - include_template('head-inc.html.tpl'); ?> - - <?=SITE_TITLE?>: aggregate - - - - - include_template('nav.html.tpl') ?> - -
- - - - - - - - - - - -

video

- -

- more → -

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

image

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

- rss, more → -

- -
- -

video

- - -

- rss, - more → -

-
-

flickr

-
    - - channel->item as $item) : if (!$count--) break; ?> -
  • - description; - $pattern = '/rss, more → -

    -
- -:@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); -?> - -

link

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

- rss, more → -

- -
- -
- - include_template('footer.html.tpl'); ?> - - - \ No newline at end of file diff --git a/templates/entry.html.tpl b/templates/entry.html.tpl index e23d763..93876cd 100644 --- a/templates/entry.html.tpl +++ b/templates/entry.html.tpl @@ -39,7 +39,7 @@ ?> -
+
diff --git a/templates/projects.html.tpl b/templates/projects.html.tpl index 7b8bb4b..ff149e3 100644 --- a/templates/projects.html.tpl +++ b/templates/projects.html.tpl @@ -3,7 +3,7 @@ include_template('head-inc.html.tpl') ?> - <?=SITE_TITLE?>: <?=$page_title?> + <?=SITE_TITLE?>: <?=$entry->title?> @@ -12,6 +12,7 @@
+
  • diff --git a/templates/single.html.tpl b/templates/single.html.tpl index e511b6c..1a175c2 100644 --- a/templates/single.html.tpl +++ b/templates/single.html.tpl @@ -3,24 +3,19 @@ include_template('head-inc.html.tpl') ?> - <?=$entry['title'];?> + <?=$entry->title;?> -
    - include_template($entry['config']['template'] . '.' . $this->response_format . '.tpl'); - } - else { - $this->include_template('entry.' . $this->response_format . '.tpl'); - } - ?> + include_template('nav.html.tpl') ?> +
    +
    + include_template('entry.html.tpl', array('entry' => $entry, 'single' => true)); ?> +
    - include_template('nav.html.tpl') ?> include_template('footer.html.tpl') ?> diff --git a/test.php b/test.php index 5325017..9bab046 100644 --- a/test.php +++ b/test.php @@ -10,7 +10,6 @@ require 'lib/init.php'; class AllTests extends TestSuite { function AllTests() { - $this->TestSuite('All tests'); $this->addFile('lib/test/data_test.php'); } } -- 2.34.1