From f126c06050f97582a999c9e2e8191d5db6fc34c5 Mon Sep 17 00:00:00 2001 From: ROllerozxa Date: Sat, 29 Apr 2023 15:35:57 +0200 Subject: [PATCH] File icons and image thumbnails!!! --- .dirlistozxa/file.png | Bin 0 -> 137 bytes .dirlistozxa/folder.png | Bin 0 -> 370 bytes dirlistozxa.php | 70 +++++++++++++++++++++++++++++++--------- gen-thumbs | 8 +++++ 4 files changed, 63 insertions(+), 15 deletions(-) create mode 100644 .dirlistozxa/file.png create mode 100644 .dirlistozxa/folder.png create mode 100755 gen-thumbs diff --git a/.dirlistozxa/file.png b/.dirlistozxa/file.png new file mode 100644 index 0000000000000000000000000000000000000000..1bceff1a245910b71272470192e54e086d5c1190 GIT binary patch literal 137 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDD3?#L31Vw-pXMj(LYfh>jkoo`re>>*D8X$|Y zB*-tA!Qt7BG$2RM)5S4FBRDx>fqVoj3-^Yi1|B`VIWhu`&CJ2=2P3y~v9m8Ja48OJ eWHjTmWnfV0Q#IWG;aU$+CxfS}pUXO@geCy*!XlIa literal 0 HcmV?d00001 diff --git a/.dirlistozxa/folder.png b/.dirlistozxa/folder.png new file mode 100644 index 0000000000000000000000000000000000000000..7ca3618fd3fe5cf2382b1bbd9c3751eb57b4cba1 GIT binary patch literal 370 zcmV-&0ge8NP)U9bnx zU;3i;{G&#Z(~T{5?aWEZHRW>PJAd8IXxPHXu0&sT8 zwwIylbfEj~ByI0V@2VBfZ8ZA_bj<2b$prKO&R19m7$t3Yph(H=svU-2>%r%HNMMzN zw8l47D;x;y$?YywtX%9elX@FyK?aIRroX(hTn>1of3txWIWUm}+J%$>WuVCnWRJ=~ zGY-UKZUBylZYKTtvR~>yBYtrA89#BWzY-p6reV!%dNz$(;eZfA2qBu}4VH;Vj^9H> QjsO4v07*qoM6N<$f=g1KzW@LL literal 0 HcmV?d00001 diff --git a/dirlistozxa.php b/dirlistozxa.php index 17b67be..6d3c4b5 100644 --- a/dirlistozxa.php +++ b/dirlistozxa.php @@ -1,8 +1,29 @@ '/.dirlistozxa/folder.png', + THUMB_FILE => '/.dirlistozxa/file.png', + THUMB_IMAGE => "/.thumbs/".$name, + }; + return sprintf( - '%s%s%s', - $name, $name, $date, $size); + '%s%s%s', + $img, $name, $name, $date, $size); } function build_blocks($items) { @@ -40,13 +67,13 @@ function build_blocks($items) { natsort($objects['files']); if ($folder != '/') - $rtn .= row('../', '-', '-'); + $rtn .= row('../', '', '', THUMB_FOLDER); foreach ($objects['directories'] as $dir) { $name = basename($dir).'/'; $date = date('Y-m-d H:i', filemtime($path.$dir)); - $rtn .= row($name, $date, '-'); + $rtn .= row($name, $date, '-', THUMB_FOLDER); } foreach ($objects['files'] as $file) { @@ -54,7 +81,9 @@ function build_blocks($items) { $date = date('Y-m-d H:i', filemtime($path.$file)); $size = display_size(filesize($path.$file)); - $rtn .= row($name, $date, $size); + $doThumb = file_exists($_SERVER['DOCUMENT_ROOT']."/.thumbs/".$file) ? THUMB_IMAGE : THUMB_FILE; + + $rtn .= row($name, $date, $size, $doThumb); } return $rtn; @@ -83,18 +112,29 @@ a { color: lime; text-decoration: none; } + +.tum { + height: 48px; + width: 48px; +} +.tum img { + max-width: 100%; + max-height: 100%; + margin: auto; + display: block; +} -

Index of

+

Index of

- - - - - -
NameLast modifiedSize


-
server at , index powered by dirlistozxa
+ + + + + +
NameLast modifiedSize


+
server at , index powered by dirlistozxa
diff --git a/gen-thumbs b/gen-thumbs new file mode 100755 index 0000000..bc38ea2 --- /dev/null +++ b/gen-thumbs @@ -0,0 +1,8 @@ +#!/bin/bash + +# Generates thumbs + +rm -rf .thumbs/ +mkdir .thumbs + +find \( -iname "*.png" -or -iname "*.jpg" -or -iname "*.jpeg" \) -exec bash -c 'mogrify -path .thumbs/ -auto-orient -thumbnail 128x128 -quality 90% "{}" &' \; -- 2.44.0