From ddfdf100a88e59e81e8b7b879420290681ca8121 Mon Sep 17 00:00:00 2001 From: Lanius Trolling Date: Tue, 9 Apr 2024 14:33:50 -0400 Subject: [PATCH] Fix styling --- .../kotlin/info/mechyrdia/data/views_files.kt | 210 +++++++++--------- src/jvmMain/resources/static/admin.css | 14 +- 2 files changed, 121 insertions(+), 103 deletions(-) diff --git a/src/jvmMain/kotlin/info/mechyrdia/data/views_files.kt b/src/jvmMain/kotlin/info/mechyrdia/data/views_files.kt index dfbad0d..a8801cb 100644 --- a/src/jvmMain/kotlin/info/mechyrdia/data/views_files.kt +++ b/src/jvmMain/kotlin/info/mechyrdia/data/views_files.kt @@ -110,85 +110,87 @@ suspend fun ApplicationCall.adminViewVfs(path: StoragePath): HTML.() -> Unit { val tree = fileTree(path)!! return adminPage("VFS - /$path") { - h1 { +"/$path" } - - when (tree) { - is TreeNode.FileNode -> table { - tr { - th { - colSpan = "2" - +"/$path" + main { + 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" + 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() } - 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)))) { - +".." - } - } - render(path, tree.children) + is TreeNode.DirNode -> ul { + if (!path.isRoot) + li { + a(href = href(Root.Admin.Vfs.View(path.elements.dropLast(1)))) { + +".." + } + } + + render(path, tree.children) + } } } } @@ -242,28 +244,30 @@ suspend fun ApplicationCall.adminConfirmDeleteFile(path: StoragePath) { respond(HttpStatusCode.Conflict) else respondHtml(block = adminPage("Confirm Deletion of /$path") { - 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) } + main { + p { + +"Are you sure you want to delete the file at /$path? " + strong { +"It will be gone forever!" } } - tr { - th { +"Size (bytes)" } - td { +"${stats.size}" } + 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" } + } + +Entities.nbsp + form(method = FormMethod.post, action = href(Root.Admin.Vfs.DeleteConfirmPost(path.elements))) { + installCsrfToken() + submitInput(classes = "evil") { value = "Yes, delete it" } } - } - - 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" } } }) } @@ -290,26 +294,28 @@ suspend fun ApplicationCall.adminConfirmRemoveDirectory(path: StoragePath) { respond(HttpStatusCode.Conflict) else respondHtml(block = adminPage("Confirm Deletion of /$path") { - 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" } + 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" } + } } }) } diff --git a/src/jvmMain/resources/static/admin.css b/src/jvmMain/resources/static/admin.css index 61097e1..a8e1d29 100644 --- a/src/jvmMain/resources/static/admin.css +++ b/src/jvmMain/resources/static/admin.css @@ -44,7 +44,7 @@ body { width: 100vw; height: 100vh; margin: 0; - padding: 1em 20vmin; + padding: 0; background-color: #541; box-shadow: inset 0 0 15vmin 10vmin #000; @@ -69,6 +69,18 @@ body::after { pointer-events: none; } +main { + position: fixed; + top: 0; + left: 0; + right: 0; + bottom: 0; + + padding: 0 20vmin; + + overflow-y: auto; +} + div.message { position: fixed; top: 50vh; -- 2.25.1