From 5be916987977ec92e18068d256a2807c9b4f7409 Mon Sep 17 00:00:00 2001 From: Gabriel Dunne Date: Sat, 8 Sep 2012 13:29:27 -0700 Subject: [PATCH] Considering moving static pages to content so they're cached. --- content/studio/config | 1 + content/tag | 4 +++ css/style.css | 9 ++++-- data/content/data.json | 2 +- index.php | 1 - lib/data.php | 7 ++-- lib/init.php | 30 +++++++++++------- lib/model.php | 10 +----- pages/contact | 65 ++++++++++++++++++-------------------- templates/default.html.tpl | 5 --- templates/edit.html.tpl | 5 ++- templates/entry.html.tpl | 22 ++----------- templates/nav.html.tpl | 11 +++++++ 13 files changed, 83 insertions(+), 89 deletions(-) create mode 100644 content/tag diff --git a/content/studio/config b/content/studio/config index 6961c44..8401ad6 100755 --- a/content/studio/config +++ b/content/studio/config @@ -2,3 +2,4 @@ title = studio -- Studio +lots to go here. \ No newline at end of file diff --git a/content/tag b/content/tag new file mode 100644 index 0000000..11a8106 --- /dev/null +++ b/content/tag @@ -0,0 +1,4 @@ +title = tag +-- + +yep. diff --git a/css/style.css b/css/style.css index 603543b..b3b8c55 100644 --- a/css/style.css +++ b/css/style.css @@ -88,9 +88,12 @@ table, td, tr { } +.edit, +.edit textarea { + background:#111; +} .edit { box-sizing: border-box; - background:#005; position:fixed; width:100%; bottom:0; @@ -102,7 +105,6 @@ table, td, tr { } .edit textarea { font-family: monaco, monospace; - background:#005; padding:5px; border:0; width:100%; @@ -110,6 +112,9 @@ table, td, tr { color:#eee; height:200px; } + textarea:focus { + outline: none; + } .edit_button { /* position:fixed; diff --git a/data/content/data.json b/data/content/data.json index 6f073b5..c4b484d 100644 --- a/data/content/data.json +++ b/data/content/data.json @@ -1 +1 @@ -{"entries":[{"config":{"date":"feb 20 2012","title":"temple","tags":"photo"},"title":"temple","filename":"temple","path":"\/Users\/gdunne\/_code\/plog\/content\/log\/temple","fileInfo":{},"timestamp":"1329724800","tags":["photo"],"content":"

\n \n<\/a><\/p>\n","comments_enabled":false,"comments":{"comments":[],"comments_loc":"\/Users\/gdunne\/_code\/plogcomments\/\/Users\/gdunne\/_code\/plog\/content\/log\/temple\/","fileInfo":{},"_recaptcha_resp":null,"_recaptcha_error":null,"_comment_error":null},"cat":{"name":"og","url":"log\/"},"media":"media\/\/og\/temple\/","thumb":"media\/\/og\/temple\/thumb.png","url":"\/og\/temple","edit_url":"\/edit\/\/og\/temple"},{"config":{"title":"Water Is Life","date":"Oct 23 2011 06:04:38 PM","tags":"water photo"},"title":"Water Is Life","filename":"water_is_life","path":"\/Users\/gdunne\/_code\/plog\/content\/log\/water_is_life","fileInfo":{},"timestamp":"1319418278","tags":["water","photo"],"content":"

<\/a><\/p>\n\n

near Quotar Minar in Dadabari.<\/p>\n","comments_enabled":false,"comments":{"comments":[],"comments_loc":"\/Users\/gdunne\/_code\/plogcomments\/\/Users\/gdunne\/_code\/plog\/content\/log\/water_is_life\/","fileInfo":{},"_recaptcha_resp":null,"_recaptcha_error":null,"_comment_error":null},"cat":{"name":"og","url":"log\/"},"media":"media\/\/og\/water_is_life\/","thumb":"media\/\/og\/water_is_life\/thumb.png","url":"\/og\/water_is_life","edit_url":"\/edit\/\/og\/water_is_life"},{"config":{"title":"islands","date":"Oct 05 2011, 03:53:55 PM","tags":"writing quote"},"title":"islands","filename":"islands","path":"\/Users\/gdunne\/_code\/plog\/content\/log\/islands","fileInfo":{},"timestamp":"1317855235","tags":["writing","quote"],"content":"

