Add random quote viewing
This commit is contained in:
parent
8b66e363b7
commit
be1dd411ee
|
@ -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
|
||||
|
|
|
@ -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>
|
||||
|
||||
|
|
Loading…
Reference in New Issue