From: Gabriel Dunne Date: Mon, 20 May 2013 01:15:03 +0000 (-0700) Subject: Combined Media and Content X-Git-Url: https://git.quilime.com/?a=commitdiff_plain;h=6febd63bf12171388e57242933db05b0e280be4e;p=plog.git Combined Media and Content --- diff --git a/content/tester/_config b/content/tester/_config new file mode 100644 index 0000000..b66dfb6 --- /dev/null +++ b/content/tester/_config @@ -0,0 +1,8 @@ +title = Tester +date = 2012-05-19 +tags = test project plog +featured = true +-- +A test entrie that uses a self-container folder for its media. + +Some more of this post. \ No newline at end of file diff --git a/data/content/data.json b/data/content/data.json index 1281bf9..07ef1af 100644 --- a/data/content/data.json +++ b/data/content/data.json @@ -1 +1 @@ -{"entries":[{"config":{"date":"sep 25 2012","tags":"structure process"},"title":"platform","filename":"platform","path":"\/Users\/gdunne\/_portfolio\/www\/content\/platform","fileInfo":{},"timestamp":"1348556400","tags":["structure","process"],"featured":null,"related":null,"content":"\n","comments_enabled":false,"comments":{"comments":[],"comments_loc":"\/Users\/gdunne\/_portfolio\/wwwcomments\/\/Users\/gdunne\/_portfolio\/www\/content\/platform\/","fileInfo":{},"_recaptcha_resp":null,"_recaptcha_error":null,"_comment_error":null},"cat":{"name":"","url":"\/\/"},"thumb":"\/media\/\/\/platform\/thumb.png","url":"\/platform","edit_url":"\/edit\/\/platform","media_dir":"media\/\/\/platform\/","media":[{"filename":"8025655087_27febc8f3c_z.jpg","local":"\/Users\/gdunne\/_portfolio\/www\/media\/\/\/platform\/8025655087_27febc8f3c_z.jpg","url":"\/media\/\/\/platform\/8025655087_27febc8f3c_z.jpg","extension":"jpg"},{"filename":"8025655295_cc1d0e9c0a_z.jpg","local":"\/Users\/gdunne\/_portfolio\/www\/media\/\/\/platform\/8025655295_cc1d0e9c0a_z.jpg","url":"\/media\/\/\/platform\/8025655295_cc1d0e9c0a_z.jpg","extension":"jpg"},{"filename":"thumb.png","local":"\/Users\/gdunne\/_portfolio\/www\/media\/\/\/platform\/thumb.png","url":"\/media\/\/\/platform\/thumb.png","extension":"png"}]},{"config":{"date":"july 05 2010","tags":"process","related":"icosi"},"title":"icosi_process","filename":"icosi_process","path":"\/Users\/gdunne\/_portfolio\/www\/content\/icosi_process","fileInfo":{},"timestamp":"1278313200","tags":["process"],"featured":null,"related":["icosi"],"content":"

Process blog about ICOSI Process\n\nAudio created with Ableton Live\/Max\/MSP, custom software (Processing \/ Java, OpenGL). Wood and fabric projection surface.<\/p>\n\n

The software and audio toolset was developed from scratch for this performance. The performance dramatically split my focus into two places (music and visuals), which was a juggle that I didn't fully anticipate as I was developing the visual software on one split-screen before the performance. Inspired to continue pursuing interfaces and controllers to overcome the separation of creating audio and visuals simultaneously.<\/p>\n\n

The multiple mediums (sculpture, sound, visual media) of this particular project was fascinating. Each iteration represents a process of my own curiosities in technology, consciousness, spirituality, design, and fabrication.<\/p>\n\n

The piece represents my practice and experiences in regards to my own spiritual growth and experience. Geometrically, the form is inspired by sacred polyhedra that represent forms of transition. The choice of an icosidodecahedron<\/a> represents transition of two frequencies, represented by an icosahedron<\/a> and its dual polyhedron, a dodecahedron<\/a>.<\/p>\n\n

