feat(15): associating session with root page
This commit is contained in:
parent
2d514e9258
commit
03aa9f8b94
File diff suppressed because one or more lines are too long
|
@ -1 +0,0 @@
|
|||
hello from the resource file!
|
|
@ -548,6 +548,14 @@ video {
|
|||
bottom: 0px;
|
||||
}
|
||||
|
||||
.end-0 {
|
||||
inset-inline-end: 0px;
|
||||
}
|
||||
|
||||
.top-0 {
|
||||
top: 0px;
|
||||
}
|
||||
|
||||
.col-start-2 {
|
||||
grid-column-start: 2;
|
||||
}
|
||||
|
@ -569,6 +577,10 @@ video {
|
|||
margin-top: -5rem;
|
||||
}
|
||||
|
||||
.mb-2 {
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.ml-2 {
|
||||
margin-left: 0.5rem;
|
||||
}
|
||||
|
@ -593,10 +605,6 @@ video {
|
|||
margin-top: 0.3rem;
|
||||
}
|
||||
|
||||
.mb-2 {
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.flex {
|
||||
display: flex;
|
||||
}
|
||||
|
@ -621,6 +629,10 @@ video {
|
|||
height: 3rem;
|
||||
}
|
||||
|
||||
.h-14 {
|
||||
height: 3.5rem;
|
||||
}
|
||||
|
||||
.h-20 {
|
||||
height: 5rem;
|
||||
}
|
||||
|
@ -653,20 +665,12 @@ video {
|
|||
height: 100vh;
|
||||
}
|
||||
|
||||
.h-16 {
|
||||
height: 4rem;
|
||||
}
|
||||
|
||||
.h-14 {
|
||||
height: 3.5rem;
|
||||
}
|
||||
|
||||
.w-11\/12 {
|
||||
width: 91.666667%;
|
||||
}
|
||||
|
||||
.w-20 {
|
||||
width: 5rem;
|
||||
.w-14 {
|
||||
width: 3.5rem;
|
||||
}
|
||||
|
||||
.w-24 {
|
||||
|
@ -693,18 +697,6 @@ video {
|
|||
width: 100vw;
|
||||
}
|
||||
|
||||
.w-16 {
|
||||
width: 4rem;
|
||||
}
|
||||
|
||||
.w-12 {
|
||||
width: 3rem;
|
||||
}
|
||||
|
||||
.w-14 {
|
||||
width: 3.5rem;
|
||||
}
|
||||
|
||||
.grow {
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
@ -856,6 +848,11 @@ video {
|
|||
padding-right: 1.5rem;
|
||||
}
|
||||
|
||||
.py-20 {
|
||||
padding-top: 5rem;
|
||||
padding-bottom: 5rem;
|
||||
}
|
||||
|
||||
.py-3 {
|
||||
padding-top: 0.75rem;
|
||||
padding-bottom: 0.75rem;
|
||||
|
@ -871,11 +868,6 @@ video {
|
|||
padding-bottom: 2rem;
|
||||
}
|
||||
|
||||
.py-20 {
|
||||
padding-top: 5rem;
|
||||
padding-bottom: 5rem;
|
||||
}
|
||||
|
||||
.pl-6 {
|
||||
padding-left: 1.5rem;
|
||||
}
|
||||
|
@ -903,11 +895,6 @@ video {
|
|||
line-height: 1.25rem;
|
||||
}
|
||||
|
||||
.text-xl {
|
||||
font-size: 1.25rem;
|
||||
line-height: 1.75rem;
|
||||
}
|
||||
|
||||
.font-bold {
|
||||
font-weight: 700;
|
||||
}
|
||||
|
|
|
@ -9,10 +9,14 @@
|
|||
rel="icon"
|
||||
type="image/png"
|
||||
sizes="32x32"
|
||||
href="./assets/images/favicon-32x32.png"
|
||||
th:href="'public/images/favicon-32x32.png'"
|
||||
href="../public/images/favicon-32x32.png"
|
||||
/>
|
||||
<link href="../public/out.css" rel="stylesheet" />
|
||||
|
||||
<link th:href="'public/out.css'" href="../public/out.css" rel="stylesheet" />
|
||||
<script
|
||||
th:src="'public/htmx.min.js'"
|
||||
src="../public/htmx.min.js"
|
||||
></script>
|
||||
<title>Frontend Mentor | Multi-step form</title>
|
||||
|
||||
<!-- Feel free to remove these styles or customise in your own stylesheet 👍 -->
|
||||
|
@ -28,6 +32,14 @@
|
|||
</head>
|
||||
<body>
|
||||
<main class="bg-light-gray h-screen w-screen">
|
||||
<section
|
||||
class="absolute top-0 end-0"
|
||||
>
|
||||
<button
|
||||
hx-get="/force-new-session"
|
||||
>Request new session</button>
|
||||
</section>
|
||||
<!-- here be immediate hx-get for the form. to subscitute the body -->
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -3,6 +3,8 @@ package multistepform
|
|||
import org.thymeleaf.templateresolver.ClassLoaderTemplateResolver
|
||||
import org.thymeleaf.TemplateEngine
|
||||
import org.thymeleaf.context.Context
|
||||
import cask.endpoints.ParamReader
|
||||
import java.util.UUID
|
||||
|
||||
case class Routes()(implicit cc: castor.Context, log: cask.Logger)
|
||||
extends cask.Routes {
|
||||
|
@ -14,13 +16,35 @@ case class Routes()(implicit cc: castor.Context, log: cask.Logger)
|
|||
val templateEngine = new TemplateEngine()
|
||||
templateEngine.setTemplateResolver(templateResolver)
|
||||
|
||||
val sessoinCookieName = "sessionId"
|
||||
|
||||
@cask.get("/")
|
||||
def getIndex() = {
|
||||
def getIndex(ctx: cask.Request) = {
|
||||
val sessionCookie = ctx.cookies.get(sessoinCookieName)
|
||||
lazy val newSessionCookies = sessionCookie match {
|
||||
case None => Seq(cask.Cookie(sessoinCookieName, UUID.randomUUID().toString(), path = "/"))
|
||||
case Some(_) => Seq.empty // don't set new cookies
|
||||
}
|
||||
|
||||
println(s"getting cookie $sessionCookie will set new? ${newSessionCookies}")
|
||||
|
||||
val context = new Context()
|
||||
val indexPage = templateEngine.process("index", context)
|
||||
cask.Response(
|
||||
indexPage,
|
||||
headers = Seq("Content-Type" -> "text/html;charset=UTF-8")
|
||||
headers = Seq("Content-Type" -> "text/html;charset=UTF-8"),
|
||||
cookies = newSessionCookies
|
||||
)
|
||||
}
|
||||
|
||||
@cask.get("/force-new-session")
|
||||
def forceNewSession() = {
|
||||
val newSessionCookie = cask.Cookie(sessoinCookieName, UUID.randomUUID().toString(), path = "/")
|
||||
println(s"setting new session ${newSessionCookie.value}")
|
||||
cask.Response(
|
||||
s"New session forced. Force new session",
|
||||
headers = Seq("Content-Type" -> "text/html;charset=UTF-8"),
|
||||
cookies = Seq(newSessionCookie)
|
||||
)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue