updates
This commit is contained in:
@@ -32,3 +32,62 @@ dependencies {
|
||||
api "org.jetbrains.exposed:exposed-jdbc:$kotlin_exposed_version"
|
||||
api "org.postgresql:postgresql:$psql_version"
|
||||
}
|
||||
|
||||
|
||||
task copyClient(type: Copy) {
|
||||
dependsOn ":postssystem.client:jsBrowserDistribution"
|
||||
File clientSources = project(":postssystem.client").file("build/distributions")
|
||||
SourceDirectorySet resources = sourceSets.main.resources
|
||||
File webFolderPath = new File(resources.getSrcDirs()[0].toString(), "web")
|
||||
exclude("*.map")
|
||||
from clientSources.absolutePath
|
||||
into webFolderPath.absolutePath
|
||||
}
|
||||
|
||||
|
||||
tasks.getByName("compileKotlin")
|
||||
.dependsOn(project(":postssystem.client").jsBrowserDistribution)
|
||||
.dependsOn(copyClient)
|
||||
tasks.getByName("compileKotlin").configure {
|
||||
mustRunAfter project(":postssystem.client").jsBrowserDistribution
|
||||
mustRunAfter copyClient
|
||||
}
|
||||
|
||||
tasks.getByName("run")
|
||||
.dependsOn(project(":postssystem.client").jsBrowserDistribution)
|
||||
.dependsOn(copyClient)
|
||||
tasks.getByName("run").configure {
|
||||
mustRunAfter project(":postssystem.client").jsBrowserDistribution
|
||||
mustRunAfter copyClient
|
||||
}
|
||||
|
||||
task copyUIKitCSS(type: Copy) {
|
||||
dependsOn ":postssystem.client.uikit:build"
|
||||
File dist = project(":postssystem.client.uikit").file("dist")
|
||||
SourceDirectorySet resources = sourceSets.main.resources
|
||||
File webFolderPath = new File(resources.getSrcDirs()[0].toString(), "web")
|
||||
File cssFilesFolder = new File(dist, "css")
|
||||
from cssFilesFolder.absolutePath
|
||||
include "uikit.min.css"
|
||||
into new File(webFolderPath, "css").absolutePath
|
||||
}
|
||||
|
||||
task copyUIKitJS(type: Copy) {
|
||||
dependsOn ":postssystem.client.uikit:build"
|
||||
File dist = project(":postssystem.client.uikit").file("dist")
|
||||
SourceDirectorySet resources = sourceSets.main.resources
|
||||
File webFolderPath = new File(resources.getSrcDirs()[0].toString(), "web")
|
||||
File jsFilesFolder = new File(dist, "js")
|
||||
from jsFilesFolder.absolutePath
|
||||
include "uikit.min.js"
|
||||
include "uikit-icons.min.js"
|
||||
into new File(webFolderPath, "js").absolutePath
|
||||
}
|
||||
|
||||
tasks.getByName("processResources")
|
||||
.dependsOn(copyUIKitJS)
|
||||
.dependsOn(copyUIKitCSS)
|
||||
tasks.getByName("processResources").configure {
|
||||
mustRunAfter copyUIKitJS
|
||||
mustRunAfter copyUIKitCSS
|
||||
}
|
||||
|
@@ -2,21 +2,19 @@ package dev.inmo.postssystem.server
|
||||
|
||||
import dev.inmo.micro_utils.ktor.server.configurators.ApplicationRoutingConfigurator
|
||||
import io.ktor.application.call
|
||||
import io.ktor.http.content.files
|
||||
import io.ktor.http.content.static
|
||||
import io.ktor.http.content.*
|
||||
import io.ktor.response.respondRedirect
|
||||
import io.ktor.routing.Route
|
||||
import io.ktor.routing.get
|
||||
import java.io.File
|
||||
|
||||
class ClientStaticRoutingConfiguration(
|
||||
clientStatic: String?
|
||||
private val clientStatic: String?
|
||||
) : ApplicationRoutingConfigurator.Element {
|
||||
private val staticFile = clientStatic ?.let { File(clientStatic).takeIf { it.exists() } }
|
||||
override fun Route.invoke() {
|
||||
staticFile ?.let {
|
||||
clientStatic ?.let {
|
||||
static("client") {
|
||||
files(it)
|
||||
resources(it)
|
||||
get {
|
||||
call.respondRedirect("client/index.html")
|
||||
}
|
||||
|
@@ -12,7 +12,6 @@ data class Config(
|
||||
val databaseConfig: DatabaseConfig = DatabaseConfig(),
|
||||
@SerialName("auth")
|
||||
val authConfig: AuthConfig = AuthConfig(),
|
||||
val clientStatic: String? = null,
|
||||
val filesFolder: String,
|
||||
val debugMode: Boolean = false
|
||||
) {
|
||||
|
@@ -192,7 +192,7 @@ fun getDIModule(
|
||||
singleWithBinds { RolesManagerRolesStorageServerRoutesConfigurator(get(), get()) }
|
||||
singleWithBinds { ServerPostsServiceRoutingConfigurator(get(), get(), get()) }
|
||||
|
||||
singleWithBinds { ClientStaticRoutingConfiguration(get<Config>().clientStatic) }
|
||||
singleWithBinds { ClientStaticRoutingConfiguration("web") }
|
||||
singleWithBinds {
|
||||
RolesAuthenticationConfigurator<Role>(
|
||||
get(),
|
||||
@@ -213,6 +213,7 @@ fun getDIModule(
|
||||
)
|
||||
}
|
||||
singleWithBinds { AuthenticationRoutingConfigurator(get(), get(), get()) }
|
||||
singleWithBinds { NotFoundStatusPageRedirectToIndex("/client") }
|
||||
|
||||
if (config.debugMode) {
|
||||
single<ApplicationRoutingConfigurator.Element>(StringQualifier("Tracer")) { ApplicationRoutingConfigurator.Element {(this as Routing).trace { application.log.trace(it.buildText()) } } }
|
||||
|
@@ -0,0 +1,17 @@
|
||||
package dev.inmo.postssystem.server
|
||||
|
||||
import dev.inmo.micro_utils.ktor.server.configurators.StatusPagesConfigurator
|
||||
import io.ktor.application.call
|
||||
import io.ktor.features.StatusPages
|
||||
import io.ktor.http.HttpStatusCode
|
||||
import io.ktor.response.respondRedirect
|
||||
|
||||
data class NotFoundStatusPageRedirectToIndex(
|
||||
val redirectTo: String
|
||||
) : StatusPagesConfigurator.Element {
|
||||
override fun StatusPages.Configuration.invoke() {
|
||||
status(HttpStatusCode.NotFound) {
|
||||
call.respondRedirect(redirectTo)
|
||||
}
|
||||
}
|
||||
}
|
5
server/src/main/resources/web/css/containers.css
Normal file
5
server/src/main/resources/web/css/containers.css
Normal file
@@ -0,0 +1,5 @@
|
||||
.vertical_container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
1
server/src/main/resources/web/css/uikit.min.css
vendored
Normal file
1
server/src/main/resources/web/css/uikit.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
3
server/src/main/resources/web/css/visibility.css
Normal file
3
server/src/main/resources/web/css/visibility.css
Normal file
@@ -0,0 +1,3 @@
|
||||
.gone {
|
||||
display: none;
|
||||
}
|
24
server/src/main/resources/web/index.html
Normal file
24
server/src/main/resources/web/index.html
Normal file
@@ -0,0 +1,24 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>PostsSystem</title>
|
||||
|
||||
<link rel="stylesheet" href="css/uikit.min.css">
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700" type="text/css">
|
||||
<link rel="stylesheet" href="css/containers.css" type="text/css">
|
||||
<link rel="stylesheet" href="css/visibility.css" type="text/css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="navbar" class="uk-section uk-section-secondary uk-padding-remove"></div>
|
||||
<main class="uk-flex">
|
||||
<div id="main" class="main-view"></div>
|
||||
<div id="modal"></div>
|
||||
</main>
|
||||
|
||||
<script src="js/uikit.min.js"></script>
|
||||
<script src="js/uikit-icons.min.js"></script>
|
||||
<script type="application/javascript" src="postssystem.client.js"></script>
|
||||
</body>
|
||||
</html>
|
1
server/src/main/resources/web/js/uikit-icons.min.js
vendored
Normal file
1
server/src/main/resources/web/js/uikit-icons.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
server/src/main/resources/web/js/uikit.min.js
vendored
Normal file
1
server/src/main/resources/web/js/uikit.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
2
server/src/main/resources/web/postssystem.client.js
Normal file
2
server/src/main/resources/web/postssystem.client.js
Normal file
File diff suppressed because one or more lines are too long
@@ -4,7 +4,6 @@
|
||||
"username": "test",
|
||||
"password": "test"
|
||||
},
|
||||
"clientStatic": "../client/build/distributions",
|
||||
"filesFolder": "/tmp/files",
|
||||
"debugMode": true
|
||||
}
|
||||
|
Reference in New Issue
Block a user