From ac32fa394ff582a3acbce5c48e3ecb3544cc1a36 Mon Sep 17 00:00:00 2001 From: Quad Date: Mon, 11 Apr 2022 09:03:53 +0200 Subject: [PATCH] Switch to somewhat more conventional view/route split --- src/modules/blog.nim | 8 +++----- src/modules/{templating.nim => views.nim} | 6 +++++- 2 files changed, 8 insertions(+), 6 deletions(-) rename src/modules/{templating.nim => views.nim} (55%) diff --git a/src/modules/blog.nim b/src/modules/blog.nim index 073fa21..fa1ee03 100644 --- a/src/modules/blog.nim +++ b/src/modules/blog.nim @@ -1,19 +1,17 @@ import prologue import prologue/middlewares/staticfile -import templating - -proc getIndex*(ctx: Context) {.async.} = - resp renderTemplate(templateName="index.nwt") +import views proc runWebsite(settings: Table) = let prologueSettings = newSettings( debug = settings["debug"] ) + var website = newApp(settings = prologueSettings) website.get("/", getIndex) - website.use(staticFileMiddleware("static")) + website.run() export runWebsite diff --git a/src/modules/templating.nim b/src/modules/views.nim similarity index 55% rename from src/modules/templating.nim rename to src/modules/views.nim index f40b403..5324e32 100644 --- a/src/modules/templating.nim +++ b/src/modules/views.nim @@ -1,6 +1,10 @@ +import prologue import nimja/parser proc renderTemplate(templateName: static[string]): string = compileTemplateFile(getScriptDir() & "/templates/" & templateName) -export renderTemplate +proc getIndex*(ctx: Context) {.async.} = + resp renderTemplate(templateName="index.nwt") + +export getIndex