Add top 20 quotes

This commit is contained in:
Christine Dodrill 2016-02-06 00:45:37 -08:00
parent aded75af95
commit 8b66e363b7
2 changed files with 21 additions and 1 deletions

View File

@ -162,6 +162,25 @@ routes:
redirect "/quotes/" & row[0]
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":
var
title: string = ""
@ -183,7 +202,7 @@ routes:
of "quotes":
rows = db.getAllRows(sql"SELECT * FROM quotes WHERE id = ?", qid)
title = "quote #" & $qid & " by " & rows[0][2]
title = "#" & $qid & " by " & rows[0][2]
else:
if (@"kind").startsWith "hashtag-":
let channel = (@"kind").replace("hashtag-", "#")

View File

@ -7,6 +7,7 @@
<div class=metanav>
<a href="/">home</a>
<a href="/channel">channel</a>
<a href="/top">top</a>
<a href="/submit">submit</a>
</div>