From d822d11acc52c6d6a6bf76a0d6ab9bf813f975af Mon Sep 17 00:00:00 2001 From: Janis Date: Fri, 10 Oct 2025 11:50:10 +0200 Subject: [PATCH] Add HomeController and initial application setup with routing --- build.sbt | 9 +++++---- knockoutwhist | 1 - .../app/controllers/HomeController.scala | 15 ++++++++++++--- .../app/views/index.scala.html | 0 .../app/views/main.scala.html | 0 .../conf/application.conf | 0 .../conf/logback.xml | 0 .../conf/messages | 0 .../conf/routes | 0 .../public/images/favicon.png | Bin .../public/javascripts/main.js | 0 .../public/stylesheets/main.css | 0 .../test/controllers/HomeControllerSpec.scala | 0 13 files changed, 17 insertions(+), 8 deletions(-) delete mode 120000 knockoutwhist rename {knockoutwhist-web => knockoutwhistweb}/app/controllers/HomeController.scala (65%) rename {knockoutwhist-web => knockoutwhistweb}/app/views/index.scala.html (100%) rename {knockoutwhist-web => knockoutwhistweb}/app/views/main.scala.html (100%) rename {knockoutwhist-web => knockoutwhistweb}/conf/application.conf (100%) rename {knockoutwhist-web => knockoutwhistweb}/conf/logback.xml (100%) rename {knockoutwhist-web => knockoutwhistweb}/conf/messages (100%) rename {knockoutwhist-web => knockoutwhistweb}/conf/routes (100%) rename {knockoutwhist-web => knockoutwhistweb}/public/images/favicon.png (100%) rename {knockoutwhist-web => knockoutwhistweb}/public/javascripts/main.js (100%) rename {knockoutwhist-web => knockoutwhistweb}/public/stylesheets/main.css (100%) rename {knockoutwhist-web => knockoutwhistweb}/test/controllers/HomeControllerSpec.scala (100%) diff --git a/build.sbt b/build.sbt index b1946c4..2d99d91 100644 --- a/build.sbt +++ b/build.sbt @@ -28,10 +28,11 @@ lazy val commonSettings = Seq( lazy val knockoutwhist = project.in(file("knockoutwhist")) .settings( - commonSettings + commonSettings, + mainClass := Some("de.knockoutwhist.KnockOutWhist") ) -lazy val knockoutwhistWeb = project.in(file("knockoutwhist-web")) +lazy val knockoutwhistweb = project.in(file("knockoutwhistweb")) .enablePlugins(PlayScala) .dependsOn(knockoutwhist % "compile->compile;test->test") .settings( @@ -40,7 +41,7 @@ lazy val knockoutwhistWeb = project.in(file("knockoutwhist-web")) ) lazy val root = (project in file(".")) - .aggregate(knockoutwhist, knockoutwhistWeb) + .aggregate(knockoutwhist, knockoutwhistweb) .settings( - name := "KnockOutWhistRoot" + name := "KnockOutWhistWeb" ) diff --git a/knockoutwhist b/knockoutwhist deleted file mode 120000 index 22713e0..0000000 --- a/knockoutwhist +++ /dev/null @@ -1 +0,0 @@ -/home/janis/Workspaces/IntelliJ/knockoutwhist \ No newline at end of file diff --git a/knockoutwhist-web/app/controllers/HomeController.scala b/knockoutwhistweb/app/controllers/HomeController.scala similarity index 65% rename from knockoutwhist-web/app/controllers/HomeController.scala rename to knockoutwhistweb/app/controllers/HomeController.scala index 1bed9e2..883c557 100644 --- a/knockoutwhist-web/app/controllers/HomeController.scala +++ b/knockoutwhistweb/app/controllers/HomeController.scala @@ -12,6 +12,8 @@ import de.knockoutwhist.KnockOutWhist @Singleton class HomeController @Inject()(val controllerComponents: ControllerComponents) extends BaseController { + private var initial = false + /** * Create an Action to render an HTML page. * @@ -19,7 +21,14 @@ class HomeController @Inject()(val controllerComponents: ControllerComponents) e * will be called when the application receives a `GET` request with * a path of `/`. */ - def index() = Action { implicit request: Request[AnyContent] => - Ok(views.html.main.render("KnockoutWhist", views.html.index.render())) + def index() = { + if (!initial) { + initial = true + KnockOutWhist.main(new Array[String](_length = 0)) + } + Action { implicit request: Request[AnyContent] => { + Ok(views.html.main.render("KnockoutWhist", views.html.index.apply())) + } + } } -} +} \ No newline at end of file diff --git a/knockoutwhist-web/app/views/index.scala.html b/knockoutwhistweb/app/views/index.scala.html similarity index 100% rename from knockoutwhist-web/app/views/index.scala.html rename to knockoutwhistweb/app/views/index.scala.html diff --git a/knockoutwhist-web/app/views/main.scala.html b/knockoutwhistweb/app/views/main.scala.html similarity index 100% rename from knockoutwhist-web/app/views/main.scala.html rename to knockoutwhistweb/app/views/main.scala.html diff --git a/knockoutwhist-web/conf/application.conf b/knockoutwhistweb/conf/application.conf similarity index 100% rename from knockoutwhist-web/conf/application.conf rename to knockoutwhistweb/conf/application.conf diff --git a/knockoutwhist-web/conf/logback.xml b/knockoutwhistweb/conf/logback.xml similarity index 100% rename from knockoutwhist-web/conf/logback.xml rename to knockoutwhistweb/conf/logback.xml diff --git a/knockoutwhist-web/conf/messages b/knockoutwhistweb/conf/messages similarity index 100% rename from knockoutwhist-web/conf/messages rename to knockoutwhistweb/conf/messages diff --git a/knockoutwhist-web/conf/routes b/knockoutwhistweb/conf/routes similarity index 100% rename from knockoutwhist-web/conf/routes rename to knockoutwhistweb/conf/routes diff --git a/knockoutwhist-web/public/images/favicon.png b/knockoutwhistweb/public/images/favicon.png similarity index 100% rename from knockoutwhist-web/public/images/favicon.png rename to knockoutwhistweb/public/images/favicon.png diff --git a/knockoutwhist-web/public/javascripts/main.js b/knockoutwhistweb/public/javascripts/main.js similarity index 100% rename from knockoutwhist-web/public/javascripts/main.js rename to knockoutwhistweb/public/javascripts/main.js diff --git a/knockoutwhist-web/public/stylesheets/main.css b/knockoutwhistweb/public/stylesheets/main.css similarity index 100% rename from knockoutwhist-web/public/stylesheets/main.css rename to knockoutwhistweb/public/stylesheets/main.css diff --git a/knockoutwhist-web/test/controllers/HomeControllerSpec.scala b/knockoutwhistweb/test/controllers/HomeControllerSpec.scala similarity index 100% rename from knockoutwhist-web/test/controllers/HomeControllerSpec.scala rename to knockoutwhistweb/test/controllers/HomeControllerSpec.scala