The form is composed of 7 panels trimmed and scaled from a full icosidodecahedron. The visuals follow the structure of the form nearly explicitly, with the exception of textural elements.<\/p>\n\n

Debut at Biennial of the Americas, Denver CO, Jul 29 2010.<\/p>\n\n

technical rider<\/a><\/p>\n","content_short":"

Process blog about ICOSI Process<\/p>\n","comments_enabled":false,"comments":{"comments":[],"comments_loc":"\/Users\/gdunne\/_portfolio\/wwwcomments\/\/Users\/gdunne\/_portfolio\/www\/content\/icosi_process\/","fileInfo":{},"_recaptcha_resp":null,"_recaptcha_error":null,"_comment_error":null},"cat":{"name":"","url":"\/\/"},"thumb":"\/media\/\/\/icosi_process\/thumb.png","url":"\/icosi_process","edit_url":"\/edit\/\/icosi_process","media_dir":"media\/\/\/icosi_process\/","media":[{"filename":"5165246192_dfa231d7ef_z.jpg","local":"\/Users\/gdunne\/_portfolio\/www\/media\/\/\/icosi_process\/5165246192_dfa231d7ef_z.jpg","url":"\/media\/\/\/icosi_process\/5165246192_dfa231d7ef_z.jpg","extension":"jpg"},{"filename":"plane_layout.png","local":"\/Users\/gdunne\/_portfolio\/www\/media\/\/\/icosi_process\/plane_layout.png","url":"\/media\/\/\/icosi_process\/plane_layout.png","extension":"png"},{"filename":"thumb.png","local":"\/Users\/gdunne\/_portfolio\/www\/media\/\/\/icosi_process\/thumb.png","url":"\/media\/\/\/icosi_process\/thumb.png","extension":"png"}]},{"config":{"title":"ICOSI Fabrication","date":"2010-07-01","tags":"process","related":"icosi"},"title":"ICOSI Fabrication","filename":"icosi_fab","path":"\/Users\/gdunne\/_portfolio\/www\/content\/icosi_fab","fileInfo":{},"timestamp":"1277967600","tags":["process"],"featured":null,"related":["icosi"],"content":"

