Skip to content

Commit

Permalink
Added deployment features and functionality
Browse files Browse the repository at this point in the history
Co-authored-by: LarsVomMars <[email protected]>
  • Loading branch information
marvinborner and LarsVomMars committed May 1, 2019
1 parent a3c1054 commit 8549c68
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 264 deletions.
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,17 @@
- Supports Windows, MacOS, Linux and *BSD
- Open source

## Installation
To install and run Kloud, you can either download the latest release on GitHub or use the "Development setup" instructions
below to build an executable yourself.
After that you can easily start the server via `java -jar kloud-VERSION-all.jar`

## Development setup
* Setup JVM Environment
* Setup Java JDK and JRE Environment
* Install Gradle
* Clone repository
* `./gradlew[.bat] run`
* `gradle run`
* For building, use: `gradle build`

## Help us with a small donation :)
<p align="center">
Expand Down
10 changes: 9 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,24 @@ buildscript {
plugins {
id 'org.jetbrains.kotlin.jvm' version '1.3.11'
id 'nu.studer.rocker' version '0.4'
id 'com.github.johnrengelman.shadow' version '5.0.0'
id 'java'
}

group "space.anity"
version "1.0-SNAPSHOT"
version "0.1-BETA"

apply plugin: 'java'
apply plugin: 'kotlin'
apply plugin: 'application'
apply plugin: 'com.github.johnrengelman.shadow'
jar.enabled = false
mainClassName = 'space.anity.AppKt'

shadowJar {
baseName = 'kloud'
}

repositories {
jcenter()
}
Expand Down
172 changes: 0 additions & 172 deletions gradlew

This file was deleted.

84 changes: 0 additions & 84 deletions gradlew.bat

This file was deleted.

27 changes: 24 additions & 3 deletions src/main/kotlin/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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.*

Expand All @@ -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()
Expand All @@ -43,6 +40,30 @@ fun main() {
if (URI(ctx.url()).normalize().toString() != ctx.url()) ctx.redirect(URI(ctx.url()).normalize().toString())
}

/**
* 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
*/
Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/DatabaseController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/js/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ function setListeners() {
})
});
}

// deletion button
document.querySelectorAll(".delete").forEach(element => {
element.addEventListener("click", e => {
Expand Down

0 comments on commit 8549c68

Please sign in to comment.