Add top 20 quotes
This commit is contained in:
parent
aded75af95
commit
8b66e363b7
|
@ -162,6 +162,25 @@ routes:
|
||||||
redirect "/quotes/" & row[0]
|
redirect "/quotes/" & row[0]
|
||||||
except: fail()
|
except: fail()
|
||||||
|
|
||||||
|
get "/top":
|
||||||
|
try:
|
||||||
|
var
|
||||||
|
rows = db.getAllRows(sql"SELECT * from quotes where deleted=0 and votes > 0 order by votes desc LIMIT 20")
|
||||||
|
ctx = newContext()
|
||||||
|
quoteSeq = newSeq[Context]()
|
||||||
|
|
||||||
|
for row in items(rows):
|
||||||
|
var c = newContext()
|
||||||
|
c.contextQuote row[0].parseInt(), row
|
||||||
|
quoteSeq.add c
|
||||||
|
|
||||||
|
ctx["quotes"] = quoteSeq
|
||||||
|
|
||||||
|
renderMustache("top 20 quotes", browseTemplate, ctx)
|
||||||
|
|
||||||
|
except:
|
||||||
|
fail()
|
||||||
|
|
||||||
get "/@kind/@id":
|
get "/@kind/@id":
|
||||||
var
|
var
|
||||||
title: string = ""
|
title: string = ""
|
||||||
|
@ -183,7 +202,7 @@ routes:
|
||||||
of "quotes":
|
of "quotes":
|
||||||
rows = db.getAllRows(sql"SELECT * FROM quotes WHERE id = ?", qid)
|
rows = db.getAllRows(sql"SELECT * FROM quotes WHERE id = ?", qid)
|
||||||
|
|
||||||
title = "quote #" & $qid & " by " & rows[0][2]
|
title = "#" & $qid & " by " & rows[0][2]
|
||||||
else:
|
else:
|
||||||
if (@"kind").startsWith "hashtag-":
|
if (@"kind").startsWith "hashtag-":
|
||||||
let channel = (@"kind").replace("hashtag-", "#")
|
let channel = (@"kind").replace("hashtag-", "#")
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
<div class=metanav>
|
<div class=metanav>
|
||||||
<a href="/">home</a>
|
<a href="/">home</a>
|
||||||
<a href="/channel">channel</a>
|
<a href="/channel">channel</a>
|
||||||
|
<a href="/top">top</a>
|
||||||
<a href="/submit">submit</a>
|
<a href="/submit">submit</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue