diff --git a/CHANGES b/CHANGES index 476b197..1236b37 100644 --- a/CHANGES +++ b/CHANGES @@ -1,22 +1,42 @@ ------------------------------------------------------------------------ -r684 | anrdaemon | 2017-10-10 07:41:44 +0300 (Вт, 10 окт 2017) | 3 lines +r761 | anrdaemon | 2018-03-12 18:31:02 +0300 (Mon, 12 Mar 2018) | 2 lines -- Fix using $this outside object context. -* Change base classes' resolution. +* Fix default parameters for Gallery::getUrl(). ------------------------------------------------------------------------ -r674 | anrdaemon | 2017-06-25 02:01:04 +0300 (Вс, 25 июн 2017) | 2 lines +r760 | anrdaemon | 2018-03-12 09:01:38 +0300 (Mon, 12 Mar 2018) | 2 lines -* ArrayIterator to store entries. +* Correctly set HTTP response code. ------------------------------------------------------------------------ -r673 | anrdaemon | 2017-06-25 01:57:12 +0300 (Вс, 25 июн 2017) | 2 lines +r759 | anrdaemon | 2018-03-12 08:34:55 +0300 (Mon, 12 Mar 2018) | 2 lines -* Reformat initial assignment. ++ index.sample: Added index link to show image pages. ------------------------------------------------------------------------ -r672 | anrdaemon | 2017-06-24 00:56:23 +0300 (Сб, 24 июн 2017) | 2 lines +r758 | anrdaemon | 2018-03-12 08:01:19 +0300 (Mon, 12 Mar 2018) | 2 lines -* Fix setters chaining. ++ Added example PHAR stub and compilation instructions. + +------------------------------------------------------------------------ +r757 | anrdaemon | 2018-03-12 07:55:31 +0300 (Mon, 12 Mar 2018) | 2 lines + +* index.sample: Tweak built-in config activation case. + +------------------------------------------------------------------------ +r756 | anrdaemon | 2018-03-12 07:46:20 +0300 (Mon, 12 Mar 2018) | 2 lines + +* config.sample: More comments and better defaults. + +------------------------------------------------------------------------ +r755 | anrdaemon | 2018-03-12 06:51:49 +0300 (Mon, 12 Mar 2018) | 4 lines + +* index.sample: Make index appropriate for use in PHAr as is. +* index.sample: Tweak show image page CSS to combat text overlap. + +------------------------------------------------------------------------ +r692 | anrdaemon | 2017-10-27 20:48:50 +0300 (Fri, 27 Oct 2017) | 2 lines + +* Update dev-master alias. ------------------------------------------------------------------------ diff --git a/Gallery.php b/Gallery.php index bff74eb..e3a108a 100644 --- a/Gallery.php +++ b/Gallery.php @@ -3,7 +3,7 @@ * * A simple drop-in file-based HTML gallery. * -* $Id: Gallery.php 684 2017-10-10 04:41:44Z anrdaemon $ +* $Id: Gallery.php 761 2018-03-12 15:31:02Z anrdaemon $ */ namespace AnrDaemon\MyLittleGallery; @@ -265,7 +265,7 @@ public function getPath($name = null, $local = null) return $path; } - public function getUrl($prefix, $name) + public function getUrl($prefix, $name = '') { return $this->prefix[$prefix] . ($prefix === 'index' ? '/' : rawurlencode($name)); } diff --git a/README.md b/README.md index de2e7b6..c044f5f 100644 --- a/README.md +++ b/README.md @@ -7,9 +7,19 @@ A PHP class and templates to create a quick drop-in HTML gallery. ### Unable to read files with non-ASCII names #### PHP before 7.1 Check that encoding of `config.php` file itself matches value of GALLERY_FS_ENCODING constant. -#### PHP 7.1 +#### PHP 7.1+ `config.php` MUST be in `UTF-8`. -For PHP 7.1 GALLERY_FS_ENCODING and `$fsEncoding` parameter of the constructor are ignored. +For PHP 7.1 and up GALLERY_FS_ENCODING and `$fsEncoding` parameter of the constructor are ignored. Starting from PHP 7.1, [PHP uses internal_encoding to transcode file names](https://github.com/php/php-src/blob/e33ec61f9c1baa73bfe1b03b8c48a824ab2a867e/UPGRADING#L418). Before that, file IO under Windows (notably) done using "default" (so-called "ANSI") character set (i.e. CP1251 for Russian cyrillic). + +## Compiling single file archive + +``` +pharcommand.phar pack -f mlg.phar -s stub.php -c bzip2 index.php Gallery.php +``` + +Afterwards, the resulting `mlg.phar` can be used as index.php in your web gallery directory. +You may want to place config.php next to it to configure the gallery. +By default, it will list all recognized image files in current directory using UTF-8 encoding. diff --git a/composer.json b/composer.json index 96bc1d5..6ac8167 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,8 @@ }, "extra": { "branch-alias": { - "dev-master": "1.1.x-dev" + "dev-trunk": "1.2.x-dev", + "dev-master": "1.2.x-dev" } }, "autoload": { diff --git a/config.sample.php b/config.sample.php index f557d1f..fee5b32 100644 --- a/config.sample.php +++ b/config.sample.php @@ -18,16 +18,26 @@ //define('GALLERY_DESC_FILE', 'Files.bbs'); //define('GALLERY_DESC_FILE', 'Descript.ion'); -// Specify gallery descriptions encoding. -define('GALLERY_DESC_ENCODING', 'CP866'); +/** Specify gallery descriptions encoding. +* +* CP866 for cyrillic descriptions is common. +* UTF-8 is a sane default suitable for drop-in gallery. (It's not used anyway then.) +*/ +//define('GALLERY_DESC_ENCODING', 'CP866'); +define('GALLERY_DESC_ENCODING', 'UTF-8'); +/** Define general gallery layout +*/ define('GALLERY_PREVIEW_X', 160); define('GALLERY_PREVIEW_Y', 120); define('GALLERY_PREVIEW_WIDTH_FACTOR', 2); define('GALLERY_COLUMNS', 3); /** Allow X-SendFile/X-Accel-Redirect -* Uncomment one of the following defines +* +* Uncomment one of the following defines, if you know what you are doing. +* +* NB: SERVER CONFIGURATION IS REQUIRED BEFORE ACTIVATING THIS FEATURE! */ // Lighttpd, Apache mod_xsendfile //define('GALLERY_SENDFILE_HEADER', 'X-SendFile'); diff --git a/index.sample.php b/index.sample.php index 43b6091..308c5e9 100644 --- a/index.sample.php +++ b/index.sample.php @@ -5,7 +5,10 @@ require_once __DIR__ . '/Gallery.php'; } -require_once __DIR__ . '/config.php'; +if(!defined('GALLERY_BASE_DIR')) +{ + require_once __DIR__ . '/config.php'; +} ini_set('default_charset', 'UTF-8'); setlocale(LC_ALL, 'C.' . GALLERY_FS_ENCODING); @@ -36,8 +39,8 @@ 501 => 'Not implemented', ); $code = isset($map[$e->getCode()]) ? $e->getCode() : 500; - header("Status: $code", true, $code); - die(" + http_response_code($code); + exit(" {$code} {$map[$code]}

{$map[$code]}

@@ -105,6 +108,7 @@ <?=htmlspecialchars($gallery[$name]['desc'])?> - My Little Gallery + getUrl('view', $gallery[$name]['next']))?>"/>