Add random quote viewing

This commit is contained in:
Christine Dodrill 2016-02-06 00:50:30 -08:00
parent 8b66e363b7
commit be1dd411ee
2 changed files with 18 additions and 0 deletions

View File

@ -162,6 +162,23 @@ routes:
redirect "/quotes/" & row[0]
except: fail()
get "/random":
try:
var
rows = db.getAllRows(sql"SELECT * from quotes where deleted=0 order by random() 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("random 20 quotes", browseTemplate, ctx)
except: fail()
get "/top":
try:
var

View File

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