From 74ff514a6ef37ee58eafd4b999b1138cda80da2e Mon Sep 17 00:00:00 2001 From: Max Nuding Date: Sun, 19 Feb 2023 11:28:11 +0100 Subject: [PATCH] Initial commit --- .gitignore | 47 ++++++ composer.json | 25 +++ config.php.EXAMPLE | 7 + index.html | 403 +++++++++++++++++++++++++++++++++++++++++++++ photos.php | 69 ++++++++ update.sh | 19 +++ 6 files changed, 570 insertions(+) create mode 100644 .gitignore create mode 100644 composer.json create mode 100644 config.php.EXAMPLE create mode 100644 index.html create mode 100644 photos.php create mode 100644 update.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d1cda7f --- /dev/null +++ b/.gitignore @@ -0,0 +1,47 @@ +config.php + +# Created by https://www.toptal.com/developers/gitignore/api/macos,composer +# Edit at https://www.toptal.com/developers/gitignore?templates=macos,composer + +### Composer ### +composer.phar +/vendor/ + +# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control +# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file +# composer.lock + +### macOS ### +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### macOS Patch ### +# iCloud generated files +*.icloud + +# End of https://www.toptal.com/developers/gitignore/api/macos,composer \ No newline at end of file diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..f0f5808 --- /dev/null +++ b/composer.json @@ -0,0 +1,25 @@ +{ + "name": "phlaym/photoprism-slideshow", + "require": { + "php": "^8.0", + "phlaym/photoprism-api": "dev-main" + }, + "autoload": { + "psr-4": { + "PhotoPrismUpload\\": "src/" + } + }, + "authors": [ + { + "name": "Max Nuding", + "email": "max.nuding@icloud.com" + } + ], + "repositories": [ + { + "type": "vcs", + "url": "https://phlaym.net/git/phlaym/photoprism-api.git" + } + ] + +} diff --git a/config.php.EXAMPLE b/config.php.EXAMPLE new file mode 100644 index 0000000..c06429d --- /dev/null +++ b/config.php.EXAMPLE @@ -0,0 +1,7 @@ + 'admin', + 'password' => '', + 'host' => 'https://photos.phlaym.net' +]; diff --git a/index.html b/index.html new file mode 100644 index 0000000..164e056 --- /dev/null +++ b/index.html @@ -0,0 +1,403 @@ + + + + + + + + + + +
+

Zeige Album:

+ + + + + + + + +
+ Hintergrundfarbe + + + + +
+ +
+ + + + \ No newline at end of file diff --git a/photos.php b/photos.php new file mode 100644 index 0000000..459a706 --- /dev/null +++ b/photos.php @@ -0,0 +1,69 @@ + ['message' => $message]])); +} + +if (!isset($_GET['album'])) { + goodbye('Kein Album angegeben!'); +} + +if (!isset($config['host'])) { + $config['host'] = 'https://photos.phlaym.net'; +} +$album_token = $_GET['album']; +$offset = $_GET['offset'] ?? 0; + +$api = new PhotoPrism($config); +try { + $api->login(); +} catch (\Exception $e) { + goodbye('Login bei Photoprism fehlgeschlagen'); +} +$album = null; +try { + if (isset($_SESSION[$album_token])) { + $album = $api->getAlbumById($_SESSION[$album_token], $album_token); + if (is_null($album)) { + goodbye('Fotoalbum konnte nicht gefunden werden'); + } + $album->photoCount = $_SESSION[$album_token . '_count']; + } else { + $album = $api->getAlbumByToken($album_token); + if (is_null($album)) { + goodbye('Fotoalbum konnte nicht gefunden werden'); + } + $_SESSION[$album_token] = $album->uid; + $_SESSION[$album_token . '_count'] = $album->photoCount; + } +} catch (\Exception $e) { + goodbye('Login bei Photoprism fehlgeschlagen'); +} + +$photo = null; +try { + $photos = $api->getAlbumPhotos($album, 1, $offset % $album->photoCount); + if (is_null($photos) || empty($photos)) { + goodbye('Fotos konnten nicht gefunden werden'); + } + $photo = $photos[0]; +} catch (\Exception $e) { + goodbye('Laden des nächstes Fotos fehlgeschlagen'); +} +echo json_encode( + [ + 'src' => $config['host'] . $photo->getEmbedUrl('fit_1920'), + 'count' => $album->photoCount, + 'album' => $album->title + ] +); diff --git a/update.sh b/update.sh new file mode 100644 index 0000000..168560e --- /dev/null +++ b/update.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +LATEST_RELEASE=$(curl -X 'GET' -H 'accept: application/json' 'https://phlaym.net/git/api/v1/repos/phlaym/photoprism-slideshow/releases' | jq .[0].tag_name -r) +CURRENT=$(cat version.txt 2> /dev/null) +SUCCESS=$? +if [[ $SUCCESS != 0 ]] +then + CURRENT='v0.0.0' +fi +if [[ $LATEST_RELEASE < $CURRENT ]] +then + echo "New version ${LATEST_RELEASE} is up to date with currently installed ${CURRENT}" + exit +fi + +echo "New version ${LATEST_RELEASE} detected, updating from ${CURRENT}" +wget "https://phlaym.net/git/phlaym/photoprism-slideshow/archive/${LATEST_RELEASE}.tar.gz" -O release.tar.gz + +tar xvf release.tar.gz \ No newline at end of file