From 961a3fc0e9f367f75ae891c63db04915a92ebb87 Mon Sep 17 00:00:00 2001 From: dom96 Date: Thu, 17 May 2012 01:21:59 +0100 Subject: [PATCH] Fixes for Urls. --- captchas.nim | 6 +++--- forms.tmpl | 10 +++++----- forum.nim | 8 ++++---- main.tmpl | 10 +++++----- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/captchas.nim b/captchas.nim index 839ed96..0d56022 100644 --- a/captchas.nim +++ b/captchas.nim @@ -6,13 +6,13 @@ # All rights reserved. # -import cairo, os, strutils +import cairo, os, strutils, jester proc getCaptchaFilename*(i: int): string {.inline.} = result = "public/captchas/capture_" & $i & ".png" -proc getCaptchaUrl*(i: int): string = - result = "/captchas/capture_" & $i & ".png" +proc getCaptchaUrl*(req: var TRequest, i: int): string = + result = req.makeUri("/captchas/capture_" & $i & ".png", absolute = false) proc createCaptcha*(file, text: string) = var surface = imageSurfaceCreate(FORMAT_ARGB32, 10*text.len, 10) diff --git a/forms.tmpl b/forms.tmpl index f8a5430..039b435 100644 --- a/forms.tmpl +++ b/forms.tmpl @@ -123,7 +123,7 @@
${topText}
-
+ ${FieldValid(c, "subject", "Subject:")} ${TextWidget(c, "subject", title, maxlength=100)}
@@ -146,7 +146,7 @@ # #proc genFormRegister(c: var TForumData): string = # result = "" - + Register
@@ -173,7 +173,7 @@ #proc genFormLogin(c: var TForumData): string = # result = "" # if not c.loggedIn: - +
@@ -202,11 +202,11 @@ # if usr.isAdmin: #if index != 0: result.add ',' #end if - ${usr.nick} + #result.add(""" """ & usr.nick & """""") # else: #if index != 0: result.add ',' #end if - ${usr.nick} + #result.add(""" """ & usr.nick & """""") # end if #end for diff --git a/forum.nim b/forum.nim index a4728b8..1055b43 100644 --- a/forum.nim +++ b/forum.nim @@ -13,7 +13,6 @@ import const unselectedThread = -1 transientThread = 0 - websiteLoc = "" type TCrud = enum crCreate, crRead, crUpdate, crDelete @@ -185,7 +184,7 @@ proc antibot(c: var TForumData): string = answer).int mod 10_000 let CaptchaFile = getCaptchaFilename(CaptchaId) createCaptcha(CaptchaFile, $a & "+" & $b) - result = """""" % getCaptchaUrl(captchaId) + result = """""" % c.req.getCaptchaUrl(captchaId) const SecureChars = {'A'..'Z', 'a'..'z', '0'..'9', '_', '\128'..'\255'} @@ -407,7 +406,8 @@ proc login(c: var TForumData, name, pass: string): bool = proc genActionMenu(c: var TForumData): string = result = "" var btns: seq[TStyledButton] = @[] - if c.req.pathInfo != "/": + # TODO: Make this detection better? + if c.req.pathInfo notin ["/", "/login", "/register", "/dologin", "/doregister"]: btns.add(("Thread List", c.req.makeUri("/", false))) if c.loggedIn: let hasReplyBtn = c.req.pathInfo != "/donewthread" and c.req.pathInfo != "/doreply" @@ -575,6 +575,6 @@ when isMainModule: if paramCount() > 0: if paramStr(1) == "scgi": http = false - run(websiteLoc, port = TPort(9000), http = http) + run("", port = TPort(9000), http = http) db.close() diff --git a/main.tmpl b/main.tmpl index 70a20fc..964f1a0 100644 --- a/main.tmpl +++ b/main.tmpl @@ -5,8 +5,8 @@ Nimrod Forum - - + +
@@ -18,12 +18,12 @@ #let frontQuery = c.req.makeUri("/") Nimrod's Forum #if c.loggedIn: - Logout + Logout $c.username ${genGravatar(c.email, 26)} #else: - Register - Login + Register + Login #end if
Username: