diff --git a/src/quotesite.nim b/src/quotesite.nim index 54e8d85..f3d54e8 100644 --- a/src/quotesite.nim +++ b/src/quotesite.nim @@ -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 diff --git a/src/templates/layout.mustache b/src/templates/layout.mustache index 688341f..670d4de 100644 --- a/src/templates/layout.mustache +++ b/src/templates/layout.mustache @@ -8,6 +8,7 @@ home channel top + random submit