feat(14): template in showdown-table, show choice
This commit is contained in:
parent
69a464a767
commit
66013ae1c6
|
@ -74,8 +74,8 @@
|
|||
<!-- This badge is fragment to be repeated in other pages as well -->
|
||||
<div
|
||||
th:fragment="choiceBadge (choiceBadgeData)"
|
||||
id="paper"
|
||||
th:id="${choiceBadgeData.c.name}"
|
||||
id="paper"
|
||||
class="top-[var(--top-offset)] left-[var(--left-offset)] w-[var(--diameter)] h-[var(--diameter)] bg-gradient-to-b rounded-full -translate-x-[var(--translation)] -translate-y-[var(--translation)] from-[var(--bg-bright)] to-[var(--bg-dark)]"
|
||||
style="
|
||||
--diameter: 8rem;
|
||||
|
|
|
@ -63,7 +63,10 @@
|
|||
class="flex relative flex-col items-center pt-10"
|
||||
>
|
||||
<!-- This will be imported fragment -->
|
||||
<!-- <p th:text="${playersChoiceData.c.toString}">Hello</p> -->
|
||||
<div th:replace="index::choiceBadge (${playersChoiceData})"> </div>
|
||||
<div
|
||||
th:remove="all"
|
||||
id="rock"
|
||||
class="top-[var(--top-offset)] left-[var(--left-offset)] w-[var(--diameter)] h-[var(--diameter)] bg-gradient-to-b rounded-full -translate-x-[var(--translation)] -translate-y-[var(--translation)] from-[var(--bg-bright)] to-[var(--bg-dark)]"
|
||||
style="
|
||||
|
|
|
@ -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 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")
|
||||
|
|
Loading…
Reference in New Issue