From 723777f0b89a17853a2c87627f80013e4ac8014e Mon Sep 17 00:00:00 2001 From: Xwilarg Date: Wed, 11 Sep 2024 11:48:12 +0200 Subject: [PATCH 1/8] Fix crash if filesize is too big --- _internal/DeerLister.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_internal/DeerLister.php b/_internal/DeerLister.php index f28e7ce..c9117f2 100644 --- a/_internal/DeerLister.php +++ b/_internal/DeerLister.php @@ -35,7 +35,7 @@ function __construct() // Convert a size in byte to something more diggest $this->twig->addFilter(new TwigFilter("humanFileSize", function($size) { $units = ["B", "KB", "MB", "GB"]; - for ($i = 0; $size > 1024; $i++) $size /= 1024; + for ($i = 0; $size > 1024 && $i < count($units); $i++) $size /= 1024; return round($size, 2) . $units[$i]; })); From 58e0fe6320f11dc8594ff825416b2ee663c3114c Mon Sep 17 00:00:00 2001 From: Xwilarg Date: Wed, 11 Sep 2024 12:19:07 +0200 Subject: [PATCH 2/8] Fix broken preview --- _internal/js/script.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/_internal/js/script.js b/_internal/js/script.js index ae92e6e..6d71c15 100644 --- a/_internal/js/script.js +++ b/_internal/js/script.js @@ -51,6 +51,7 @@ function showFileModal(target, filename, content) { clone.querySelector("a").href = target.href // add into modal and show it - document.querySelector(".modal-body").innerHTML = clone + document.querySelector(".modal-body").innerHTML = "" + document.querySelector(".modal-body").appendChild(clone) document.getElementById("modal").style.display = "block" } From e447eb8d26fbb2497d89e0ed7d87857721bd41bf Mon Sep 17 00:00:00 2001 From: Xwilarg Date: Wed, 11 Sep 2024 12:24:21 +0200 Subject: [PATCH 3/8] Add basic share button --- _internal/css/index.css | 5 +++++ _internal/js/script.js | 11 +++++++++++ _internal/templates/index.html.twig | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/_internal/css/index.css b/_internal/css/index.css index 1ab2202..6612fda 100644 --- a/_internal/css/index.css +++ b/_internal/css/index.css @@ -141,6 +141,11 @@ body { text-decoration: none; } +.button:hover { + box-shadow: .15em .15em lightgrey; + cursor: pointer; +} + .codeblock { padding: 1em; border-radius: 5px; diff --git a/_internal/js/script.js b/_internal/js/script.js index 6d71c15..4bd5226 100644 --- a/_internal/js/script.js +++ b/_internal/js/script.js @@ -54,4 +54,15 @@ function showFileModal(target, filename, content) { document.querySelector(".modal-body").innerHTML = "" document.querySelector(".modal-body").appendChild(clone) document.getElementById("modal").style.display = "block" + + document.getElementById("share").addEventListener("click", _ => { + if (navigator.share) + { + navigator.share({url: target.href}); + } + else + { + window.prompt("Copy to share", target.href) + } + }) } diff --git a/_internal/templates/index.html.twig b/_internal/templates/index.html.twig index 27472d6..86d60de 100644 --- a/_internal/templates/index.html.twig +++ b/_internal/templates/index.html.twig @@ -27,7 +27,7 @@