From 3897fdc688ff53467a1f124c07a912813e52fe70 Mon Sep 17 00:00:00 2001 From: Stefan Schallerl Date: Fri, 7 Feb 2025 14:58:01 +0100 Subject: [PATCH] Fixes tags. --- app/src/main/kotlin/net/h34t/filemure/Util.kt | 5 +++-- .../tpl/net.h34t.filemure.tpl/DocumentCreateForm.tpl.html | 3 +-- .../main/tpl/net.h34t.filemure.tpl/DocumentEditForm.tpl.html | 3 +-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/app/src/main/kotlin/net/h34t/filemure/Util.kt b/app/src/main/kotlin/net/h34t/filemure/Util.kt index e656df0..be57ab3 100644 --- a/app/src/main/kotlin/net/h34t/filemure/Util.kt +++ b/app/src/main/kotlin/net/h34t/filemure/Util.kt @@ -48,11 +48,12 @@ fun formatHumanReadableSize(bytes: Long) = when (bytes) { else -> "${bytes / 1_000_000_000} gb" } -private val tagSplitRegex = Regex("\\s") +private val tagSplitRegex = Regex("\\s+") object TagAdapter { fun parse(ser: String?): List { - return ser?.let { if (it.isNotBlank()) it.split(tagSplitRegex).map { Tag(it) } else emptyList() } ?: emptyList() + return ser?.trim()?.let { if (it.isNotBlank()) it.split(tagSplitRegex).map { Tag(it) } else emptyList() } + ?: emptyList() } fun List.serialize() = if (this.isEmpty()) "" else this.joinToString(",") { it.value } diff --git a/app/src/main/tpl/net.h34t.filemure.tpl/DocumentCreateForm.tpl.html b/app/src/main/tpl/net.h34t.filemure.tpl/DocumentCreateForm.tpl.html index 817c716..59ccdfa 100644 --- a/app/src/main/tpl/net.h34t.filemure.tpl/DocumentCreateForm.tpl.html +++ b/app/src/main/tpl/net.h34t.filemure.tpl/DocumentCreateForm.tpl.html @@ -15,9 +15,8 @@
- + -
{for $tags}{*$tag}{/for}
diff --git a/app/src/main/tpl/net.h34t.filemure.tpl/DocumentEditForm.tpl.html b/app/src/main/tpl/net.h34t.filemure.tpl/DocumentEditForm.tpl.html index 6767c31..a78de53 100644 --- a/app/src/main/tpl/net.h34t.filemure.tpl/DocumentEditForm.tpl.html +++ b/app/src/main/tpl/net.h34t.filemure.tpl/DocumentEditForm.tpl.html @@ -14,9 +14,8 @@
- + -
{for $tags}{*$tag}{/for}