Projection surface fabrication<\/p>\n","comments_enabled":false,"comments":{"comments":[],"comments_loc":"\/Users\/gdunne\/_portfolio\/wwwcomments\/\/Users\/gdunne\/_portfolio\/www\/content\/icosi_fab\/","fileInfo":{},"_recaptcha_resp":null,"_recaptcha_error":null,"_comment_error":null},"cat":{"name":"","url":"\/\/"},"thumb":"\/media\/\/\/icosi_fab\/thumb.png","url":"\/icosi_fab","edit_url":"\/edit\/\/icosi_fab","media_dir":"media\/\/\/icosi_fab\/","media":[{"filename":"14-4769443639_728b077b3a.jpg","local":"\/Users\/gdunne\/_portfolio\/www\/media\/\/\/icosi_fab\/14-4769443639_728b077b3a.jpg","url":"\/media\/\/\/icosi_fab\/14-4769443639_728b077b3a.jpg","extension":"jpg"},{"filename":"3-4744981890_2a41c9f374.jpg","local":"\/Users\/gdunne\/_portfolio\/www\/media\/\/\/icosi_fab\/3-4744981890_2a41c9f374.jpg","url":"\/media\/\/\/icosi_fab\/3-4744981890_2a41c9f374.jpg","extension":"jpg"},{"filename":"thumb.png","local":"\/Users\/gdunne\/_portfolio\/www\/media\/\/\/icosi_fab\/thumb.png","url":"\/media\/\/\/icosi_fab\/thumb.png","extension":"png"},{"filename":"z01-4743498955_d8d524bd27.jpg","local":"\/Users\/gdunne\/_portfolio\/www\/media\/\/\/icosi_fab\/z01-4743498955_d8d524bd27.jpg","url":"\/media\/\/\/icosi_fab\/z01-4743498955_d8d524bd27.jpg","extension":"jpg"}]},{"config":{"date":"2010-01-28","tags":"process","related":"monad","gallery":"stacked"},"title":"monad_install","filename":"monad_install","path":"\/Users\/gdunne\/_portfolio\/www\/content\/monad_install","fileInfo":{},"timestamp":"1264665600","tags":["process"],"featured":null,"related":["monad"],"content":"\n","comments_enabled":false,"comments":{"comments":[],"comments_loc":"\/Users\/gdunne\/_portfolio\/wwwcomments\/\/Users\/gdunne\/_portfolio\/www\/content\/monad_install\/","fileInfo":{},"_recaptcha_resp":null,"_recaptcha_error":null,"_comment_error":null},"cat":{"name":"","url":"\/\/"},"thumb":"\/media\/\/\/monad_install\/thumb.png","url":"\/monad_install","edit_url":"\/edit\/\/monad_install","media_dir":"media\/\/\/monad_install\/","media":[{"filename":"monad_install_02.png","local":"\/Users\/gdunne\/_portfolio\/www\/media\/\/\/monad_install\/monad_install_02.png","url":"\/media\/\/\/monad_install\/monad_install_02.png","extension":"png"},{"filename":"monad_install_03.png","local":"\/Users\/gdunne\/_portfolio\/www\/media\/\/\/monad_install\/monad_install_03.png","url":"\/media\/\/\/monad_install\/monad_install_03.png","extension":"png"},{"filename":"thumb.png","local":"\/Users\/gdunne\/_portfolio\/www\/media\/\/\/monad_install\/thumb.png","url":"\/media\/\/\/monad_install\/thumb.png","extension":"png"},{"filename":"x4264434313_9c1abc891b_o.png","local":"\/Users\/gdunne\/_portfolio\/www\/media\/\/\/monad_install\/x4264434313_9c1abc891b_o.png","url":"\/media\/\/\/monad_install\/x4264434313_9c1abc891b_o.png","extension":"png"},{"filename":"z4254727883_5f7090db0f_o.png","local":"\/Users\/gdunne\/_portfolio\/www\/media\/\/\/monad_install\/z4254727883_5f7090db0f_o.png","url":"\/media\/\/\/monad_install\/z4254727883_5f7090db0f_o.png","extension":"png"}]},{"config":{"date":"2010-01-06","tags":"process","related":"monad"},"title":"monad_move","filename":"monad_move","path":"\/Users\/gdunne\/_portfolio\/www\/content\/monad_move","fileInfo":{},"timestamp":"1262764800","tags":["process"],"featured":null,"related":["monad"],"content":"\n","comments_enabled":false,"comments":{"comments":[],"comments_loc":"\/Users\/gdunne\/_portfolio\/wwwcomments\/\/Users\/gdunne\/_portfolio\/www\/content\/monad_move\/","fileInfo":{},"_recaptcha_resp":null,"_recaptcha_error":null,"_comment_error":null},"cat":{"name":"","url":"\/\/"},"thumb":"\/media\/\/\/monad_move\/thumb.png","url":"\/monad_move","edit_url":"\/edit\/\/monad_move","media_dir":"media\/\/\/monad_move\/","media":[{"filename":"1monad_jeep.png","local":"\/Users\/gdunne\/_portfolio\/www\/media\/\/\/monad_move\/1monad_jeep.png","url":"\/media\/\/\/monad_move\/1monad_jeep.png","extension":"png"},{"filename":"moan_move.png","local":"\/Users\/gdunne\/_portfolio\/www\/media\/\/\/monad_move\/moan_move.png","url":"\/media\/\/\/monad_move\/moan_move.png","extension":"png"},{"filename":"thumb.png","local":"\/Users\/gdunne\/_portfolio\/www\/media\/\/\/monad_move\/thumb.png","url":"\/media\/\/\/monad_move\/thumb.png","extension":"png"}]}]} \ No newline at end of file +{"entries":[{"config":{"title":"Tester","date":"2012-05-19","tags":"test project plog","featured":"1"},"title":"Tester","filename":"_config","path":"\/Users\/gdunne\/_portfolio\/www\/content\/tester\/_config","basename":"tester","dirname":"\/Users\/gdunne\/_portfolio\/www\/content","fileInfo":{},"timestamp":"1337410800","tags":["test","project","plog"],"featured":"1","related":null,"content":"

