This commit is contained in:
Hubert Van De Walle 2020-08-22 04:50:11 +02:00
parent 39fe7a5ab6
commit bad5322abd
4 changed files with 15 additions and 5 deletions

View File

@ -7,7 +7,10 @@ import kotlinx.html.div
import org.intellij.lang.annotations.Language
class BaseView(staticFileResolver: StaticFileResolver) : View(staticFileResolver) {
fun renderHome(jwtPayload: JwtPayload?) = renderPage(title = "Home", jwtPayload = jwtPayload) {
fun renderHome(jwtPayload: JwtPayload?) = renderPage(
title = "Home",
description = "A fast and simple note taking website",
jwtPayload = jwtPayload) {
section("text-center my-2 p-2") {
h1("text-5xl") {
span("text-teal-300") { +"Simplenotes " }

View File

@ -17,7 +17,6 @@ class NoteView(staticFileResolver: StaticFileResolver) : View(staticFileResolver
validationErrors: List<ValidationError> = emptyList(),
) = renderPage(title = "New note", jwtPayload = jwtPayload) {
div("container mx-auto p-4") {
// TODO: error
error?.let { alert(Alert.Warning, error) }
validationErrors.forEach {
alert(Alert.Warning, it.dataPath.substringAfter('.') + ": " + it.message)

View File

@ -15,7 +15,13 @@ class UserView(staticFileResolver: StaticFileResolver) : View(staticFileResolver
jwtPayload: JwtPayload?,
error: String? = null,
validationErrors: List<ValidationError> = emptyList(),
) = accountForm("Register", jwtPayload, error, validationErrors, "Create an account", "Register") {
) = accountForm("Register",
"Registration page",
jwtPayload,
error,
validationErrors,
"Create an account",
"Register") {
+"Already have an account? "
a(href = "/login", classes = "no-underline text-blue-500 font-bold") { +"Sign In" }
}
@ -25,13 +31,14 @@ class UserView(staticFileResolver: StaticFileResolver) : View(staticFileResolver
error: String? = null,
validationErrors: List<ValidationError> = emptyList(),
new: Boolean = false,
) = accountForm("Login", jwtPayload, error, validationErrors, "Sign In", "Sign In", new) {
) = accountForm("Login", "Login page", jwtPayload, error, validationErrors, "Sign In", "Sign In", new) {
+"Don't have an account yet? "
a(href = "/register", classes = "no-underline text-blue-500 font-bold") { +"Create an account" }
}
private fun accountForm(
title: String,
description: String,
jwtPayload: JwtPayload?,
error: String? = null,
validationErrors: List<ValidationError> = emptyList(),
@ -39,7 +46,7 @@ class UserView(staticFileResolver: StaticFileResolver) : View(staticFileResolver
submit: String,
new: Boolean = false,
footer: FlowContent.() -> Unit,
) = renderPage(title = title, jwtPayload = jwtPayload) {
) = renderPage(title = title, description, jwtPayload = jwtPayload) {
div("centered container mx-auto flex justify-center items-center") {
div("w-full md:w-1/2 lg:w-1/3 m-4") {
h1("font-semibold text-lg mb-6 text-center") { +h1 }

View File

@ -1,2 +1,3 @@
User-agent: *
Allow: /$
Disallow: /