From ae4eb30a73216ad7d8f8e8dbedd506189aef3393 Mon Sep 17 00:00:00 2001 From: Max Nuding Date: Sat, 27 Nov 2021 10:59:29 +0100 Subject: [PATCH] Improved formatting --- index.php | 16 ++++++++++++---- src/API/LoggerFactory.php | 22 ++++++++++++++++++++++ src/API/PhotoPrism.php | 16 ---------------- src/Entities/Album.php | 3 ++- 4 files changed, 36 insertions(+), 21 deletions(-) create mode 100644 src/API/LoggerFactory.php diff --git a/index.php b/index.php index ac056f5..1583d60 100644 --- a/index.php +++ b/index.php @@ -3,7 +3,9 @@ session_start(); require __DIR__ . '/vendor/autoload.php'; use PhotoPrismUpload\API\PhotoPrism; -$footer = ''; + +$footer = ''; ?> @@ -258,7 +260,9 @@ if (!isset($_POST['submit'])) { window.tooManyFiles = fileList.length > maxAmountOfFiles; if (window.tooManyFiles) { errorDiv.style.display = 'block'; - errorDiv.innerHTML += `Das sind zu viele Dateien, du darfst max. ${maxAmountOfFiles} Dateien gleichzeitig hochladen. `; + errorDiv.innerHTML += ``` + Das sind zu viele Dateien, du darfst max. + ${maxAmountOfFiles} Dateien gleichzeitig hochladen. ```; submitButton.disabled = true; console.warn('Total files:', target.files.length, '. Too many!'); } @@ -267,8 +271,12 @@ if (!isset($_POST['submit'])) { if (window.tooLarge) { const names = filesTooLarge.join(', ') errorDiv.style.display = 'block'; - const pluralizedMessage = filesTooLarge.length > 1 ? 'Die folgenden Dateien sind' : 'Die folgende Datei ist'; - errorDiv.innerHTML += `${pluralizedMessage} zu groß: ${names}. Jede Datei darf max. ${maxFileSize} MB groß sein.`; + const pluralizedMessage = filesTooLarge.length > 1 + ? 'Die folgenden Dateien sind' + : 'Die folgende Datei ist'; + errorDiv.innerHTML += ``` + ${pluralizedMessage} zu groß: ${names}. + Jede Datei darf max. ${maxFileSize} MB groß sein.```; submitButton.disabled = true; } }); diff --git a/src/API/LoggerFactory.php b/src/API/LoggerFactory.php new file mode 100644 index 0000000..3860479 --- /dev/null +++ b/src/API/LoggerFactory.php @@ -0,0 +1,22 @@ +setHandlers(self::$handlers); + $l->info('Initialized'); + return $l; + } +} diff --git a/src/API/PhotoPrism.php b/src/API/PhotoPrism.php index 2fe24e6..ec55342 100644 --- a/src/API/PhotoPrism.php +++ b/src/API/PhotoPrism.php @@ -4,27 +4,11 @@ namespace PhotoPrismUpload\API; use Monolog\Logger; use Monolog\Handler\RotatingFileHandler; -use Monolog\Handler\HandlerInterface; use Psr\Log\LoggerInterface; use PhotoPrismUpload\Exceptions\NetworkException; use PhotoPrismUpload\Exceptions\AuthenticationException; use PhotoPrismUpload\Entities\Album; -class LoggerFactory -{ - private static $handlers = []; - - public static function addHandler(HandlerInterface $handler) { - self::$handlers[] = $handler; - } - public static function create(string $name) { - $l = new Logger($name); - $l->setHandlers(self::$handlers); - $l->info('Initialized'); - return $l; - } -} - class PhotoPrism { protected string $base_url = 'https://photos.phlaym.net'; diff --git a/src/Entities/Album.php b/src/Entities/Album.php index b6490b2..ea3eb89 100644 --- a/src/Entities/Album.php +++ b/src/Entities/Album.php @@ -20,7 +20,8 @@ class Album $this->logger = LoggerFactory::create('PhotoPrismUpload.Album'); } - public function getUrlPath(): ?string { + public function getUrlPath(): ?string + { if (empty($this->token)) { return null; }