A test entrie that uses a self-container folder for its media.\n\nSome more of this post.<\/p>\n","content_short":"

A test entrie that uses a self-container folder for its media.<\/p>\n","comments_enabled":false,"comments":{"comments":[],"comments_loc":"\/Users\/gdunne\/_portfolio\/wwwcomments\/Users\/gdunne\/_portfolio\/www\/content\/tester\/_config\/","fileInfo":{},"_recaptcha_resp":null,"_recaptcha_error":null,"_comment_error":null},"cat":{"name":"tester","url":"\/tester\/"},"thumb":"\/content\/tester\/thumb.png","url":"\/tester","edit_url":"\/edit\/tester","media_dir":"\/Users\/gdunne\/_portfolio\/www\/content\/tester\/media","media":[{"filename":"egg.jpg","local":"\/Users\/gdunne\/_portfolio\/www\/content\/tester\/media\/egg.jpg","url":"\/content\/tester\/media\/egg.jpg","extension":"jpg"},{"filename":"Screen Shot 2012-10-08 at 6.08.07 PM.png","local":"\/Users\/gdunne\/_portfolio\/www\/content\/tester\/media\/Screen Shot 2012-10-08 at 6.08.07 PM.png","url":"\/content\/tester\/media\/Screen Shot 2012-10-08 at 6.08.07 PM.png","extension":"png"}]}]} \ No newline at end of file diff --git a/data/content/tags.json b/data/content/tags.json index 339d479..a64b30a 100644 --- a/data/content/tags.json +++ b/data/content/tags.json @@ -1 +1 @@ -{"tags":{"software":6,"installation":5,"structure":4,"process":5,"code":6,"performance":3,"studio":3,"audiovisual":6,"projection":5,"sculpture":8,"web":2,"design":9,"painting":5,"sketchbook":2,"commercial":1,"opengl":1,"processing":1,"photo":2,"video":1,"visualization":1,"typography":3,"drawing":2,"film":1,"animation":1,"print":3}} \ No newline at end of file +{"tags":{"test":1,"project":1,"plog":1}} \ No newline at end of file diff --git a/lib/config.ini b/lib/config.ini index 2a0ce06..7b52d9f 100644 --- a/lib/config.ini +++ b/lib/config.ini @@ -8,15 +8,16 @@ date_format = M d Y ; local locations web_root = / -data = data/ -content = content/ -comments = comments/ -templates = templates/ -pages = pages/ -media = media/ +data = data +content = content +comments = comments +templates = templates +pages = pages +media = media ; local filenames config_file = config +content_config_file = _config data_file = data.json tags_file = tags.json diff --git a/lib/data.php b/lib/data.php index 8ffb2aa..1dec526 100644 --- a/lib/data.php +++ b/lib/data.php @@ -33,14 +33,15 @@ function get_entries( $path = "", $args = array() ) } $entries = array(); - + + if (isset($dir_iterator)) { foreach ($dir_iterator as $file => $info) { - // skip dot files if (substr($info->getFilename(), 0, 1) == '.') continue; - if (!$info->isDir() && $info->getFilename() != CONFIG_FILE) { + // parse only specific files + if ($info->isFile() && $info->getFilename() == CONTENT_CONFIG_FILE) { $entry = parse_entry($info); if ($show_featured && empty($tag)) { if (isset($entry->featured)) { @@ -59,6 +60,8 @@ function get_entries( $path = "", $args = array() ) $entries = sort_entries($entries, $order_by, $order); + + if ($create_datafile) { if (!is_dir($data_path)) { if (!mkdir($data_path, 0777, true)) { @@ -267,10 +270,13 @@ function parse_entry($fileInfo, $page = false) return $entry(); } - $file['config'] = parse_ini_string($config); + + $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['basename'] = basename($fileInfo->getPath()); + $file['dirname'] = dirname($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(); @@ -281,7 +287,7 @@ function parse_entry($fileInfo, $page = false) $file['content'] = Markdown($content); if ($passed_more) - $file['content_short'] = Markdown($content_short); + $file['content_short'] = Markdown($content_short); $file['comments_enabled'] = isset($f['config']['comments']) && $f['config']['comments']; $file['comments'] = new Comments($fileInfo); @@ -291,16 +297,11 @@ function parse_entry($fileInfo, $page = false) $file['cat'] = $page ? null : array('name' => trim($cat,'/'), 'url' => WEB_ROOT . trim($cat , '/') . '/' ); $file['path'] = $fileInfo->getRealPath(); - $file['thumb'] = isset($file['config']['thumb']) ? $file['config']['thumb'] : WEB_ROOT . MEDIA . '/' . substr($file['cat']['url'],1) . $fileInfo->getFilename() . '/thumb.png'; - $file['url'] = clean_slashes( ($page ? '' : $file['cat']['url']) . $fileInfo->getFilename() ); - $file['edit_url'] = WEB_ROOT . 'edit/' . $file['url']; - - $file['media_dir'] = MEDIA . '/' . ($page ? '' : substr($file['cat']['url'],1)) . $fileInfo->getFilename() . '/'; - if (!is_dir($file['media_dir'])) { - if (!mkdir('./' . $file['media_dir'], 0777, true)) { - die('Failed to create folders...'); - } - } + $file['thumb'] = isset($file['config']['thumb']) ? $file['config']['thumb'] : WEB_ROOT . join(DIRECTORY_SEPARATOR, array(CONTENT_DIR, $file['basename'])) . '/thumb.png'; + $file['url'] = WEB_ROOT . ($page ? $file['filename'] : $file['basename']); + $file['edit_url'] = WEB_ROOT . 'edit' . $file['url']; + + $file['media_dir'] = join(DIRECTORY_SEPARATOR, array($file['dirname'], $file['basename'], MEDIA)); $file['media'] = (array) get_media( $file['media_dir'] ); $file['cat'] = (object) $file['cat']; $file['config'] = (object) $file['config']; @@ -309,7 +310,7 @@ function parse_entry($fileInfo, $page = false) } function get_media( $path ) { - $local_path = LOCAL_ROOT . '/' . $path; + $local_path = $path; $files = array(); if (is_dir($local_path)) { $dir_iterator = new DirectoryIterator($local_path); @@ -322,8 +323,14 @@ function get_media( $path ) { if (!$info->isDir()) { $files[] = (object) array( 'filename' => $info->getFilename(), - 'local' => $info->getPath() . '/' . $info->getFilename(), - 'url' => WEB_ROOT . $path . $info->getFilename(), + 'local' => join(DIRECTORY_SEPARATOR, array( + $info->getPath(), + $info->getFilename())), + 'url' => WEB_ROOT . join(DIRECTORY_SEPARATOR, array( + CONTENT_DIR, + basename(dirname($info->getPath())), + basename($info->getPath()), + $info->getFilename())), 'extension' => $info->getExtension() ); } @@ -351,7 +358,8 @@ function get_clean_path ( &$fileInfo, $page = false ) { function get_entry ( $relative_path ) { - return parse_entry(new SplFileInfo(join(array(LOCAL_ROOT, CONTENT_DIR, $relative_path), DIRECTORY_SEPARATOR))); + $f = join(array(LOCAL_ROOT, CONTENT_DIR, $relative_path, CONTENT_CONFIG_FILE), DIRECTORY_SEPARATOR); + return parse_entry(new SplFileInfo($f)); } function get_page ( $relative_path ) diff --git a/lib/init.php b/lib/init.php index d9dfc91..9936719 100644 --- a/lib/init.php +++ b/lib/init.php @@ -47,6 +47,7 @@ define ('PAGE_DIR', $_cfg['pages']); define ('CONFIG_DELIMITER', $_cfg['config_delim']); define ('GALLERY_DELIMITER', $_cfg['gallery_delim']); define ('CONFIG_FILE', $_cfg['config_file']); +define ('CONTENT_CONFIG_FILE', $_cfg['content_config_file']); define ('MORE_DELIMITER', $_cfg['more_delim']); define ('TITLE_DELIMITER', $_cfg['title_delim']); define ('DATE_FORMAT', $_cfg['date_format']); diff --git a/lib/model.php b/lib/model.php index cc4e361..2df4072 100644 --- a/lib/model.php +++ b/lib/model.php @@ -69,6 +69,7 @@ class Model } # if multiple (multiple files in CONTENT dir) if ($this->is_multiple()) { + if ($this->has_config() && !$_cfg) { $this->config = parse_config( $request['path'] ); if (isset($this->config->config->template)) { @@ -78,9 +79,8 @@ class Model $this->entry = $this->config; $this->page_title = preg_replace('{^/|/$}', '', $this->request['path']); - $recursive = $this->tag ? true : false; - $entries_args = array('recursive' => $recursive, 'tag' => $this->tag); + $entries_args = array('tag' => $this->tag); if (isset($this->config->config->show_featured)) { $entries_args['show_featured'] = true; } @@ -124,11 +124,12 @@ class Model $this->entry->is_single = true; - + + $gallery_type = isset($this->entry->config->gallery) ? $this->entry->config->gallery : null; if (strpos($this->entry->content, GALLERY_DELIMITER)) { - $this->entry->content = str_replace(GALLERY_DELIMITER, gallerize_media($this->entry), $this->entry->content); + $this->entry->content = str_replace(GALLERY_DELIMITER, gallerize_media($this->entry->media, $gallery_type), $this->entry->content); } else { - $this->entry->content = gallerize_media($this->entry) . $this->entry->content; + $this->entry->content = gallerize_media($this->entry->media, $gallery_type) . $this->entry->content; } $this->template = isset($this->entry->config->template) ? @@ -176,24 +177,24 @@ class Model function has_config() { - $conf = join(array( LOCAL_ROOT, CONTENT_DIR, $this->request['path'], CONFIG_FILE ), '/' ); - return is_file($conf) ? 1 : 0; + return is_file(join(array( LOCAL_ROOT, CONTENT_DIR, $this->request['path'], CONFIG_FILE ), '/' )) ? 1 : 0; } function is_multiple() { - return is_dir(join(array( LOCAL_ROOT, CONTENT_DIR, $this->request['path'] ), '/' )) ? 1 : 0; + $f = join(DIRECTORY_SEPARATOR, array( LOCAL_ROOT, CONTENT_DIR, $this->request['path'] )); + return is_dir($f) && !is_file(join(DIRECTORY_SEPARATOR, array($f, CONTENT_CONFIG_FILE))); } function is_single() { - return is_file(join(array( LOCAL_ROOT, CONTENT_DIR, $this->request['path'] ), '/' )) ? 1 : 0; + $f = join(DIRECTORY_SEPARATOR, array( LOCAL_ROOT, CONTENT_DIR, $this->request['path'], CONTENT_CONFIG_FILE )); + return is_file($f); } function is_page() { - $path = rtrim(join(array( LOCAL_ROOT, PAGE_DIR, $this->request['path'] ), '/' ), '/'); - return is_file($path) ? 1 : 0; + return is_file(rtrim(join(array( LOCAL_ROOT, PAGE_DIR, $this->request['path'] ), '/' ), '/')); } function get_filename() diff --git a/lib/output.php b/lib/output.php index fe6f3ad..c860db3 100644 --- a/lib/output.php +++ b/lib/output.php @@ -120,17 +120,18 @@ function get_rss_feed( $url ) } -function gallerize_media( $entry ) { +function gallerize_media( $media, $gallery_type = null ) { + $g = array(); - $type = isset($entry->config->gallery) ? $entry->config->gallery : null; + $type = $gallery_type; $g[] = $type != 'slides' && $type != 'stacked' ? '' : ''; $g[] = '