# HG changeset patch # User Tomas Zeman # Date 1542888929 -3600 # Node ID 48479e4b89d4d878254be32ff4a7a2e280dd1443 # Parent eb0fb99d02895d415515fa96adcba3f5c352871c App skeleton diff -r eb0fb99d0289 -r 48479e4b89d4 build.sc --- 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") diff -r eb0fb99d0289 -r 48479e4b89d4 jvm/resources/config.conf --- /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 + } +} diff -r eb0fb99d0289 -r 48479e4b89d4 jvm/resources/reference.conf --- /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 diff -r eb0fb99d0289 -r 48479e4b89d4 jvm/src/sqwl/cms/Server.scala --- /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) + +} diff -r eb0fb99d0289 -r 48479e4b89d4 jvm/src/sqwl/cms/Service.scala --- /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 +} diff -r eb0fb99d0289 -r 48479e4b89d4 jvm/src/sqwl/cms/UrlScheme.scala --- /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" + +} diff -r eb0fb99d0289 -r 48479e4b89d4 jvm/src/sqwl/cms/config.scala --- /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" + } + +}