Merge pull request 'harsh' (#24) from harsh into main

Reviewed-on: #24
This commit is contained in:
cereci5049 2024-08-15 18:54:53 +02:00
commit cc08aa8080
4 changed files with 37 additions and 28 deletions

View file

@ -12,6 +12,6 @@ bin = @["hh1"]
# Dependencies
requires "nim >= 2.0.8"
requires "https://github.com/ire4ever1190/mike >= 1.3.3"
requires "nimja"
requires "https://codeberg.org/13thab/turso-nim"
# requires "https://github.com/ire4ever1190/mike >= 1.3.3"
# requires "nimja"
# requires "https://codeberg.org/13thab/turso-nim"

28
src/controller/htmx.nim Normal file
View file

@ -0,0 +1,28 @@
import
mike,
../model/rand,
../lib/htmx
proc htmxEmail*(ctx:Context)=
var
em = ctx.urlForm["email"]
val: Validity
if em == "":
val.message = "Last Name is Required"
val.mark = "is-invalid"
else:
val.message = ""
val.mark = ""
ctx.send htmxEmail(em, val)
proc htmxPassword*(ctx:Context)=
var
pw = ctx.urlForm["password"]
val: Validity
if pw == "":
val.message = "Last Name is Required"
val.mark = "is-invalid"
else:
val.message = ""
val.mark = ""
ctx.send htmxPassword(pw, val)

View file

@ -1,5 +1,5 @@
import
mike,
mike,
nimja,
strutils,
json,
@ -9,7 +9,7 @@ import
./lib/[mics, htmx],
./db/users,
./model/[model, rand],
./controller/[signup, login]
./controller/[signup, login, htmx]
load()
@ -71,29 +71,9 @@ load()
"/htmx/login" -> post: ctx.htmxLogin()
"/htmx/email" -> post:
var
em = ctx.urlForm["email"]
val: Validity
if em == "":
val.message = "Last Name is Required"
val.mark = "is-invalid"
else:
val.message = ""
val.mark = ""
ctx.send htmxEmail(em, val)
"/htmx/email" -> post: htmxEmail(ctx)
"/htmx/password" -> post:
var
pw = ctx.urlForm["password"]
val: Validity
if pw == "":
val.message = "Last Name is Required"
val.mark = "is-invalid"
else:
val.message = ""
val.mark = ""
ctx.send htmxPassword(pw, val)
"/htmx/password" -> post: htmxPassword(ctx)
"/:path" -> get:
var

View file

@ -2,4 +2,5 @@ type
Validity* = object
name*: string
message*: string
mark*: string
mark*: string