\n

Imagine that every man's mind is an island, surrounded by ocean. Each seems isolated, yet in reality all are linked by the bedrock from which they spring. If the ocean were to vanish, that would be the end of the islands. They would all be part of one continent, but their individuality would be gone.<\/p>\n \n

—\"The Inspector\" Overlord. Childhoods End<\/u>, Arthur C. Clark. p.176<\/p>\n<\/blockquote>\n","comments_enabled":false,"comments":{"comments":[],"comments_loc":"\/Users\/gdunne\/_code\/plogcomments\/\/Users\/gdunne\/_code\/plog\/content\/log\/islands\/","fileInfo":{},"_recaptcha_resp":null,"_recaptcha_error":null,"_comment_error":null},"cat":{"name":"og","url":"log\/"},"media":"media\/\/og\/islands\/","thumb":"media\/\/og\/islands\/thumb.png","url":"\/og\/islands","edit_url":"\/edit\/\/og\/islands"},{"config":{"title":"childhoods end","date":"Oct 05 2011, 03:17:57 PM","tags":"india quote"},"title":"childhoods end","filename":"overlords","path":"\/Users\/gdunne\/_code\/plog\/content\/log\/overlords","fileInfo":{},"timestamp":"1317853077","tags":["india","quote"],"content":"

\n

The case of India is particularly instructive. The main difference between us and the British in India was that they had no real motives for going there\u2014no conscious objectives, that is, except such trivial and temporary ones as trade or hostility to other European powers. They found themselves possessors of an empire before they knew what to do with it, and were never really happy until they had got rid of it again.<\/p>\n \n

\u2014\"The Inspector\" Overlord. Childhoods End<\/u>, Arthur C. Clark. p.161<\/p>\n<\/blockquote>\n","comments_enabled":false,"comments":{"comments":[],"comments_loc":"\/Users\/gdunne\/_code\/plogcomments\/\/Users\/gdunne\/_code\/plog\/content\/log\/overlords\/","fileInfo":{},"_recaptcha_resp":null,"_recaptcha_error":null,"_comment_error":null},"cat":{"name":"og","url":"log\/"},"media":"media\/\/og\/overlords\/","thumb":"media\/\/og\/overlords\/thumb.png","url":"\/og\/overlords","edit_url":"\/edit\/\/og\/overlords"},{"config":{"title":"prism","date":"2007-08-23","thumb":"http:\/\/portfolio.quilime.com\/2008\/prism\/thumb.png","tags":"prism painting"},"title":"prism","filename":"prism","path":"\/Users\/gdunne\/_code\/plog\/content\/projects\/prism","fileInfo":{},"timestamp":"1187852400","tags":["prism","painting"],"content":"

<\/p>\n\n

oil on canvas. 4' x 3'<\/p>\n","comments_enabled":false,"comments":{"comments":[],"comments_loc":"\/Users\/gdunne\/_code\/plogcomments\/\/Users\/gdunne\/_code\/plog\/content\/projects\/prism\/","fileInfo":{},"_recaptcha_resp":null,"_recaptcha_error":null,"_comment_error":null},"cat":{"name":"rojects","url":"projects\/"},"media":"media\/\/rojects\/prism\/","thumb":"http:\/\/portfolio.quilime.com\/2008\/prism\/thumb.png","url":"\/rojects\/prism","edit_url":"\/edit\/\/rojects\/prism"},{"config":{"title":"mask","date":"2007-07-02","thumb":"http:\/\/portfolio.quilime.com\/2008\/mask\/thumb.png","tags":"mask painting"},"title":"mask","filename":"mask","path":"\/Users\/gdunne\/_code\/plog\/content\/projects\/mask","fileInfo":{},"timestamp":"1183359600","tags":["mask","painting"],"content":"

<\/p>\n\n

graphite on plywood. 12\" x 12\"<\/p>\n","comments_enabled":false,"comments":{"comments":[],"comments_loc":"\/Users\/gdunne\/_code\/plogcomments\/\/Users\/gdunne\/_code\/plog\/content\/projects\/mask\/","fileInfo":{},"_recaptcha_resp":null,"_recaptcha_error":null,"_comment_error":null},"cat":{"name":"rojects","url":"projects\/"},"media":"media\/\/rojects\/mask\/","thumb":"http:\/\/portfolio.quilime.com\/2008\/mask\/thumb.png","url":"\/rojects\/mask","edit_url":"\/edit\/\/rojects\/mask"}]} \ No newline at end of file +{"entries":[{"config":{"title":"tag","date":null},"title":"tag","filename":"tag","path":"\/Users\/gdunne\/_code\/plog\/content\/tag","fileInfo":{},"timestamp":1347134885,"tags":null,"content":"

yep.<\/p>\n","comments_enabled":false,"comments":{"comments":[],"comments_loc":"\/Users\/gdunne\/_code\/plogcomments\/\/Users\/gdunne\/_code\/plog\/content\/tag\/","fileInfo":{},"_recaptcha_resp":null,"_recaptcha_error":null,"_comment_error":null},"cat":{"name":false,"url":"\/"},"media":"media\/\/tag\/","thumb":"media\/\/tag\/thumb.png","url":"\/tag","edit_url":"\/edit\/\/tag"}]} \ No newline at end of file diff --git a/index.php b/index.php index 4325e40..32f5b87 100644 --- a/index.php +++ b/index.php @@ -14,7 +14,6 @@ if ($m->is_multiple()) if ($m->is_single() || $m->is_page() || $m->is_multiple()) $v->assign('entry', $m->entry); -$v->assign('is_edit', $m->is_edit); header("Content-Type: {$m->response_mime_type}; charset=UTF-8"); $v->render( $m->template, $m->response_format ); diff --git a/lib/data.php b/lib/data.php index 24ec42f..aa53b3a 100644 --- a/lib/data.php +++ b/lib/data.php @@ -120,10 +120,11 @@ function get_dirs( $path = "", $args = array()) if (substr($info->getFilename(), 0, 1) == '.') continue; $d = array(); - $d['url'] = WEB_ROOT . str_replace($path, "", $info->getRealPath()); + $d['url'] = rtrim(WEB_ROOT . str_replace($path, "", $info->getRealPath()), "/") . "/"; if (!CLEAN_URLS) $d['url'] = WEB_ROOT . '?p=' . $d['url']; $d['name'] = str_replace($path, "", $info->getRealPath()); + $d['title'] = $d['name']; $dirs[] = (object) $d; } } @@ -242,14 +243,14 @@ function parse_entry($fileInfo, $page = false) $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())); + $cat = clean_slashes(str_replace(rtrim(LOCAL_ROOT . '/' . CONTENT_DIR, "/"), "", $fileInfo->getPath())); $file['cat'] = $page ? null : array('name' => substr($cat, 1), 'url' => $cat.'/' ); $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['url'] = WEB_ROOT . ($page ? '' : substr($file['cat']['url'], 1)) . $fileInfo->getFilename(); $file['edit_url'] = WEB_ROOT . 'edit/' . $file['url']; $file['cat'] = (object) $file['cat']; $file['config'] = (object) $file['config']; diff --git a/lib/init.php b/lib/init.php index b071f3f..7f6f0ce 100644 --- a/lib/init.php +++ b/lib/init.php @@ -8,9 +8,17 @@ */ -# error reporting (turn this off for production) -error_reporting(E_ALL); -ini_set("display_errors", 1); +$_INI_LOC = 'lib/config.ini'; + + + +# recaptcha for comments +//require_once 'recaptchalib.php'; +// Get a key from https://www.google.com/recaptcha/admin/create +//$captcha_publickey = "6Lek-MkSAAAAAAZknQQGSx9DiCqm_wAiFGytc37d"; +//$captcha_privatekey = "6Lek-MkSAAAAAK4FAaPKO0Cwp-iHa0OcUaqipee4"; + + # timezone putenv("TZ=America/Los_Angeles"); @@ -26,7 +34,7 @@ if (!is_dir(LOCAL_ROOT)) { define ('LOG_FILE', LOCAL_ROOT . '/plog.log'); -$_cfg = parse_ini_file('lib/config.ini'); +$_cfg = parse_ini_file($_INI_LOC); define ('WEB_ROOT', $_cfg['web_root']); define ('CLEAN_URLS', $_cfg['clean_urls']); define ('LIMIT', $_cfg['limit']); @@ -43,19 +51,17 @@ define ('CONFIG_DELIMITER', $_cfg['config_delim']); define ('CONFIG_FILE', $_cfg['config_file']); define ('MORE_DELIM', $_cfg['more_delim']); define ('TITLE_DELIMITER', $_cfg['title_delim']); -define ('ENTRY_DATE_FORMAT', $_cfg['date_format']); +define ('DATE_FORMAT', $_cfg['date_format']); define ('DEV', $_cfg['dev']); define ('EDIT', $_cfg['edit']); $_FILE_IGNORES = $_cfg['file_ignores']; - - -# recaptcha for comments -//require_once 'recaptchalib.php'; -// Get a key from https://www.google.com/recaptcha/admin/create -//$captcha_publickey = "6Lek-MkSAAAAAAZknQQGSx9DiCqm_wAiFGytc37d"; -//$captcha_privatekey = "6Lek-MkSAAAAAK4FAaPKO0Cwp-iHa0OcUaqipee4"; +# error reporting (turn this off for production) +if (DEV) { + error_reporting(E_ALL); + ini_set("display_errors", 1); +} diff --git a/lib/model.php b/lib/model.php index d952441..6baedc2 100644 --- a/lib/model.php +++ b/lib/model.php @@ -20,18 +20,10 @@ class Model function __construct( $req ) { $this->request = $req; - - // TODO: clean request to make sure there's no ../'s - if (EDIT) { - $this->is_edit = strpos($this->request['path'], 'edit/') !== false ? true : false; - $this->request['dirname'] = str_replace('edit/', '', $this->request['dirname']); - $this->request['path'] = str_replace('edit/', '', $this->request['path']); if ($_SERVER['REQUEST_METHOD'] == 'POST') $this->process_edit_post_request(); } - - list($this->response_format, $this->response_mime_type) = parse_format($this->request['extension']); $this->template = 'default.' . $this->response_format . '.tpl'; $this->parse_request( $this->request ); @@ -103,7 +95,7 @@ class Model } function process_edit_post_request() { - if ($this->is_edit && isset($_POST['edited_file_contents'])) { + if (EDIT && isset($_POST['edited_file_contents'])) { try { if (!is_writable( $this->get_filename() )) { throw new Exception('Error editing file. Permissions?'); diff --git a/pages/contact b/pages/contact index 3997433..8ce9bca 100755 --- a/pages/contact +++ b/pages/contact @@ -1,35 +1,30 @@ --- - -Gabriel Dunne -1242 Market St -Floor 2 -San Francisco, CA USA 94102 - -studio at gabrieldunne dot com - -\+ 1 415 493 8496 - -
- -

- -

-name
- -

- -

-email
- -

- -

-message
- -

- -

- -

- - +-- + +Gabriel Dunne +1242 Market St +Floor 2 +San Francisco, CA USA 94102 + +studio at gabrieldunne dot com + +\+ 1 415 493 8496 + +
+ +
+ +

+name
+ +

+ +

+email
+ +

+ +

+message
+ + + diff --git a/templates/default.html.tpl b/templates/default.html.tpl index 7281930..35f9b30 100644 --- a/templates/default.html.tpl +++ b/templates/default.html.tpl @@ -16,11 +16,6 @@ content)): ?> ' . $entry->content); ?> - - - edit_button;?> - - diff --git a/templates/edit.html.tpl b/templates/edit.html.tpl index 751ccde..8649238 100644 --- a/templates/edit.html.tpl +++ b/templates/edit.html.tpl @@ -1,9 +1,12 @@ + +fileInfo) && $f = file_get_contents($entry->fileInfo)) : ?>

- +
+ diff --git a/templates/entry.html.tpl b/templates/entry.html.tpl index d21b210..608692e 100644 --- a/templates/entry.html.tpl +++ b/templates/entry.html.tpl @@ -22,19 +22,7 @@ - -
# -
- in - /' . implode(', ', $entry['tags']); ?> - -*/ -?> - - +
@@ -47,13 +35,7 @@ is_single) && $entry->is_single && $entry->comments_enabled) $this->include_template('comments.html.tpl', array('entry' => $entry)); -?> - - - -edit - - +?> diff --git a/templates/nav.html.tpl b/templates/nav.html.tpl index 95eb2b5..27a45b5 100644 --- a/templates/nav.html.tpl +++ b/templates/nav.html.tpl @@ -4,6 +4,17 @@
  •  
  • + false) ); ?> + '; + // print_r($e); + ?> +
  • title?>
  • + + + + + false) ); ?>
  • name?>
  • -- 2.34.1