From: Mischa POSLAWSKY Date: Mon, 18 Sep 2017 16:54:42 +0000 (+0200) Subject: foto: image album browser and control X-Git-Tag: v3.3~22 X-Git-Url: http://git.shiar.net/minimedit.git/commitdiff_plain/77ab25edd98ec5a3871fc07bceaa0cd61949b69e foto: image album browser and control Original foto.php controller and related assets copied from Lijtweg at commit v2.5-24-ga5399c5d03 (2017-10-22). Requires image files at data/ symlinked into albums at foto/ with prefixed resolution attributes. Depends on external javascript libraries [PhotoSwipe and Flickr's Justified-Layout] at lib/ (changed from import/ at lijtweg) installed by make rules. --- diff --git a/.gitignore b/.gitignore index a99a8c9..33ea8fd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ -# link to some ckeditor build (or checkout in a pinch) -/ckeditor +# assets built by make rules +/lib +!/lib/photoswipe.html # dynamic user data /profile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..49bf4d2 --- /dev/null +++ b/Makefile @@ -0,0 +1,23 @@ +foto: lib/album.js lib/photoswipe.css lib/photoswipe-ui + +lib/album.js: lib/.photoswipe/dist/photoswipe.min.js lib/.photoswipe/dist/photoswipe-ui-default.min.js lib/.justified/dist/justified-layout.js + cat $^ >$@ + +lib/photoswipe.css: lib/.photoswipe/dist/photoswipe.css + ln -sf ../$^ $@ + +lib/photoswipe-ui: lib/.photoswipe/dist/default-skin + ln -sf ../$^ $@ + +lib/.photoswipe/dist/photoswipe.css: lib/.photoswipe +lib/.photoswipe/dist/photoswipe.min.js: lib/.photoswipe +lib/.photoswipe/dist/default-skin: lib/.photoswipe + +lib/.photoswipe: + git clone https://github.com/dimsemenov/PhotoSwipe $@ + +lib/.justified/dist/justified-layout.js: lib/.justified + +lib/.justified: + git clone https://github.com/flickr/justified-layout $@ + diff --git a/foto/album.inc.php b/foto/album.inc.php new file mode 100644 index 0000000..597e9a4 --- /dev/null +++ b/foto/album.inc.php @@ -0,0 +1,100 @@ + + + + + + + diff --git a/foto/index.php b/foto/index.php new file mode 100644 index 0000000..eadda91 --- /dev/null +++ b/foto/index.php @@ -0,0 +1,85 @@ +%s', + "/$PageAccess", pathinfo($PageAccess, PATHINFO_FILENAME) + ); + } + } + print "\n\n"; +} + +$nav = explode('/', $Page.$Args); +$title = array_pop($nav); +$rootname = "Foto's"; # override of 'foto' +$link = ''; +print "

"; +foreach ($nav as $i => $linktitle) { + $link .= "/$linktitle"; + printf('%s →'."\n", $link, $i ? $linktitle : $rootname); +} +print $Args ? $title : $rootname; +print "

\n\n"; + +print $intro; + +function showthumb($path) +{ + // assume all album entries are symlinks to archive originals + $target = preg_replace('{^(\.\./)*}', '', readlink($path)); + $thumb = preg_replace('{^data/}', 'thumb/200/', $target); + + @list ($order, $size, $title) = explode(':', pathinfo($path, PATHINFO_FILENAME), 3); + $imgtag = 'img src="/'.$thumb.'"'; + if ($title) { + $imgtag .= ' title="'.htmlspecialchars(urldecode($title)).'"'; + } + if ($size) { + $imgtag .= ' data-size="'.$size.'"'; + } + + return sprintf('<%s />'."\n", $target, $imgtag); +} + +if ($imgs = glob("$rootdir/*", GLOB_ONLYDIR)) { + natsort($imgs); + print '\n\n"; +} + +if ($imgs = glob("$rootdir/*.jpg")) { + print ''."\n\n"; + + include 'foto/album.inc.php'; +} diff --git a/foto/template.html b/foto/template.html new file mode 100644 index 0000000..e69de29 diff --git a/lib/photoswipe.html b/lib/photoswipe.html new file mode 100644 index 0000000..6372c5b --- /dev/null +++ b/lib/photoswipe.html @@ -0,0 +1,44 @@ +