--- /dev/null
+<?
+
+$file = $_GET['f'];
+require_once(dirname(dirname(__FILE__)).'/serendipity_config.inc.php');
+require_once(S9Y_INCLUDE_PATH.'plugins/serendipity_plugin_gallery/lib.php');
+
+echo '
+<html>
+ <head>
+ <title>view image</title>
+ <link rel="stylesheet" type="text/css" href="'.$serendipity['baseURL'].'templates/sgn/style.css" />
+ </head>
+ <body>
+';
+
+
+$file = sanitize_filename($file);
+
+if (file_exists(SGN_DIR_ROOT.$file)) {
+ $caption = '';
+ $f = explode('.',$file);
+ if (file_exists(SGN_DIR_ROOT.str_replace($f[count($f)-1],'inc',$file))) {
+ $caption = implode('',file(SGN_DIR_ROOT.str_replace($f[count($f)-1],'inc',$file)));
+ }
+ echo '<p align="center"><img src="'.SGN_WEB_ROOT.$file.'" alt="'.strip_tags($caption).'" /></p>'
+ .'<p align="center">'.$caption.'</p>'
+ .'<p align="center">';
+ if ($prev = has_prev_image($file)) {
+ echo '<a href="/gallery/view.php?f='.$prev.'">prev</a> | ';
+ }
+ echo '<a href="/gallery/show'.substr($file,0,strrpos($file,'/')).'">dir</a>';
+ if ($next = has_next_image($file)) {
+ echo ' | <a href="/gallery/view.php?f='.$next.'">next</a> ';
+ }
+ echo '</p>';
+}
+?>
+</body>
+</html>
\ No newline at end of file
--- /dev/null
+<?php
+$serendipity['smarty']->assign('content_message','
+<h3 class="serendipity_date">about</h3>
+<p>A long list of not very interesting facts about me, in no particular order:</p>
+<ul>
+<li>I live in Wellington, New Zealand</li>
+<li>I was born in Dunedin, New Zealand on the 19th of April, 1980</li>
+<li>I work at <a href="http://catalyst.net.nz">Catalyst IT</a></li>
+<li>As a dirty, dirty nerd</li>
+<li>I feel the cold, and love electric blankets, heaters, and fires</li>
+<li>I like mod_rewrite a whole lot</li>
+<li>I have a cat called Nothing, named after a character in a book I read when I was 16</li>
+<li>I live with one other person, she has two cats</li>
+<li>That makes three cats</li>
+<li>I like my mail to arrive at least digitally signed</li>
+<li>I have visible tattoos and piercings</li>
+<li>I prefer postgres to mysql</li>
+<li>One thing that makes me really, really happy is to wake up in the morning after a storm, and have From the Edge of The Deep Green Sea by The Cure stuck in my head</li>
+<li>Mac hardware == hottt. I am a macwhore</li>
+<li>I like Open Source. Right now I am interested in <a href="http://moodle.org">Moodle</a>, <a href="http://elgg.net">Elgg</a>, and <a href="http://eduforge.org">Eduforge</a>, and am trying to find time to be more interested in <a href="http://debian.org">Debian</a></li>
+<li>I am generally reading about 4 or 5 books at any given time</li>
+<li>My parents are both archaeologists, I grew up with weird artifacts in my house that my friends laughed at</li>
+<li>I went to boarding school, and I hated it</li>
+<li>I was vegan for a year and a half, and vegetarian on-and-off for about 5. Now I am a shameless meatmouth</li>
+<li>I make clothes and jewellery</li>
+<li>I still use tables for layout in HTML</li>
+<li>Spelling errors make me really embarrassed</li>
+<li>I generally play at least 3 games of foosball every day. I prefer to play attack</li>
+<li>I try and convince everyone I know that they should install Linux, preferably Debian</li>
+<li>Which often means I end up being a one-woman helpdesk</li>
+<li>My favourite book is Still Life with Woodpecker, by Tom Robbins</li>
+<li>Give me <span class="mono">emacs</span> over <span class="mono">vi</span> any day</li>
+<li>When I\'m really tired, I often incorporate the alarm clock noise into my dream and keep sleeping</li>
+<li>(Obviously) I like lists</li>
+<li>I <i>do not</i> like it when people end a parenthesised sentence with a smiley face (like this ;)</li>
+</ul>
+');
+
+
+
+
+?>
'{PAT_PERMALINK_AUTHORS}',
'{PAT_PERMALINK_FEEDCATEGORIES}',
'{PAT_PERMALINK_CATEGORIES}',
- '{PAT_PERMALINK_FEEDAUTHORS}'
+ '{PAT_PERMALINK_FEEDAUTHORS}',
+ '{PAT_ABOUT}', '{PATH_ABOUT}',
+ '{PAT_GALLERY}','{PATH_GALLERY}',
+
),
array(
trim($PAT['PERMALINK_AUTHORS'], '@/i'),
trim($PAT['PERMALINK_FEEDCATEGORIES'], '@/i'),
trim($PAT['PERMALINK_CATEGORIES'], '@/i'),
- trim($PAT['PERMALINK_FEEDAUTHORS'], '@/i')
+ trim($PAT['PERMALINK_FEEDAUTHORS'], '@/i'),
+ trim($PAT['ABOUT'], '@/i'), $serendipity['permalinkAboutPath'],
+ trim($PAT['GALLERY'],'@/i'), $serendipity['permalinkGalleryPath'],
),
implode('', $a)
fwrite($fp, $match[1] . $content . $match[2]);
} else {
fwrite($fp, $content);
+ error_log('writing to file');
}
fclose($fp);
return true;
$serendipity['permalinkSearchPath'] = 'search';
}
+ if (!isset($serendipity['permalinkAboutPath'])) {
+ $serendipity['permalinkAboutPath'] = 'about';
+ }
+
+ if (!isset($serendipity['permalinkGallery{ath'])) {
+ $serendipity['permalinkGalleryPath'] = 'gallery';
+ }
+
/* URI paths
* These could be defined in the language headers, except that would break
* backwards URL compatibility
*/
+ @define('PATH_ABOUT', $serendipity['permalinkAboutPath']);
+ @define('PATH_GALLERY', $serendipity['permalinkGalleryPath']);
@define('PATH_ARCHIVES', $serendipity['permalinkArchivesPath']);
@define('PATH_ARCHIVE', $serendipity['permalinkArchivePath']);
@define('PATH_CATEGORIES', $serendipity['permalinkCategoriesPath']);
* If you add new patterns, remember to add the new rules to the *.tpl files and
* function serendipity_installFiles().
*/
+ @define('PAT_ABOUT', '@/'.PATH_ABOUT.'/?@');
+ @define('PAT_GALLERY','@/'.PATH_GALLERY.'/(.*)@');
@define('PAT_FILENAME', '0-9a-z\.\_!;,\+\-');
@define('PAT_CSS', '@/(serendipity\.css|serendipity_admin\.css)@');
@define('PAT_FEED', '@/(index|atom[0-9]*|rss|b2rss|b2rdf).(rss|rdf|rss2|xml)@');
$PAT = array();
+ $PAT['ABOUT'] = '@/' . $serendipity['permalinkAboutPath'];
+ $PAT['GALLERY'] = '@/' . $serendipity['permalinkGalleryPath'];
$PAT['UNSUBSCRIBE'] = '@/' . $serendipity['permalinkUnsubscribePath'].'/(.*)/([0-9]+)@';
$PAT['APPROVE'] = '@/' . $serendipity['permalinkApprovePath'].'/(.*)/(.*)/([0-9]+)@';
$PAT['DELETE'] = '@/' . $serendipity['permalinkDeletePath'].'/(.*)/(.*)/([0-9]+)@';
--- /dev/null
+<?php
+
+require_once(S9Y_INCLUDE_PATH.'plugins/serendipity_plugin_gallery/lib.php');
+
+// uriargs[0] should always be gallery
+// uriargs[1] can either be show, expand, collapse, view
+// the rest of the array is the actual useful stuff.
+
+$uriargs = explode('/',$_SERVER['REQUEST_URI']);
+
+$start = 0;
+$relevantargs = array();
+foreach ($uriargs as $arg) {
+ if ($arg == 'gallery') {
+ $start = 1;
+ }
+ if (empty($start)) {
+ continue;
+ }
+ $relevantargs[] = $arg;
+}
+
+$cmd = $relevantargs[1];
+
+$args = '';
+for ($i = 2; $i < count($relevantargs); $i++) {
+ $args .= '/'.$relevantargs[$i];
+}
+
+if ($cmd == 'show') {
+ $show = $args;
+}
+if (empty($show)) {
+ $show = (isset($_SESSION['show'])) ? $_SESSION['show'] : '';
+}
+$_SESSION['show'] = $show;
+
+if ($cmd == 'expand') {
+ $expand = $args;
+}
+if (empty($expand)) {
+ $expand =(isset($_SESSION['expand'])) ? $_SESSION['expand'] : '';
+}
+$_SESSION['expand'] = $expand;
+
+$expanded = $_SESSION['expanded'];
+if (empty($expanded)) {
+ $expanded = array();
+}
+$expanded[$expand] = 1;
+
+if ($cmd == 'collapse') {
+ $collapse= $args;
+}
+if (!empty($collapse)) {
+ $expanded[$collapse] = 0;
+}
+$_SESSION['expanded'] = $expanded;
+
+if ($cmd == 'search') {
+ $content = make_search($args);
+}
+else if ($cmd == 'view') {
+ $file = sanitize_filename($args);
+
+ if (file_exists(SGN_DIR_ROOT.$file)) {
+ $caption = '';
+ $f = explode('.',$file);
+ if (file_exists(SGN_DIR_ROOT.str_replace($f[count($f)-1],'inc',$file))) {
+ $caption = implode('',file(SGN_DIR_ROOT.str_replace($f[count($f)-1],'inc',$file)));
+
+ }
+ $content .= '<p align="center"><img src="'.SGN_WEB_ROOT.$file.'" alt="'.strip_tags($caption).'" /></p>'
+ .'<p align="center">'.$caption.'</p>';
+
+ }
+} else {
+ $content = make_directory($show);
+}
+
+$serendipity['smarty']->assign('content_message',$content);
+
+
+?>
\ No newline at end of file
case 'archives':
serendipity_printArchives();
break;
+ case 'about':
+ include_once(S9Y_INCLUDE_PATH.'include/about.inc.php');
+ break;
+ case 'gallery':
+ include_once(S9Y_INCLUDE_PATH.'include/gallery.inc.php');
+ break;
// Welcome screen or whatever
default:
RewriteRule ^{PAT_CSS} {indexFile}?url=/$1 [L,QSA]
RewriteRule ^index\.(html?|php.+) {indexFile}?url=index.html [L,QSA]
RewriteRule ^htmlarea/(.*) htmlarea/$1 [L,QSA]
+RewriteRule ^{PAT_ABOUT} {indexFile}?url=/{PAT_ABOUT}/ [L,QSA]
RewriteRule (.*\.html?) {indexFile}?url=/$1 [L,QSA]
<Files *.tpl.php>
$css_mode = $matches[1];
include_once(S9Y_INCLUDE_PATH . 'serendipity.css.php');
exit;
+} else if (preg_match(PAT_ABOUT, $uri, $matches)) {
+ $serendipity['GET']['action'] = 'about';
+ include_once(S9Y_INCLUDE_PATH . 'include/genpage.inc.php');
+} else if (preg_match(PAT_GALLERY, $uri, $matches)) {
+ $serendipity['GET']['action'] = 'gallery';
+ include_once(S9Y_INCLUDE_PATH . 'include/genpage.inc.php');
} else if (preg_match('@/(index(\.php|\.html)?)|'. preg_quote($serendipity['indexFile']) .'@', $uri) ||
preg_match('@^/' . preg_quote(trim($serendipity['serendipityHTTPPath'], '/')) . '/?(\?.*)?$@', $uri)) {
--- /dev/null
+<?php
+
+@define('SGN_DIR_ROOT',$serendipity['serendipityPath'].'gallery/images');
+@define('SGN_WEB_ROOT',$serendipity['baseURL'].'gallery/images');
+
+
+function make_tree($start,$indent,$show,$expand,$expanded) {
+ global $serendipity;
+ $spacer = serendipity_getTemplateFile('img/spacer.gif');
+ $plus = serendipity_getTemplateFile('img/plus.gif');
+ $minus = serendipity_getTemplateFile('img/minus.gif');
+ $plusGrey = serendipity_getTemplateFile('img/plusGrey.gif');
+ $minusGrey = serendipity_getTemplateFile('img/minusGrey.gif');
+
+ $children = get_children($start);
+
+
+ foreach ($children as $path => $name) {
+ echo '<img src="'.$spacer.'" height="1" width="'.$indent.'" />';
+ if ($expanded[$path] == 1) {
+ echo '<a href="'.$serendipity['baseURL'].'gallery/collapse'.$path.'"><img src="'.$minus.'" alt="expand" /></a> '."\n";
+ if ($show != $path) {
+ echo '<a href="'.$serendipity['baseURL'].'gallery/show'.$path.'">'.stripslashes($name).'</a><br />'."\n";
+ }
+ else {
+ echo '<span class="selected">'.stripslashes($name).'</span><br />'."\n";
+ }
+ make_tree($path,$indent+10,$show,$expand,$expanded);
+ }
+ else {
+ if (has_children($path)) {
+ echo '<a href="'.$serendipity['baseURL'].'gallery/expand'.$path.'"><img src="'.$plus.'" alt="expand" /></a> '."\n";
+ }
+ else {
+ echo '<img src="'.$plusGrey.'" alt="No children" /> '."\n";
+ }
+ if ($show != $path) {
+ echo '<a href="'.$serendipity['baseURL'].'gallery/show'.$path.'">'.stripslashes($name).'</a><br />'."\n";
+ }
+ else {
+ echo '<span class="selected">'.stripslashes($name).'</span><br />'."\n";
+ }
+ }
+ }
+}
+
+
+function has_children($path) {
+ global $serendipity;
+ $children = get_children($path);
+ if (!empty($children) || count($children)) {
+ return true;
+ }
+ return false;
+}
+
+
+function get_children($path) {
+ global $serendipity;
+ $fullpath = SGN_DIR_ROOT.$path;
+ $children = array();
+ $dir = opendir($fullpath);
+ while (false !== ($file = readdir($dir))) {
+ if (substr($file,0,1) == '.') { // hide hidden
+ continue;
+ }
+ if (!is_dir($fullpath.'/'.$file)) {
+ continue;
+ }
+ if ($path{strlen($path) -1} != '/') {
+ $path = $path.'/';
+ }
+ $children[$path.$file] = $file;
+ }
+ return $children;
+
+}
+
+
+function make_search($query) {
+ global $serendipity;
+
+}
+
+
+function make_directory($show) {
+ global $serendipity;
+ $content .='<div style="padding-left:20px">';
+ $content .='<p><b>showing images in: '.get_heading($show).':</b></p>';
+ if (file_exists(SGN_DIR_ROOT.$show.'/summary.inc')) {
+ $content .='<p>»» ';
+ $content .= implode('',file(SGN_DIR_ROOT.$show.'/summary.inc'));
+ $content .='</p>';
+ }
+ $files = get_images($show);
+ if (!is_array($files) || !count($files)) {
+ $content .='<p>»» No images!</p>';
+ $content .='</div>';
+ }
+ else {
+ $content .='</div>';
+ $content .='<table cellpadding="20"><tr>';
+ $count = 1;
+ foreach ($files as $file) {
+ $thumb = get_thumb($show,$file);
+ $f = explode('.',$file);
+ $caption = '';
+ if (file_exists(SGN_DIR_ROOT.$show.str_replace($f[count($f)-1],'inc',$file))) {
+ $caption = implode('',file(SGN_DIR_ROOT.$show.str_replace($f[count($f)-1],'inc',$file)));
+ }
+ $content .='<td><a href="'.$serendipity['baseURL'].'gallery/view.php?f='.$show.'/'.$file.'"><img src="'.SGN_WEB_ROOT.$thumb.'" alt="'.$caption.'" /></a></td>';
+ if ($count == 3) {
+ $content .='</tr><tr>';
+ $count = 1;
+ }
+ else {
+ $count++;
+ }
+ }
+ $content .='</tr></table>';
+ }
+ $content .='<div style="padding-left:20px">';
+ $content .='<p><b>subdirectories:</b></p>';
+
+ $children = get_children($show);
+
+ if (count($children)) {
+ foreach ($children as $path => $child) {
+ $content .='<p>»» <a href="'.$serendipity['baseURL'].'gallery/show'.$path.'">'.$child.'</a>';
+ if (file_exists(SGN_DIR_ROOT.$path.'/summary.inc')) {
+ $content .='<br />'
+ .implode('',file(SGN_DIR_ROOT.$path.'/summary.inc'));
+ }
+ $content .='</p>';
+ }
+ } else {
+ $content .='<p>No children</p>';
+ }
+ $content .='</div>';
+ return $content;
+}
+
+function get_heading($str) {
+ global $serendipity;
+ $dirs = explode('/',$str);
+ $newstr = '';
+ foreach ($dirs as $index => $dir) {
+ $path = '';
+ for ($i = 0; $i < $index; $i++) {
+ $path .= $dirs[$i].'/';
+ }
+ $newstr .= '<a href="'.$serendipity['baseURL'].'gallery/show'.$path.$dir.'">'.$dir.'</a>/';
+ }
+ return $newstr;
+}
+
+
+function get_images($path) {
+ global $serendipity;
+ $fullpath = SGN_DIR_ROOT.$path;
+ $children = array();
+ $dir = opendir($fullpath);
+ while (false !== ($file = readdir($dir))) {
+ if (substr($file,0,1) == '.') { // hide hidden
+ continue;
+ }
+ if (is_dir($fullpath.'/'.$file)) {
+ continue;
+ }
+ $f = explode('.',$file);
+ if ($f[count($f)-1] == 'inc') {
+ continue;
+ }
+ if ($f[count($f)-2] == 'thumb') {
+ continue;
+ }
+ if ($file{strlen($file)-1} == '~') {
+ // naughty emacs
+ continue;
+ }
+ if ($path{strlen($path) -1} != '/') {
+ $path = $path.'/';
+ }
+ $children[$path.$file] = $file;
+ }
+ return $children;
+}
+
+function get_thumb($path,$filename) {
+ global $serendipity;
+
+ $f = explode('.',$filename);
+ $thumbname = $path.'/'.str_replace($f[count($f)-1],'thumb.'.$f[count($f)-1],$filename);
+
+ if (file_exists(SGN_DIR_ROOT.$thumbname)) {
+ return $thumbname;
+ }
+
+
+ // set up some config variables
+ $width = 100; // max width of thumb
+ $height = 100; // max height of thumb
+
+ $view = SGN_DIR_ROOT.$path.'/'.$filename;
+
+ $extn = strtolower(substr($filename, -3));
+ switch($extn) {
+ case 'jpg':
+ $old = @ImageCreateFromJPEG($view);
+ break;
+
+ case 'png':
+ $old = @ImageCreateFromPNG($view);
+ break;
+ }
+
+
+ if (empty($old)) {
+ return false;
+ } else {
+ $old_x = ImageSX($old);
+ $old_y = ImageSY($old);
+
+ // make new thumbnail
+ if ($old_y > $old_x) {
+ $new_y = $height; // max height of thumb
+ $new_x = ($old_x * $new_y)/$old_y; // retain aspect ratio
+ }
+ else {
+ $new_x = $width; // max width of thumb
+ $new_y = ($old_y * $new_x)/$old_x; // retain aspect ratio
+ }
+ // $new = ImageCreate($new_x, $new_y);
+ $new = ImageCreateTrueColor($new_x, $new_y);
+ @ImageCopyResized($new, $old, 0, 0, 0, 0, $new_x, $new_y, $old_x, $old_y);
+ }
+
+ imageInterlace($new);
+ touch(SGN_DIR_ROOT.$thumbname);
+ $result = ImagePNG($new,SGN_DIR_ROOT.$thumbname);
+ return $thumbname;
+}
+
+function sanitize_filename($file) {
+ global $serendipity;
+ $path = explode('/',$file);
+ $return = '';
+ foreach ($path as $p) {
+ if ($p != '..') {
+ $return .= $p.'/';
+ }
+ }
+ return substr($return,0,-1);
+
+}
+
+
+function has_next_image($file) {
+ $images = get_images(substr($file,0,strrpos($file,'/')));
+ $count = 0;
+ $ret = false;
+ foreach ($images as $k => $v) {
+ if (!empty($ret)) {
+ return $k;
+ }
+ if ($k == $file) {
+ if ($count != count($images)-1) {
+ $ret = true;
+ }
+ }
+ $count++;
+ }
+ return false;
+}
+
+function has_prev_image($file) {
+ $images = get_images(substr($file,0,strrpos($file,'/')));
+ $count = 0;
+ $ret = false;
+ foreach ($images as $k => $v) {
+ if ($k == $file) {
+ if (!empty($ret)) {
+ return $ret;
+ }
+ }
+ $ret = $k;
+ $count++;
+ }
+ return false;
+}
+
+
+?>
--- /dev/null
+<?php # $Id: serendipity_plugin_comments.php 7 2005-04-16 06:39:31Z s_bergmann $
+require_once('lib.php');
+
+// Probe for a language include with constants. Still include defines later on, if some constants were missing
+$probelang = dirname(__FILE__) . '/lang_' . $serendipity['lang'] . '.inc.php';
+if (file_exists($probelang)) {
+ include $probelang;
+}
+
+switch ($serendipity['lang']) {
+ case 'en':
+ default:
+ @define('PLUGIN_GALLERY','Image gallery');
+ @define('PLUGIN_GALLERY_BLAHBLAH', 'Embedded image gallery');
+ break;
+}
+
+class serendipity_plugin_gallery extends serendipity_plugin
+{
+ var $title = PLUGIN_GALLERY;
+
+ function introspect(&$propbag)
+ {
+ global $serendipity;
+
+ $propbag->add('name', PLUGIN_GALLERY);
+ $propbag->add('description', PLUGIN_GALLERY_BLAHBLAH);
+ $propbag->add('stackable', true);
+ $propbag->add('author', 'Penny Leach');
+ $propbag->add('version', '1.0');
+ $propbag->add('requirements', array(
+ 'serendipity' => '0.8',
+ 'smarty' => '2.6.7',
+ 'php' => '4.1.0'
+ ));
+ }
+
+ function generate_content(&$title)
+ {
+ global $serendipity;
+ $title = $this->title;
+
+
+ $show = $_GET['show'];
+ if (!isset($show)) {
+ $show = (isset($_SESSION['show'])) ? $_SESSION['show'] : '';
+ }
+ $_SESSION['show'] = $show;
+ $expand = $_GET['expand'];
+ if (!isset($_GET['expand'])) {
+ $expand =(isset($_SESSION['expand'])) ? $_SESSION['expand'] : '';
+ }
+ $_SESSION['expand'] = $expand;
+ $expanded = $_SESSION['expanded'];
+ if (!isset($expanded)) {
+ $expanded = array();
+ }
+ $expanded[$expand] = 1;
+ $collapse= $_GET['collapse'];
+ if (isset($collapse)) {
+ $expanded[$collapse] = 0;
+ }
+ $_SESSION['expanded'] = $expanded;
+ $op = $_GET['op'];
+
+ make_tree('/',1,$show,$expand,$expanded);
+ }
+
+}
+
+
+/* vim: set sts=4 ts=4 expandtab : */
+?>