Compare commits
3 Commits
b6ba1dfcd0
...
83c75ad3a9
Author | SHA1 | Date |
---|---|---|
|
83c75ad3a9 | |
|
ec5cac0680 | |
|
770b4f6e87 |
|
@ -0,0 +1,16 @@
|
||||||
|
.bsp/
|
||||||
|
.scala-build/
|
||||||
|
.metals/
|
||||||
|
.direnv
|
||||||
|
*/dist/
|
||||||
|
/11-single-price-grid-component/.bloop/
|
||||||
|
|
||||||
|
**/.bloop
|
||||||
|
**/project/project/
|
||||||
|
**/project/metals.sbt
|
||||||
|
**/project/.bloop
|
||||||
|
**/project/target/
|
||||||
|
**/target/
|
||||||
|
|
||||||
|
*/result
|
||||||
|
result
|
|
@ -0,0 +1,2 @@
|
||||||
|
version = "3.7.3"
|
||||||
|
runner.dialect = scala3
|
|
@ -0,0 +1,15 @@
|
||||||
|
ThisBuild / scalaVersion := "3.2.2"
|
||||||
|
fork := true
|
||||||
|
|
||||||
|
ThisBuild / version := "0.0.1"
|
||||||
|
ThisBuild / organization := "industries.sunshine"
|
||||||
|
|
||||||
|
lazy val root = (project in file("."))
|
||||||
|
.settings(
|
||||||
|
name := "rock-paper-scissors",
|
||||||
|
libraryDependencies ++= Seq(
|
||||||
|
"com.lihaoyi" %% "cask" % "0.9.1",
|
||||||
|
"com.lihaoyi" %% "mainargs" % "0.5.0",
|
||||||
|
"org.thymeleaf" % "thymeleaf" % "3.1.1.RELEASE",
|
||||||
|
)
|
||||||
|
)
|
|
@ -0,0 +1 @@
|
||||||
|
sbt.version=1.9.0
|
|
@ -0,0 +1,3 @@
|
||||||
|
addSbtPlugin("io.spray" % "sbt-revolver" % "0.10.0")
|
||||||
|
|
||||||
|
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "2.1.1")
|
Binary file not shown.
After Width: | Height: | Size: 1.0 KiB |
|
@ -0,0 +1,33 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html class="no-js" lang="">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta http-equiv="x-ua-compatible" content="ie=edge" />
|
||||||
|
<title>Initial flie</title>
|
||||||
|
<meta name="description" content="" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
|
<link
|
||||||
|
rel="icon"
|
||||||
|
type="image/png"
|
||||||
|
sizes="32x32"
|
||||||
|
href="../public/images/favicon-32x32.png"
|
||||||
|
th:href="'public/images/favicon-32x32.png'"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<link rel="apple-touch-icon" href="/apple-touch-icon.png" />
|
||||||
|
<!-- Place favicon.ico in the root directory -->
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<!--[if lt IE 8]>
|
||||||
|
<p class="browserupgrade">
|
||||||
|
You are using an <strong>outdated</strong> browser. Please
|
||||||
|
<a href="http://browsehappy.com/">upgrade your browser</a> to improve
|
||||||
|
your experience.
|
||||||
|
</p>
|
||||||
|
<![endif]-->
|
||||||
|
<main>
|
||||||
|
<h1>Hello!</h1>
|
||||||
|
<p th:text="${myVar}">with static text</p>
|
||||||
|
</main>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -0,0 +1,67 @@
|
||||||
|
package rockpaperscissors
|
||||||
|
|
||||||
|
import mainargs.{main, arg, ParserForMethods}
|
||||||
|
import cask.main.Routes
|
||||||
|
import org.thymeleaf.context.Context
|
||||||
|
import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver
|
||||||
|
import org.thymeleaf.TemplateEngine
|
||||||
|
|
||||||
|
object Main {
|
||||||
|
@main def run(
|
||||||
|
@arg(
|
||||||
|
name = "port",
|
||||||
|
short = 'p',
|
||||||
|
doc = "Port on which server will start serving"
|
||||||
|
)
|
||||||
|
portArg: Int = 8080,
|
||||||
|
@arg(name = "host", doc = "Host on which server will start serving.")
|
||||||
|
hostArg: String = "localhost"
|
||||||
|
): Unit = {
|
||||||
|
println(s"Will start server on ${hostArg}:${portArg}")
|
||||||
|
val server = new cask.Main {
|
||||||
|
override def allRoutes: Seq[Routes] = Seq(AppRoutes())
|
||||||
|
override def port: Int = portArg
|
||||||
|
override def host: String = hostArg
|
||||||
|
}
|
||||||
|
server.main(Array.empty)
|
||||||
|
}
|
||||||
|
|
||||||
|
def main(args: Array[String]): Unit = {
|
||||||
|
println(s"got args : $args")
|
||||||
|
ParserForMethods(this).runOrExit(args)
|
||||||
|
}
|
||||||
|
|
||||||
|
case class AppRoutes()(implicit cc: castor.Context, log: cask.Logger)
|
||||||
|
extends cask.Routes {
|
||||||
|
val templateResolver = new ClassLoaderTemplateResolver()
|
||||||
|
templateResolver.setPrefix("templates/");
|
||||||
|
templateResolver.setSuffix(".html")
|
||||||
|
templateResolver.setTemplateMode("HTML5")
|
||||||
|
|
||||||
|
val templateEngine = new TemplateEngine()
|
||||||
|
templateEngine.setTemplateResolver(templateResolver)
|
||||||
|
|
||||||
|
@cask.get("/")
|
||||||
|
def index(req: cask.Request) = {
|
||||||
|
val context = new Context()
|
||||||
|
println(s"getting request for ${req.remainingPathSegments}")
|
||||||
|
context.setVariable(
|
||||||
|
"myVar",
|
||||||
|
"Hello, from Scala world!"
|
||||||
|
)
|
||||||
|
val result = templateEngine.process("index", context)
|
||||||
|
cask.Response(
|
||||||
|
result,
|
||||||
|
headers = Seq("Content-Type" -> "text/html;charset=UTF-8")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@cask.staticResources("/public")
|
||||||
|
def publicFiles(req: cask.Request) = {
|
||||||
|
println(s"getting request for ${req.remainingPathSegments}")
|
||||||
|
"public"
|
||||||
|
}
|
||||||
|
initialize()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
package example
|
||||||
|
|
||||||
|
class ExampleSuite extends munit.FunSuite:
|
||||||
|
|
||||||
|
test("addition") {
|
||||||
|
assert(1 + 1 == 2)
|
||||||
|
}
|
||||||
|
end ExampleSuite
|
Loading…
Reference in New Issue