Skip to content

Commit

Permalink
Prepare 1.1.1 patch
Browse files Browse the repository at this point in the history
Encapsulate link composition.
  • Loading branch information
AnrDaemon committed Jun 22, 2017
1 parent d2beb47 commit 8a12519
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 36 deletions.
28 changes: 2 additions & 26 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -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.

------------------------------------------------------------------------
7 changes: 6 additions & 1 deletion Gallery.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand Down
18 changes: 9 additions & 9 deletions index.sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@
<head>
<title><?=htmlspecialchars($gallery[$name]['desc'])?> - My Little Gallery</title>
<?php if(isset($gallery[$name]['prev'])):?>
<link rel="PREVIOUS" href="<?=htmlspecialchars($gallery->getPrefix('view') . rawurlencode($gallery[$name]['prev']))?>"/>
<link rel="PREVIOUS" href="<?=htmlspecialchars($gallery->getUrl('view', $gallery[$name]['prev']))?>"/>
<?php endif;
if(isset($gallery[$name]['next'])):?>
<link rel="NEXT" href="<?=htmlspecialchars($gallery->getPrefix('view') . rawurlencode($gallery[$name]['next']))?>"/>
<link rel="NEXT" href="<?=htmlspecialchars($gallery->getUrl('view', $gallery[$name]['next']))?>"/>
<?php endif; ?>
<style type="text/css"><!--
h1, p {
Expand Down Expand Up @@ -139,23 +139,23 @@
</head>
<body>
<h1><?=htmlspecialchars($gallery[$name]['desc'])?></h1>
<p><img src="<?=htmlspecialchars($gallery->getPrefix('image') . rawurlencode($name))?>
<p><img src="<?=htmlspecialchars($gallery->getUrl('image', $name))?>
" alt="<?=htmlspecialchars($gallery[$name]['desc'] . ' (' . $gallery->imageFileSize($name, 1024) . "\xC2\xA0kB)")?>
" title="" onclick="window.close();"/></p>
<?php if(isset($gallery[$name]['prev'])):?>
<div class="navFloater prev"><a href="<?=htmlspecialchars($gallery->getPrefix('view') . rawurlencode($gallery[$name]['prev']))?>
<div class="navFloater prev"><a href="<?=htmlspecialchars($gallery->getUrl('view', $gallery[$name]['prev']))?>
" title="<?=htmlspecialchars($gallery[$gallery[$name]['prev']]['desc'])?>
"><?=htmlspecialchars("<< {$gallery[$gallery[$name]['prev']]['desc']}")?></a></div>
<?php endif;
if(isset($gallery[$name]['next'])):?>
<div class="navFloater next"><a href="<?=htmlspecialchars($gallery->getPrefix('view') . rawurlencode($gallery[$name]['next']))?>
<div class="navFloater next"><a href="<?=htmlspecialchars($gallery->getUrl('view', $gallery[$name]['next']))?>
" title="<?=htmlspecialchars($gallery[$gallery[$name]['next']]['desc'])?>
"><?=htmlspecialchars("{$gallery[$gallery[$name]['next']]['desc']} >>")?></a></div>
<?php endif; ?>
<!-- Forum embed code
[url=<?="{$_SERVER['REQUEST_SCHEME']}://{$_SERVER['SERVER_NAME']}" . htmlspecialchars($gallery->getPrefix('view') . rawurlencode($name)) ?>
][img]<?="{$_SERVER['REQUEST_SCHEME']}://{$_SERVER['SERVER_NAME']}" . htmlspecialchars($gallery->getPrefix('thumbnail') . rawurlencode($name)) ?>[/img][/url]
[url=<?="{$_SERVER['REQUEST_SCHEME']}://{$_SERVER['SERVER_NAME']}" . htmlspecialchars($gallery->getPrefix('view') . rawurlencode($name)) ?>
[url=<?="{$_SERVER['REQUEST_SCHEME']}://{$_SERVER['SERVER_NAME']}" . htmlspecialchars($gallery->getUrl('view', $name))?>
][img]<?="{$_SERVER['REQUEST_SCHEME']}://{$_SERVER['SERVER_NAME']}" . htmlspecialchars($gallery->getUrl('thumbnail', $name))?>[/img][/url]
[url=<?="{$_SERVER['REQUEST_SCHEME']}://{$_SERVER['SERVER_NAME']}" . htmlspecialchars($gallery->getUrl('view', $name))?>
]<?=htmlspecialchars($gallery[$name]['desc'] . ' (' . $gallery->imageFileSize($name, 1024) . "\xC2\xA0kB)")?>[/url]
-->
</body>
Expand Down Expand Up @@ -192,7 +192,7 @@
//--></style>
</head>
<body><p><a href="./..">Go up</a></p>
<div class="MyLittleGallery"><?=$gallery->showIndex();?></div>
<div class="MyLittleGallery"><?=$gallery->showIndex()?></div>
<!-- pre style="text-align: left;"><?php//=print_r($gallery, true)?></pre -->
</body></html>
<?php
Expand Down

0 comments on commit 8a12519

Please sign in to comment.