aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/kotlin/App.kt27
-rw-r--r--src/main/kotlin/DatabaseController.kt4
-rw-r--r--src/main/resources/js/files.js1
3 files changed, 27 insertions, 5 deletions
diff --git a/src/main/kotlin/App.kt b/src/main/kotlin/App.kt
index 49cc553..1aa150b 100644
--- a/src/main/kotlin/App.kt
+++ b/src/main/kotlin/App.kt
@@ -9,8 +9,6 @@ import io.javalin.rendering.*
import io.javalin.rendering.template.TemplateUtil.model
import io.javalin.security.*
import io.javalin.security.SecurityUtil.roles
-import io.javalin.staticfiles.*
-import java.io.*
import java.net.*
import java.util.logging.*
@@ -22,7 +20,6 @@ private val log = Logger.getLogger("App.kt")
fun main() {
val app = Javalin.create().apply {
- enableStaticFiles("${File(".").absolutePath}/src/main/resources/", Location.EXTERNAL)
port(7000)
accessManager { handler, ctx, permittedRoles -> roleManager(handler, ctx, permittedRoles) }
}.start()
@@ -44,6 +41,30 @@ fun main() {
}
/**
+ * Renders the static resources (important for deployed jar files)
+ */
+ get(
+ "/css/*", { ctx ->
+ ctx.contentType("text/css")
+ ctx.result(Thread.currentThread().contextClassLoader.getResourceAsStream("css/" + ctx.splat(0)))
+ },
+ roles(Roles.GUEST)
+ )
+ get(
+ "/js/*", { ctx ->
+ ctx.contentType("text/js")
+ ctx.result(Thread.currentThread().contextClassLoader.getResourceAsStream("js/" + ctx.splat(0)))
+ },
+ roles(Roles.GUEST)
+ )
+ get(
+ "/fonts/*", { ctx ->
+ ctx.result(Thread.currentThread().contextClassLoader.getResourceAsStream("fonts/" + ctx.splat(0)))
+ },
+ roles(Roles.GUEST)
+ )
+
+ /**
* Main page
*/
get(
diff --git a/src/main/kotlin/DatabaseController.kt b/src/main/kotlin/DatabaseController.kt
index dbb41ba..cce9601 100644
--- a/src/main/kotlin/DatabaseController.kt
+++ b/src/main/kotlin/DatabaseController.kt
@@ -64,8 +64,8 @@ class DatabaseController(dbFileLocation: String = "main.db") {
*/
object General : Table() {
val id = integer("id").autoIncrement().primaryKey()
- val initialUse = bool("initialUse").default(true).primaryKey()
- val isSetup = bool("isSetup").default(false).primaryKey()
+ val initialUse = bool("initialUse").default(true)
+ val isSetup = bool("isSetup").default(false)
}
init {
diff --git a/src/main/resources/js/files.js b/src/main/resources/js/files.js
index d8755cb..de52635 100644
--- a/src/main/resources/js/files.js
+++ b/src/main/resources/js/files.js
@@ -186,6 +186,7 @@ function setListeners() {
})
});
}
+
// deletion button
document.querySelectorAll(".delete").forEach(element => {
element.addEventListener("click", e => {