From: Lanius Trolling Date: Tue, 9 Apr 2024 18:31:22 +0000 (-0400) Subject: Fix instant rendering & improve styling X-Git-Url: https://gitweb.starshipfights.net/?a=commitdiff_plain;h=3235fd04b477b4b31c570aed0037743620fcf0ae;p=factbooks Fix instant rendering & improve styling --- diff --git a/src/jvmMain/kotlin/info/mechyrdia/data/views_files.kt b/src/jvmMain/kotlin/info/mechyrdia/data/views_files.kt index a8801cb..dfbad0d 100644 --- a/src/jvmMain/kotlin/info/mechyrdia/data/views_files.kt +++ b/src/jvmMain/kotlin/info/mechyrdia/data/views_files.kt @@ -110,87 +110,85 @@ suspend fun ApplicationCall.adminViewVfs(path: StoragePath): HTML.() -> Unit { val tree = fileTree(path)!! return adminPage("VFS - /$path") { - main { - h1 { +"/$path" } - - when (tree) { - is TreeNode.FileNode -> table { - tr { - th { - colSpan = "2" - +"/$path" - } + h1 { +"/$path" } + + when (tree) { + is TreeNode.FileNode -> table { + tr { + th { + colSpan = "2" + +"/$path" } - tr { - td { - colSpan = "2" - iframe { - src = href(Root.Admin.Vfs.Inline(path.elements)) - } + } + tr { + td { + colSpan = "2" + iframe { + src = href(Root.Admin.Vfs.Inline(path.elements)) } } - tr { - th { +"Last updated" } - td { dateTime(tree.stats.updated) } - } - tr { - th { +"Size (bytes)" } - td { +"${tree.stats.size}" } - } - tr { - th { +"Actions" } - td { - ul { - li { - a(href = href(Root.Admin.Vfs.Download(path.elements))) { - +"Download" - } + } + tr { + th { +"Last updated" } + td { dateTime(tree.stats.updated) } + } + tr { + th { +"Size (bytes)" } + td { +"${tree.stats.size}" } + } + tr { + th { +"Actions" } + td { + ul { + li { + a(href = href(Root.Admin.Vfs.Download(path.elements))) { + +"Download" } - li { - form(action = href(Root.Admin.Vfs.Overwrite(path.elements)), method = FormMethod.post, encType = FormEncType.multipartFormData) { - installCsrfToken() - label { - fileInput(name = "uploaded") - +"Upload New Version" - } - submitInput() + } + li { + form(action = href(Root.Admin.Vfs.Overwrite(path.elements)), method = FormMethod.post, encType = FormEncType.multipartFormData) { + installCsrfToken() + label { + fileInput(name = "uploaded") + +"Upload New Version" } + submitInput() } - li { - a(href = href(Root.Admin.Vfs.DeleteConfirmPage(path.elements))) { - +"Delete" - } + } + li { + a(href = href(Root.Admin.Vfs.DeleteConfirmPage(path.elements))) { + +"Delete" } } } } - tr { - th { +"Navigate" } - td { - ul { - path.elements.indices.forEach { index -> - val parent = path.elements.take(index) - li { - a(href = href(Root.Admin.Vfs.View(parent))) { - +"/${StoragePath(parent)}" - } + } + tr { + th { +"Navigate" } + td { + ul { + path.elements.indices.forEach { index -> + val parent = path.elements.take(index) + li { + a(href = href(Root.Admin.Vfs.View(parent))) { + +"/${StoragePath(parent)}" } } } } } } - - is TreeNode.DirNode -> ul { - if (!path.isRoot) - li { - a(href = href(Root.Admin.Vfs.View(path.elements.dropLast(1)))) { - +".." - } + } + + is TreeNode.DirNode -> ul { + if (!path.isRoot) + li { + a(href = href(Root.Admin.Vfs.View(path.elements.dropLast(1)))) { + +".." } - - render(path, tree.children) - } + } + + render(path, tree.children) } } } @@ -244,31 +242,29 @@ suspend fun ApplicationCall.adminConfirmDeleteFile(path: StoragePath) { respond(HttpStatusCode.Conflict) else respondHtml(block = adminPage("Confirm Deletion of /$path") { - main { - p { - +"Are you sure you want to delete the file at /$path? " - strong { +"It will be gone forever!" } - } - table { - tr { - th { +"Last Updated" } - td { dateTime(stats.updated) } - } - tr { - th { +"Size (bytes)" } - td { +"${stats.size}" } - } - } - - form(method = FormMethod.get, action = href(Root.Admin.Vfs.View(path.elements))) { - submitInput { value = "No, take me back" } + p { + +"Are you sure you want to delete the file at /$path? " + strong { +"It will be gone forever!" } + } + table { + tr { + th { +"Last Updated" } + td { dateTime(stats.updated) } } - +Entities.nbsp - form(method = FormMethod.post, action = href(Root.Admin.Vfs.DeleteConfirmPost(path.elements))) { - installCsrfToken() - submitInput(classes = "evil") { value = "Yes, delete it" } + tr { + th { +"Size (bytes)" } + td { +"${stats.size}" } } } + + form(method = FormMethod.get, action = href(Root.Admin.Vfs.View(path.elements))) { + submitInput { value = "No, take me back" } + } + +Entities.nbsp + form(method = FormMethod.post, action = href(Root.Admin.Vfs.DeleteConfirmPost(path.elements))) { + installCsrfToken() + submitInput(classes = "evil") { value = "Yes, delete it" } + } }) } @@ -294,28 +290,26 @@ suspend fun ApplicationCall.adminConfirmRemoveDirectory(path: StoragePath) { respond(HttpStatusCode.Conflict) else respondHtml(block = adminPage("Confirm Deletion of /$path") { - main { - p { - +"Are you sure you want to delete the directory at /$path? " - strong { +"It, and all of its contents, will be gone forever!" } - } - ul { - for (entry in entries) - li { - +entry.name - if (entry.type == StoredFileType.DIRECTORY) - +"/" - } - } - - form(method = FormMethod.get, action = href(Root.Admin.Vfs.View(path.elements))) { - submitInput { value = "No, take me back" } - } - +Entities.nbsp - form(method = FormMethod.post, action = href(Root.Admin.Vfs.RmDirConfirmPost(path.elements))) { - installCsrfToken() - submitInput(classes = "evil") { value = "Yes, delete it" } - } + p { + +"Are you sure you want to delete the directory at /$path? " + strong { +"It, and all of its contents, will be gone forever!" } + } + ul { + for (entry in entries) + li { + +entry.name + if (entry.type == StoredFileType.DIRECTORY) + +"/" + } + } + + form(method = FormMethod.get, action = href(Root.Admin.Vfs.View(path.elements))) { + submitInput { value = "No, take me back" } + } + +Entities.nbsp + form(method = FormMethod.post, action = href(Root.Admin.Vfs.RmDirConfirmPost(path.elements))) { + installCsrfToken() + submitInput(classes = "evil") { value = "Yes, delete it" } } }) } diff --git a/src/jvmMain/resources/static/admin.css b/src/jvmMain/resources/static/admin.css index e821bc8..61097e1 100644 --- a/src/jvmMain/resources/static/admin.css +++ b/src/jvmMain/resources/static/admin.css @@ -44,6 +44,7 @@ body { width: 100vw; height: 100vh; margin: 0; + padding: 1em 20vmin; background-color: #541; box-shadow: inset 0 0 15vmin 10vmin #000; @@ -68,16 +69,6 @@ body::after { pointer-events: none; } -main { - position: fixed; - top: 0; - left: 20vmin; - right: 20vmin; - bottom: 0; - - overflow-y: auto; -} - div.message { position: fixed; top: 50vh; diff --git a/src/jvmMain/resources/static/admin.js b/src/jvmMain/resources/static/admin.js index 000b9fd..e6ad241 100644 --- a/src/jvmMain/resources/static/admin.js +++ b/src/jvmMain/resources/static/admin.js @@ -7,4 +7,14 @@ }); } }); + + window.addEventListener("load", function () { + // Localize dates and times + const moments = document.getElementsByClassName("moment"); + for (const moment of moments) { + let date = new Date(Number(moment.textContent.trim())); + moment.innerHTML = date.toLocaleString(); + moment.style.display = "inline"; + } + }); })();