diff --git a/hh1.nimble b/hh1.nimble index 012df6a..7e5e6d3 100644 --- a/hh1.nimble +++ b/hh1.nimble @@ -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" \ No newline at end of file +# requires "https://github.com/ire4ever1190/mike >= 1.3.3" +# requires "nimja" +# requires "https://codeberg.org/13thab/turso-nim" \ No newline at end of file diff --git a/src/controller/htmx.nim b/src/controller/htmx.nim new file mode 100644 index 0000000..50ffb21 --- /dev/null +++ b/src/controller/htmx.nim @@ -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) \ No newline at end of file diff --git a/src/hh1.nim b/src/hh1.nim index 3e30719..8024c03 100644 --- a/src/hh1.nim +++ b/src/hh1.nim @@ -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 diff --git a/src/model/rand.nim b/src/model/rand.nim index 98db4ed..f3e112e 100644 --- a/src/model/rand.nim +++ b/src/model/rand.nim @@ -2,4 +2,5 @@ type Validity* = object name*: string message*: string - mark*: string \ No newline at end of file + mark*: string + \ No newline at end of file