Some adjustments to genFormPost
This commit is contained in:
parent
645ad91a0c
commit
5b20a0ca2d
2 changed files with 11 additions and 11 deletions
|
|
@ -115,12 +115,11 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
#proc genFormPost(c: var TForumData, action: string,
|
#proc genFormPost(c: var TForumData, action: string,
|
||||||
# topText, title, content: string): string =
|
# topText, title, content: string, isEdit: bool): string =
|
||||||
# result = ""
|
# result = ""
|
||||||
<br />
|
<br />
|
||||||
<a name="reply"></a>
|
<a name="reply"></a>
|
||||||
<div id="replywrapper">
|
<div id="replywrapper">
|
||||||
# let isEdit = topText == "Edit"
|
|
||||||
<div id="replytop">
|
<div id="replytop">
|
||||||
<span>${topText}</span>
|
<span>${topText}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
19
forum.nim
19
forum.nim
|
|
@ -433,7 +433,8 @@ proc getStats(c: var TForumData): TForumStats =
|
||||||
const getUsersQuery =
|
const getUsersQuery =
|
||||||
sql"select id, name, admin, strftime('%s', lastOnline), strftime('%s', creation) from person"
|
sql"select id, name, admin, strftime('%s', lastOnline), strftime('%s', creation) from person"
|
||||||
for row in fastRows(db, getUsersQuery):
|
for row in fastRows(db, getUsersQuery):
|
||||||
let lastOnlineSeconds = getTime() - TTime(row[3].parseInt)
|
let secs = if row[3] == "": 0 else: row[3].parseint
|
||||||
|
let lastOnlineSeconds = getTime() - TTime(secs)
|
||||||
if lastOnlineSeconds < (60 * 5): # 5 minutes
|
if lastOnlineSeconds < (60 * 5): # 5 minutes
|
||||||
result.activeUsers.add((row[1], row[0].parseInt, row[2].parseBool))
|
result.activeUsers.add((row[1], row[0].parseInt, row[2].parseBool))
|
||||||
if row[4].parseInt > newestMemberCreation:
|
if row[4].parseInt > newestMemberCreation:
|
||||||
|
|
@ -475,14 +476,14 @@ get "/t/@threadid/?":
|
||||||
$c.threadId).prependRe
|
$c.threadId).prependRe
|
||||||
body = genPostsList(c, $c.threadId)
|
body = genPostsList(c, $c.threadId)
|
||||||
echo(c.threadId)
|
echo(c.threadId)
|
||||||
body.add genFormPost(c, "doreply", "Reply", subject, "")
|
body.add genFormPost(c, "doreply", "Reply", subject, "", false)
|
||||||
of "edit":
|
of "edit":
|
||||||
cond c.postId != -1
|
cond c.postId != -1
|
||||||
const query = sql"select header, content from post where id = ?"
|
const query = sql"select header, content from post where id = ?"
|
||||||
let row = getRow(db, query, $c.postId)
|
let row = getRow(db, query, $c.postId)
|
||||||
let header = ||row[0]
|
let header = ||row[0]
|
||||||
let content = ||row[1]
|
let content = ||row[1]
|
||||||
body = genFormPost(c, "doedit", "Edit", header, content)
|
body = genFormPost(c, "doedit", "Edit", header, content, true)
|
||||||
resp c.genMain(body)
|
resp c.genMain(body)
|
||||||
else:
|
else:
|
||||||
cond validThreadId(c)
|
cond validThreadId(c)
|
||||||
|
|
@ -513,11 +514,11 @@ template finishLogin(): stmt =
|
||||||
setCookie("sid", c.userpass, daysForward(7))
|
setCookie("sid", c.userpass, daysForward(7))
|
||||||
redirect(uri("/"))
|
redirect(uri("/"))
|
||||||
|
|
||||||
template handleError(action: string, topText: string): stmt =
|
template handleError(action: string, topText: string, isEdit: bool): stmt =
|
||||||
if c.isPreview:
|
if c.isPreview:
|
||||||
body.add genPostPreview(c, @"subject", @"content",
|
body.add genPostPreview(c, @"subject", @"content",
|
||||||
c.userName, $getGMTime(getTime()))
|
c.userName, $getGMTime(getTime()))
|
||||||
body.add genFormPost(c, action, topText, reuseText, reuseText)
|
body.add genFormPost(c, action, topText, reuseText, reuseText, isEdit)
|
||||||
resp genMain(c, body)
|
resp genMain(c, body)
|
||||||
|
|
||||||
post "/dologin":
|
post "/dologin":
|
||||||
|
|
@ -541,7 +542,7 @@ post "/donewthread":
|
||||||
redirect(uri("/"))
|
redirect(uri("/"))
|
||||||
else:
|
else:
|
||||||
body = ""
|
body = ""
|
||||||
handleError("donewthread", "New thread")
|
handleError("donewthread", "New thread", false)
|
||||||
|
|
||||||
post "/doreply":
|
post "/doreply":
|
||||||
createTFD()
|
createTFD()
|
||||||
|
|
@ -550,7 +551,7 @@ post "/doreply":
|
||||||
redirect(c.genThreadUrl())
|
redirect(c.genThreadUrl())
|
||||||
else:
|
else:
|
||||||
body = genPostsList(c, $c.threadId)
|
body = genPostsList(c, $c.threadId)
|
||||||
handleError("doreply", "Reply")
|
handleError("doreply", "Reply", false)
|
||||||
|
|
||||||
post "/doedit":
|
post "/doedit":
|
||||||
createTFD()
|
createTFD()
|
||||||
|
|
@ -559,11 +560,11 @@ post "/doedit":
|
||||||
redirect(c.genThreadUrl())
|
redirect(c.genThreadUrl())
|
||||||
else:
|
else:
|
||||||
body = ""
|
body = ""
|
||||||
handleError("doedit", "Edit")
|
handleError("doedit", "Edit", true)
|
||||||
|
|
||||||
get "/newthread/?":
|
get "/newthread/?":
|
||||||
createTFD()
|
createTFD()
|
||||||
resp genMain(c, genFormPost(c, "donewthread", "New thread", "", ""))
|
resp genMain(c, genFormPost(c, "donewthread", "New thread", "", "", false))
|
||||||
|
|
||||||
when isMainModule:
|
when isMainModule:
|
||||||
docConfig = rstgen.defaultConfig()
|
docConfig = rstgen.defaultConfig()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue