Merge pull request '038' (#19) from ayushman into main

Reviewed-on: #19
This commit is contained in:
cereci5049 2024-08-10 22:42:34 +02:00
commit 0cb58ad991
4 changed files with 16 additions and 16 deletions

View file

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

View file

@ -11,7 +11,7 @@ proc signup*(ctx: Context): string=
var var
user1 = ctx.cookies.getOrDefault("user1", "none") user1 = ctx.cookies.getOrDefault("user1", "none")
user = to(parseJson(user1), User) user = to(parseJson(user1), User)
compileTemplateFile(getScriptDir() / "view" / "signup.nimja") compileTemplateFile(".." / "view" / "signup.nimja", baseDir = getScriptDir())
elif ctx.httpMethod == HttpPost: elif ctx.httpMethod == HttpPost:
var var
firstName = ctx.urlForm["fn"] firstName = ctx.urlForm["fn"]

View file

@ -19,55 +19,55 @@ import
user1 = ctx.cookies.getOrDefault("user1", """{"none": "none"}""") user1 = ctx.cookies.getOrDefault("user1", """{"none": "none"}""")
echo user1 echo user1
# var user = to(parseJson(user1), User) # var user = to(parseJson(user1), User)
compileTemplateFile(getScriptDir() / "view" / "index.nimja") compileTemplateFile("view" / "index.nimja", baseDir = getScriptDir())
"/shop" -> get: "/shop" -> get:
# var user = ctx.getUserFromCookie(ctx.cookies.getOrDefault("user", "")) # var user = ctx.getUserFromCookie(ctx.cookies.getOrDefault("user", ""))
# echo ctx.cookies.getOrDefault("user", "") # echo ctx.cookies.getOrDefault("user", "")
var var
user1 = ctx.cookies.getOrDefault("user1", "none") user1 = ctx.cookies.getOrDefault("user1", "none")
user = to(parseJson(user1), User) # user = to(parseJson(user1), User)
compileTemplateFile(getScriptDir() / "view" / "shop.nimja") compileTemplateFile("view" / "shop.nimja", baseDir = getScriptDir())
"/contact" -> get: "/contact" -> get:
var var
user1 = ctx.cookies.getOrDefault("user1", "none") user1 = ctx.cookies.getOrDefault("user1", "none")
user = to(parseJson(user1), User) # user = to(parseJson(user1), User)
compileTemplateFile(getScriptDir() / "view" / "contact.nimja") compileTemplateFile("view" / "contact.nimja", baseDir = getScriptDir())
"/cart" -> get: "/cart" -> get:
# var user = ctx.getUserFromCookie(ctx.cookies.getOrDefault("user", "")) # var user = ctx.getUserFromCookie(ctx.cookies.getOrDefault("user", ""))
var var
user1 = ctx.cookies.getOrDefault("user1", "none") user1 = ctx.cookies.getOrDefault("user1", "none")
user = to(parseJson(user1), User) # user = to(parseJson(user1), User)
compileTemplateFile(getScriptDir() / "view" / "cart.nimja") compileTemplateFile("view" / "cart.nimja", baseDir = getScriptDir())
"/checkout" -> get: "/checkout" -> get:
var var
user1 = ctx.cookies.getOrDefault("user1", "none") user1 = ctx.cookies.getOrDefault("user1", "none")
user = to(parseJson(user1), User) user = to(parseJson(user1), User)
compileTemplateFile(getScriptDir() / "view" / "checkout.nimja") compileTemplateFile("view" / "checkout.nimja", baseDir = getScriptDir())
"/shop/:id" -> get: "/shop/:id" -> get:
var var
prodId = capitalizeAscii(ctx.pathParams["id"]) prodId = capitalizeAscii(ctx.pathParams["id"])
user1 = ctx.cookies.getOrDefault("user1", "none") user1 = ctx.cookies.getOrDefault("user1", "none")
user = to(parseJson(user1), User) user = to(parseJson(user1), User)
compileTemplateFile(getScriptDir() / "view" / "shop-detail.nimja") compileTemplateFile("view" / "shop-detail.nimja", baseDir = getScriptDir())
"/testimonial" -> get: "/testimonial" -> get:
var var
user1 = ctx.cookies.getOrDefault("user1", "none") user1 = ctx.cookies.getOrDefault("user1", "none")
user = to(parseJson(user1), User) user = to(parseJson(user1), User)
compileTemplateFile(getScriptDir() / "view" / "testimonial.nimja") compileTemplateFile("view" / "testimonial.nimja", baseDir = getScriptDir())
"/signup" -> [get, post]: ctx.signup() # "/signup" -> [get, post]: ctx.signup()
"/login" -> get: "/login" -> get:
var var
user1 = ctx.cookies.getOrDefault("user1", "none") user1 = ctx.cookies.getOrDefault("user1", "none")
# user = to(parseJson(user1), User) # user = to(parseJson(user1), User)
compileTemplateFile(getScriptDir() / "view" / "login.nimja") compileTemplateFile("view" / "login.nimja", baseDir = getScriptDir())
"/htmx/login" -> post: "/htmx/login" -> post:
var var
form = ctx.urlForm form = ctx.urlForm
@ -137,7 +137,7 @@ import
var var
user1 = ctx.cookies.getOrDefault("user1", "none") user1 = ctx.cookies.getOrDefault("user1", "none")
user = to(parseJson(user1), User) user = to(parseJson(user1), User)
compileTemplateFile(getScriptDir() / "view" / "404.nimja") compileTemplateFile("view" / "404.nimja", baseDir = getScriptDir())
servePublic("src/public", "/static") servePublic("src/public", "/static")

View file

@ -1,4 +1,4 @@
{% extends "view/partials/_master.nimja" %} {% extends "../view/partials/_master.nimja" %}
{% block spheader1 %} Sign Up {% endblock %} {% block spheader1 %} Sign Up {% endblock %}
{% block spheader2 %} Sign Up {% endblock %} {% block spheader2 %} Sign Up {% endblock %}