feat: serve static content, use template for index

This commit is contained in:
efim 2023-07-24 17:59:44 +00:00
parent 4517f5a1ae
commit a8cbdeada0
9 changed files with 71 additions and 20 deletions

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 423 B

After

Width:  |  Height:  |  Size: 423 B

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 509 B

After

Width:  |  Height:  |  Size: 509 B

View File

Before

Width:  |  Height:  |  Size: 552 B

After

Width:  |  Height:  |  Size: 552 B

View File

@ -546,6 +546,18 @@ video {
width: 100vw; width: 100vw;
} }
.flex-auto {
flex: 1 1 auto;
}
.flex-1 {
flex: 1 1 0%;
}
.grow {
flex-grow: 1;
}
.flex-row { .flex-row {
flex-direction: row; flex-direction: row;
} }
@ -574,6 +586,10 @@ video {
border-width: 4px; border-width: 4px;
} }
.border {
border-width: 1px;
}
.border-b-8 { .border-b-8 {
border-bottom-width: 8px; border-bottom-width: 8px;
} }
@ -583,6 +599,11 @@ video {
border-color: rgb(96 165 250 / var(--tw-border-opacity)); border-color: rgb(96 165 250 / var(--tw-border-opacity));
} }
.border-black {
--tw-border-opacity: 1;
border-color: rgb(0 0 0 / var(--tw-border-opacity));
}
.bg-blue-100 { .bg-blue-100 {
--tw-bg-opacity: 1; --tw-bg-opacity: 1;
background-color: rgb(219 234 254 / var(--tw-bg-opacity)); background-color: rgb(219 234 254 / var(--tw-bg-opacity));
@ -597,6 +618,10 @@ video {
padding: 8rem; padding: 8rem;
} }
.text-end {
text-align: end;
}
.text-2xl { .text-2xl {
font-size: 1.5rem; font-size: 1.5rem;
line-height: 2rem; line-height: 2rem;

View File

@ -6,7 +6,7 @@
<title>Auth page</title> <title>Auth page</title>
<meta name="description" content="" /> <meta name="description" content="" />
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="../out.css" type="text/css" /> <link rel="stylesheet" href="../public/out.css" type="text/css" />
<link rel="apple-touch-icon" href="/apple-touch-icon.png" /> <link rel="apple-touch-icon" href="/apple-touch-icon.png" />
<!-- Place favicon.ico in the root directory --> <!-- Place favicon.ico in the root directory -->
@ -26,19 +26,19 @@
class="text-2xl text-blue-400 font-bold" class="text-2xl text-blue-400 font-bold"
>Authorizatoin options</h2> >Authorizatoin options</h2>
<div class="flex flex-row justify-center gap-2"> <div class="flex flex-row justify-center gap-2">
<img src="../icons/github-svgrepo-com(1).svg" alt="log in via github" <img src="../public/icons/github-svgrepo-com(1).svg" alt="log in via github"
class="w-10 h-10" class="w-10 h-10"
/> />
<img src="../icons/apple-svgrepo-com.svg" alt="log in via github" <img src="../public/icons/apple-svgrepo-com.svg" alt="log in via github"
class="w-10 h-10" class="w-10 h-10"
/> />
<img src="../icons/google-svgrepo-com.svg" alt="log in via github" <img src="../public/icons/google-svgrepo-com.svg" alt="log in via github"
class="w-10 h-10" class="w-10 h-10"
/> />
<img src="../icons/facebook-f-svgrepo-com.svg" alt="log in via github" <img src="../public/icons/facebook-f-svgrepo-com.svg" alt="log in via github"
class="w-10 h-10" class="w-10 h-10"
/> />
<img src="../icons/gitlab-svgrepo-com(1).svg" alt="log in via github" <img src="../public/icons/gitlab-svgrepo-com(1).svg" alt="log in via github"
class="w-10 h-10" class="w-10 h-10"
/> />
</div> </div>

View File

@ -7,7 +7,12 @@
<meta name="description" content="" /> <meta name="description" content="" />
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="../out.css" type="text/css" /> <link
rel="stylesheet"
th:href="'public/out.css'"
href="../public/out.css"
type="text/css"
/>
<link rel="apple-touch-icon" href="/apple-touch-icon.png" /> <link rel="apple-touch-icon" href="/apple-touch-icon.png" />
<!-- Place favicon.ico in the root directory --> <!-- Place favicon.ico in the root directory -->
</head> </head>
@ -20,12 +25,32 @@
</p> </p>
<![endif]--> <![endif]-->
<main class="bg-blue-100 h-screen w-screen grid place-content-center"> <main class="bg-blue-100 h-screen w-screen grid place-content-center">
<section> <section>
<h1 <h1 class="text-2xl text-blue-600 font-bold tracking-wide uppercase">
class="text-2xl text-blue-600 font-bold tracking-wide uppercase" Auth successful, yay
>Auth successful, yay</h1> </h1>
<p>Here be some info</p> <p>Here be some info</p>
</section> <ul>
<li class="flex flex-row">
username:
<span class="flex-1 text-end" th:text="${userRecord.username}"
>some_username</span
>
</li>
<li class="flex flex-row">
email:
<span class="flex-1 text-end" th:text="${userRecord.email}"
>some_email</span
>
</li>
<li class="flex flex-row">
created:
<span class="flex-1 text-end" th:text="${userRecord.created}"
>some_date</span
>
</li>
</ul>
</section>
</main> </main>
</body> </body>
</html> </html>

View File

@ -35,13 +35,12 @@ case class AuthService()(implicit cc: castor.Context, log: cask.Logger)
val refreshedSession = pocketbaseApi.refreshSession(jwt) val refreshedSession = pocketbaseApi.refreshSession(jwt)
refreshedSession match { refreshedSession match {
case Right(freshAuth) => case Right(freshAuth) =>
val indexHtml = s""" val context = new PageContext()
<h1>Ok, good</h1> context.setVariable("userRecord", freshAuth.record)
<p>user should be already created, current jwt : ${freshAuth.token}</p>
<p>the account is on ${freshAuth.record.email} and ${freshAuth.record.username}</p> val indexPage = templateEngine.process("index", context)
"""
cask.Response( cask.Response(
indexHtml, indexPage,
headers = Seq("Content-Type" -> "text/html;charset=UTF-8"), headers = Seq("Content-Type" -> "text/html;charset=UTF-8"),
cookies = cookies =
Seq(cask.Cookie(name = authCookieName, value = freshAuth.token)) Seq(cask.Cookie(name = authCookieName, value = freshAuth.token))
@ -167,10 +166,12 @@ case class AuthService()(implicit cc: castor.Context, log: cask.Logger)
) )
) )
} }
okMessageFirst okMessageFirst
} }
@cask.staticResources("/public")
def servePublicResources() = "public"
initialize() initialize()
} }