Fixes problems with utf8. Profile pages now show thread count.
This commit is contained in:
parent
4e0e5c44f6
commit
2c8fbaf889
2 changed files with 17 additions and 5 deletions
21
forum.nim
21
forum.nim
|
|
@ -577,18 +577,24 @@ proc gatherUserInfo(c: var TForumData, nick: string, ui: var TUserInfo): bool =
|
||||||
if uid == "": return false
|
if uid == "": return false
|
||||||
result = true
|
result = true
|
||||||
const totalPostsQuery =
|
const totalPostsQuery =
|
||||||
sql"select count(*) from post p, person u where u.id = ?"
|
sql"SELECT count(*) FROM post WHERE author = ?"
|
||||||
ui.posts = getValue(db, totalPostsQuery, uid).parseInt
|
ui.posts = getValue(db, totalPostsQuery, uid).parseInt
|
||||||
ui.threads = 0
|
const totalThreadsQuery =
|
||||||
|
sql("select count(*) from thread where id in (select thread from post where" &
|
||||||
|
" author = ? and post.id in (select min(id) from post group by thread))")
|
||||||
|
|
||||||
|
ui.threads = getValue(db, totalThreadsQuery, uid).parseInt
|
||||||
const lastOnlineQuery =
|
const lastOnlineQuery =
|
||||||
sql"select strftime('%s', lastOnline) from person where id = ?"
|
sql"select strftime('%s', lastOnline) from person where id = ?"
|
||||||
ui.lastOnline = getValue(db, lastOnlineQuery, uid).parseInt
|
let lastOnlineDBVal = getValue(db, lastOnlineQuery, uid)
|
||||||
|
ui.lastOnline = if lastOnlineDBVal != "": lastOnlineDBVal.parseInt else: -1
|
||||||
ui.email = getValue(db, sql"select email from person where id = ?", uid)
|
ui.email = getValue(db, sql"select email from person where id = ?", uid)
|
||||||
|
|
||||||
proc genProfile(c: var TForumData, ui: TUserInfo): string =
|
proc genProfile(c: var TForumData, ui: TUserInfo): string =
|
||||||
result = ""
|
result = ""
|
||||||
result.add(htmlgen.`div`(id = "avatar", genGravatar(ui.email, 250)))
|
result.add(htmlgen.`div`(id = "avatar", genGravatar(ui.email, 250)))
|
||||||
let t2 = getGMTime(TTime(ui.lastOnline))
|
let t2 = if ui.lastOnline != -1: getGMTime(TTime(ui.lastOnline))
|
||||||
|
else: getGMTime(GetTime())
|
||||||
|
|
||||||
result.add(htmlgen.`div`(id = "info",
|
result.add(htmlgen.`div`(id = "info",
|
||||||
table(
|
table(
|
||||||
|
|
@ -596,13 +602,18 @@ proc genProfile(c: var TForumData, ui: TUserInfo): string =
|
||||||
th("Nickname"),
|
th("Nickname"),
|
||||||
td(ui.nick)
|
td(ui.nick)
|
||||||
),
|
),
|
||||||
|
tr(
|
||||||
|
th("Threads"),
|
||||||
|
td($ui.threads)
|
||||||
|
),
|
||||||
tr(
|
tr(
|
||||||
th("Posts"),
|
th("Posts"),
|
||||||
td($ui.posts)
|
td($ui.posts)
|
||||||
),
|
),
|
||||||
tr(
|
tr(
|
||||||
th("Last Online"),
|
th("Last Online"),
|
||||||
td(t2.format("dd/MM/yy HH':'mm 'UTC'"))
|
td(if ui.lastOnline != -1: t2.format("dd/MM/yy HH':'mm 'UTC'")
|
||||||
|
else: "Never")
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
))
|
))
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@
|
||||||
<title>Nimrod Forum</title>
|
<title>Nimrod Forum</title>
|
||||||
<link rel="stylesheet" href="${c.req.makeUri("css/normalize.css", absolute = false)}">
|
<link rel="stylesheet" href="${c.req.makeUri("css/normalize.css", absolute = false)}">
|
||||||
<link rel="stylesheet" href="${c.req.makeUri("css/style.css", absolute = false)}">
|
<link rel="stylesheet" href="${c.req.makeUri("css/style.css", absolute = false)}">
|
||||||
|
<meta charset="UTF-8">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="wrapper">
|
<div id="wrapper">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue