From ef330ddf881cea7d925b1b6bb6b9104d0ce2f55d Mon Sep 17 00:00:00 2001 From: Gabriel Dunne Date: Sun, 2 Sep 2012 18:40:37 -0700 Subject: [PATCH] Added editing mode when DEV --- content/config | 0 content/news/bavc_2013 | 0 content/news/config | 0 content/news/icosi_gaffta | 0 content/process/clmpr | 0 content/process/egg | 0 content/process/icosi | 32 +++++++++--------- content/process/icosi2 | 0 content/process/icosi_biennial | 0 content/process/icosi_rider | 0 content/process/permenant | 0 content/process/schedule | 0 content/projects/boat | 0 content/projects/bodyneg | 0 content/projects/cabspotting | 0 content/projects/config | 0 content/projects/obsession | 0 content/projects/rattle | 0 content/projects/seaquence | 17 +++++----- content/projects/stars | 0 content/projects/synonymovement | 0 css/style.css | 13 ++++++-- data/tags.json | 2 +- index.php | 57 ++++++++++++++++++++++++++------- lib/data.php | 1 + templates/edit.html.tpl | 32 ++++++++++++++++++ templates/entry.html.tpl | 6 ++++ templates/projects.html.tpl | 2 +- templates/single.html.tpl | 4 +-- 29 files changed, 123 insertions(+), 43 deletions(-) mode change 100644 => 100755 content/config mode change 100644 => 100755 content/news/bavc_2013 mode change 100644 => 100755 content/news/config mode change 100644 => 100755 content/news/icosi_gaffta mode change 100644 => 100755 content/process/clmpr mode change 100644 => 100755 content/process/egg mode change 100644 => 100755 content/process/icosi mode change 100644 => 100755 content/process/icosi2 mode change 100644 => 100755 content/process/icosi_biennial mode change 100644 => 100755 content/process/icosi_rider mode change 100644 => 100755 content/process/permenant mode change 100644 => 100755 content/process/schedule mode change 100644 => 100755 content/projects/boat mode change 100644 => 100755 content/projects/bodyneg mode change 100644 => 100755 content/projects/cabspotting mode change 100644 => 100755 content/projects/config mode change 100644 => 100755 content/projects/obsession mode change 100644 => 100755 content/projects/rattle mode change 100644 => 100755 content/projects/seaquence mode change 100644 => 100755 content/projects/stars mode change 100644 => 100755 content/projects/synonymovement create mode 100644 templates/edit.html.tpl diff --git a/content/config b/content/config old mode 100644 new mode 100755 diff --git a/content/news/bavc_2013 b/content/news/bavc_2013 old mode 100644 new mode 100755 diff --git a/content/news/config b/content/news/config old mode 100644 new mode 100755 diff --git a/content/news/icosi_gaffta b/content/news/icosi_gaffta old mode 100644 new mode 100755 diff --git a/content/process/clmpr b/content/process/clmpr old mode 100644 new mode 100755 diff --git a/content/process/egg b/content/process/egg old mode 100644 new mode 100755 diff --git a/content/process/icosi b/content/process/icosi old mode 100644 new mode 100755 index 6186855..a22b946 --- a/content/process/icosi +++ b/content/process/icosi @@ -1,16 +1,16 @@ -title = icosi fabrication -date = 2010-07-01 -tags = fabrication icosi design sculpture mapping --- -Fabrication process for ICOSI projection surface. The form is a section of an icosidodecahedron (scaled on the z-axis by 0.5). - - - -
-A laser-cut a small working model. - -
-Custom jig for slicing the angles. - -
-Priming the panels, readying them to be stretched with screen-fabric. +title = icosi fabrication +date = 2010-07-01 +tags = fabrication icosi design sculpture mapping +-- +Fabrication process for ICOSI projection surface. The form is a section of an icosidodecahedron (scaled on the z-axis by 0.5). + + + +
+A laser-cut a small working model. + +
+Custom jig for slicing the angles. + +
+Priming the panels, readying them to be stretched with screen-fabric. diff --git a/content/process/icosi2 b/content/process/icosi2 old mode 100644 new mode 100755 diff --git a/content/process/icosi_biennial b/content/process/icosi_biennial old mode 100644 new mode 100755 diff --git a/content/process/icosi_rider b/content/process/icosi_rider old mode 100644 new mode 100755 diff --git a/content/process/permenant b/content/process/permenant old mode 100644 new mode 100755 diff --git a/content/process/schedule b/content/process/schedule old mode 100644 new mode 100755 diff --git a/content/projects/boat b/content/projects/boat old mode 100644 new mode 100755 diff --git a/content/projects/bodyneg b/content/projects/bodyneg old mode 100644 new mode 100755 diff --git a/content/projects/cabspotting b/content/projects/cabspotting old mode 100644 new mode 100755 diff --git a/content/projects/config b/content/projects/config old mode 100644 new mode 100755 diff --git a/content/projects/obsession b/content/projects/obsession old mode 100644 new mode 100755 diff --git a/content/projects/rattle b/content/projects/rattle old mode 100644 new mode 100755 diff --git a/content/projects/seaquence b/content/projects/seaquence old mode 100644 new mode 100755 index 6293558..796c9c1 --- a/content/projects/seaquence +++ b/content/projects/seaquence @@ -1,9 +1,8 @@ -title = Seaquence -tags = code audio www -notes = this might need to be split up into a few posts -date = 2010-10-04 --- - -Alpha release of [Seaquence: A experimental web-based musical ecosystem](http://seaquence.org). - -[http://seaquence.org](http://seaquence.org) +title = Seaquence +tags = audio www +date = 2010-10-04 +-- + +Alpha release of [Seaquence: A experimental web-based musical ecosystem](http://seaquence.org). + +[http://seaquence.org](http://seaquence.org) diff --git a/content/projects/stars b/content/projects/stars old mode 100644 new mode 100755 diff --git a/content/projects/synonymovement b/content/projects/synonymovement old mode 100644 new mode 100755 diff --git a/css/style.css b/css/style.css index f64757e..55352a7 100644 --- a/css/style.css +++ b/css/style.css @@ -105,8 +105,7 @@ blockquote { -#content { - padding-bottom:50px; } +#content {} #content p:first-child { margin-top: 0pt;} @@ -190,6 +189,16 @@ text-decoration:none; +#content.edit textarea { + font-family: monaco, monospace; + padding:20px; + width:100%; + font-size:12px; + background:#222; + color:#eee; + height:400px; +} + .caption { margin-top: 5px; } diff --git a/data/tags.json b/data/tags.json index 5fd61db..50fb70b 100644 --- a/data/tags.json +++ b/data/tags.json @@ -1 +1 @@ -{"tags":{"datavis":1,"software":1,"stamen":1,"print":1,"installation":2,"code":2,"www":2,"opensource":1,"audio":2,"performance":1,"projection":1,"visual":1,"icosi":2,"fabrication":2,"design":1,"sculpture":1,"mapping":1,"timelapse":1,"photography":1}} \ No newline at end of file +{"tags":{"datavis":1,"software":1,"stamen":1,"print":1,"installation":2,"code":2,"www":2,"opensource":1,"projection-mapping":1,"performance":2,"audiovisual":1,"audio":2,"projection":1,"visual":1,"icosi":2,"fabrication":2,"design":1,"sculpture":1,"mapping":1,"timelapse":1,"photography":1}} \ No newline at end of file diff --git a/index.php b/index.php index 7513a92..9541f09 100644 --- a/index.php +++ b/index.php @@ -9,7 +9,6 @@ $content_req = LOCAL_ROOT . CONTENT_DIR . DIRECTORY_SEPARATOR . $url['url']; $page_req = LOCAL_ROOT . PAGE_DIR . DIRECTORY_SEPARATOR . $url['url']; $total = 0; - # setup template $template = 'default.html.tpl'; $t = get_template_instance(); @@ -18,14 +17,43 @@ $t->assign('url', $url); # special endpoints $dirs = explode('/', $url['url']); -# tag -if ($dirs[0] == 'tag') { - $page_req = LOCAL_ROOT . PAGE_DIR . DIRECTORY_SEPARATOR . $dirs[0]; - if (isset($dirs[1])) { - $t->assign('tag', $dirs[1]); - } -} +switch($dirs[0]) { + case 'tag' : + $page_req = LOCAL_ROOT . PAGE_DIR . DIRECTORY_SEPARATOR . $dirs[0]; + if (isset($dirs[1])) + $t->assign('tag', $dirs[1]); + break; + case 'edit' : + + if (!DEV) + break; + array_shift($dirs); + $newurl = implode($dirs, '/'); + $content_req = LOCAL_ROOT . CONTENT_DIR . DIRECTORY_SEPARATOR . $newurl; + $page_req = LOCAL_ROOT . PAGE_DIR . DIRECTORY_SEPARATOR . $newurl; + + // TODO: Sercurity risk? + if ($_SERVER['REQUEST_METHOD'] == 'POST' && + isset($_POST['edited_file_contents']) && + isset($_POST['edited_file'])) { + try { + $fp = fopen( $_POST['edited_file'], 'w'); + if ($fp) { + fwrite($fp, $_POST['edited_file_contents']); + fclose($fp); + } + if (!file_exists( $_POST['edited_file'] )) { + throw new Exception('Error creating tags.json. Permissions?'); + } + } catch (Exception $e) { + echo 'Caught exception: ', $e->getMessage(), "\n"; + } + $edit = false; + } else { + $edit = true; + } +} # content exists, and is a folder if (is_dir($content_req)) { @@ -42,16 +70,16 @@ if (is_dir($content_req)) { # content exists, and is a single entry else if (is_file($content_req)) { - $t->assign('data', parse_entry(new SplFileInfo($content_req))); + $t->assign('entry', parse_entry(new SplFileInfo($content_req))); $t->assign('single', true); $template = 'single.'.$response_format.'.tpl'; } # content exists, and is a page else if (is_file($page_req)) { - $page = parse_entry(new SplFileInfo($page_req), 1); - $t->assign('data', $page); - $template = isset($page['config']['template']) ? $page['config']['template'] . + $config = parse_entry(new SplFileInfo($page_req), 1); + $t->assign('data', $config); + $template = isset($config['config']['template']) ? $config['config']['template'] . '.' . $response_format . '.tpl' : 'page.' . $response_format . '.tpl'; } @@ -60,6 +88,11 @@ else { $template = '404.html.tpl'; } +# edit +if (DEV && isset($edit) && $edit) { + $template = 'edit.html.tpl'; +} + # render $t->response_format = $response_format; $t->assign('view', isset($_GET['v']) ? $_GET['v'] : null); diff --git a/lib/data.php b/lib/data.php index b266ac3..7f3b5b0 100644 --- a/lib/data.php +++ b/lib/data.php @@ -169,6 +169,7 @@ function parse_entry($fileInfo, $page = 0) $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; diff --git a/templates/edit.html.tpl b/templates/edit.html.tpl new file mode 100644 index 0000000..386b087 --- /dev/null +++ b/templates/edit.html.tpl @@ -0,0 +1,32 @@ + + + + include_template('head-inc.html.tpl') ?> + + <?=SITE_TITLE?><?=TITLE_DELIMITER?><?=$entry['title']?> + + + + + include_template('nav.html.tpl') ?> + +
+ + + + +
+ + + + +
+ + + +
+ + include_template('footer.html.tpl') ?> + + + diff --git a/templates/entry.html.tpl b/templates/entry.html.tpl index 8454017..a359636 100644 --- a/templates/entry.html.tpl +++ b/templates/entry.html.tpl @@ -35,3 +35,9 @@ + + + +edit + + diff --git a/templates/projects.html.tpl b/templates/projects.html.tpl index 52cf96c..a3b3186 100644 --- a/templates/projects.html.tpl +++ b/templates/projects.html.tpl @@ -13,7 +13,7 @@