From 8a12519aecfc871dd7777fb5a7d5146a52d8dda9 Mon Sep 17 00:00:00 2001 From: AnrDaemon Date: Thu, 22 Jun 2017 19:14:38 +0300 Subject: [PATCH] Prepare 1.1.1 patch Encapsulate link composition. --- CHANGES | 28 ++-------------------------- Gallery.php | 7 ++++++- index.sample.php | 18 +++++++++--------- 3 files changed, 17 insertions(+), 36 deletions(-) diff --git a/CHANGES b/CHANGES index 250728e..909d375 100644 --- a/CHANGES +++ b/CHANGES @@ -1,30 +1,6 @@ ------------------------------------------------------------------------ -r668 | anrdaemon | 2017-06-22 00:12:01 +0300 (Чт, 22 июн 2017) | 2 lines +r669 | anrdaemon | 2017-06-22 18:52:05 +0300 (Чт, 22 июн 2017) | 2 lines -+ Force use of UTF-8 for file IO under PHP 7.1. - ------------------------------------------------------------------------- -r667 | anrdaemon | 2017-06-21 23:19:20 +0300 (Ср, 21 июн 2017) | 21 lines - -Gallery: -* Use constants to store default property values. -* Normalize file handling, encapsulate charset conversions inside a class. -* Use PCRE_UTF8 for regexps. -* Use getimagesize() to retrieve image metadata. -+ Allow custom mask listing. -+ Allow clearing SendFile support. -* Allow serving gallery from the root (empty sfPrefix). -* (Windows) fix failing realpath() once again. -+ Allow setting index template globally. -* Imagick paths use UTF-8 by default. -+ Caseless extension comparison. -+ Typehint arrays where possible. - -Index: -- Use default extensions set for directory listing. -- Check for images present in gallery, not files on disk. - Gallery already skips unreadable/unsupported files. - -+ Bump base library version. ++ Encapsulate link composition. ------------------------------------------------------------------------ diff --git a/Gallery.php b/Gallery.php index a1d9f02..1d47fe5 100644 --- a/Gallery.php +++ b/Gallery.php @@ -3,7 +3,7 @@ * * A simple drop-in file-based HTML gallery. * -* $Id: Gallery.php 668 2017-06-21 21:12:01Z anrdaemon $ +* $Id: Gallery.php 669 2017-06-22 15:52:05Z anrdaemon $ */ namespace AnrDaemon\MyLittleGallery; @@ -266,6 +266,11 @@ public function getPath($name = null, $local = null) return $path; } + public function getUrl($prefix, $name) + { + return $this->prefix[$prefix] . ($prefix === 'index' ? '/' : rawurlencode($name)); + } + public function thumbnailImage($name) { $path = iconv('UTF-8', $this->cs, "{$this->path}/.preview/$name"); diff --git a/index.sample.php b/index.sample.php index 2fcd2bf..43b6091 100644 --- a/index.sample.php +++ b/index.sample.php @@ -106,10 +106,10 @@ <?=htmlspecialchars($gallery[$name]['desc'])?> - My Little Gallery - + - +

Go up

-
showIndex();?>
+
showIndex()?>