--- a/build.sc Thu Nov 08 19:12:42 2018 +0100
+++ b/build.sc Thu Nov 22 13:15:29 2018 +0100
@@ -52,7 +52,6 @@
"-Xcheckinit", // Wrap field accessors to throw an exception on uninitialized access.
"-Xfuture", // Turn on future language features.
"-target:jvm-1.8",
- "--illegal-access=warn"
)}
}
@@ -67,11 +66,13 @@
ivy"com.typesafe.akka::akka-slf4j:$akkaVer",
ivy"org.json4s::json4s-native:3.6.2",
ivy"ch.qos.logback:logback-classic:1.2.3",
- ivy"com.lihaoyi::scalatags:0.6.7"
+ ivy"com.lihaoyi::scalatags:0.6.7",
+ ivy"org.webjars:bootstrap:4.1.3",
+ ivy"org.webjars:font-awesome:5.5.0"
)
override def scalacOptions = T{super.scalacOptions.map(_ :+
- "-Xmacro-settings:conf.output.dir=jvm/src/main/resources"
+ "-Xmacro-settings:conf.output.dir=jvm/resources"
)}
override def mainClass = Some("sqwl.cms.Server")
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jvm/resources/config.conf Thu Nov 22 13:15:29 2018 +0100
@@ -0,0 +1,7 @@
+config {
+ http {
+ interface = localhost
+ port = 8080
+ prefix = cms
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jvm/resources/reference.conf Thu Nov 22 13:15:29 2018 +0100
@@ -0,0 +1,1 @@
+include "config.conf"
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jvm/src/sqwl/cms/Server.scala Thu Nov 22 13:15:29 2018 +0100
@@ -0,0 +1,28 @@
+package sqwl.cms
+
+import akka.actor.ActorSystem
+import akka.http.scaladsl.Http
+import akka.http.scaladsl.model.{ContentTypes, HttpEntity}
+import akka.http.scaladsl.server.Directives._
+import akka.stream.{ActorMaterializer, Materializer}
+
+import scala.concurrent.ExecutionContextExecutor
+
+object Server extends App with Service with config with UrlScheme {
+ override implicit val system: ActorSystem = ActorSystem()
+ override implicit val executor: ExecutionContextExecutor = system.dispatcher
+ override implicit val materializer: Materializer = ActorMaterializer()
+
+ private val routes = get {
+ path(http.prefix) {
+ complete(HttpEntity(ContentTypes.`text/html(UTF-8)`, "main"))
+ } ~ pathPrefix(http.prefix / ASSETS) {
+ getFromResourceDirectory("META-INF/resources/webjars")
+ } ~ pathPrefix(http.prefix / PUBLIC) {
+ getFromResourceDirectory("public")
+ }
+ }
+
+ Http().bindAndHandle(routes, http.interface, http.port)
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jvm/src/sqwl/cms/Service.scala Thu Nov 22 13:15:29 2018 +0100
@@ -0,0 +1,12 @@
+package sqwl.cms
+
+import akka.actor.ActorSystem
+import akka.stream.Materializer
+
+import scala.concurrent.ExecutionContextExecutor
+
+trait Service {
+ implicit val system: ActorSystem
+ implicit def executor: ExecutionContextExecutor
+ implicit val materializer: Materializer
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jvm/src/sqwl/cms/UrlScheme.scala Thu Nov 22 13:15:29 2018 +0100
@@ -0,0 +1,7 @@
+package sqwl.cms
+
+trait UrlScheme {
+ val ASSETS = "assets"
+ val PUBLIC = "public"
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jvm/src/sqwl/cms/config.scala Thu Nov 22 13:15:29 2018 +0100
@@ -0,0 +1,13 @@
+package sqwl.cms
+
+import com.wacai.config.annotation.conf
+
+@conf trait config {
+
+ final val http = new {
+ val interface = "localhost"
+ val port = 8080
+ val prefix = "cms"
+ }
+
+}