feat(14): template in showdown-table, show choice
This commit is contained in:
@@ -8,6 +8,9 @@ import org.thymeleaf.TemplateEngine
|
||||
import org.thymeleaf.Thymeleaf
|
||||
|
||||
import scala.jdk.CollectionConverters._
|
||||
import javax.swing.text.Position
|
||||
import rockpaperscissors.Models.Positioning
|
||||
import scala.util.Random
|
||||
|
||||
object Main {
|
||||
@main def run(
|
||||
@@ -62,11 +65,21 @@ object Main {
|
||||
@cask.get("/select/:choice")
|
||||
def acceptPlayerVote(choice: String) = {
|
||||
val context = new Context()
|
||||
val result = templateEngine.process("showdown", Set("showdown-table").asJava, context)
|
||||
cask.Response(
|
||||
result,
|
||||
headers = Seq("Content-Type" -> "text/html;charset=UTF-8")
|
||||
)
|
||||
val badge = Models.choiceSelectionItems.find(_.c.name == choice)
|
||||
val response = badge match {
|
||||
case Some(playersChoiceBadge) =>
|
||||
val badge = playersChoiceBadge.copy()
|
||||
badge.p = Positioning.Relative
|
||||
context.setVariable("playersChoiceData", badge)
|
||||
val result = templateEngine.process("showdown", Set("showdown-table").asJava, context)
|
||||
cask.Response(
|
||||
result,
|
||||
headers = Seq("Content-Type" -> "text/html;charset=UTF-8")
|
||||
)
|
||||
case None =>
|
||||
cask.Response(s"Unknown choice: '${choice}'", 400)
|
||||
}
|
||||
response
|
||||
}
|
||||
|
||||
@cask.staticResources("/public")
|
||||
|
||||
Reference in New Issue
Block a user