full functionality

This commit is contained in:
Christine Dodrill 2016-02-05 21:12:20 -08:00
parent cbf18df53d
commit 86daf5b0f3
4 changed files with 19 additions and 4 deletions

View File

@ -5,6 +5,7 @@ const
baseTemplate*: string = staticRead "./templates/layout.mustache"
browseTemplate*: string = staticRead "./templates/browse.mustache"
errorTemplate*: string = staticRead "./templates/error.mustache"
channelTemplate*: string = staticRead "./templates/channel.mustache"
testTemplate*: string = """<p>hi!</p>"""
@ -80,8 +81,17 @@ routes:
var
channels = db.getAllRows(sql"select channel from quotes group by channel")
ctx: Context = newContext()
channelList = newSeq[Context]()
renderMustache("channel list", testTemplate, ctx)
for row in channels.items():
var c = newContext()
c["name"] = row[0]
c["safe"] = row[0].replace("#", "hashtag-")
channelList.add c
ctx["channels"] = channelList
renderMustache("channel list", channelTemplate, ctx)
except:
fail()

View File

@ -1,6 +1,6 @@
{{# quotes }}
<div class="entries">
<h3><a href="/{{ channelsafe }}">{{channel}}</a> - #{{listid}} - {{time}}</h3>
<h3><a href="/{{ channelsafe }}/0">{{channel}}</a> - #{{listid}} - {{time}}</h3>
<p>({{nick}}) {{message}}</p>
<small><i>Added by {{adder}}. <a href="/quotes/{{id}}">permalink</a></i></small>
<br />

View File

@ -0,0 +1,5 @@
<ul>
{{# channels }}
<li><a href="/{{ safe }}/0">{{ name }}</li>
{{/ channels }}
</ul>

View File

@ -2,11 +2,11 @@
<title>quotes{{# title }} - {{ title }}{{/ title }}</title>
<link rel=stylesheet type=text/css href="/style.css">
<div class=page>
<h1>{{# title }}{{ title }}{{/ title }}</h1>
<h1>quotes - {{# title }}{{ title }}{{/ title }}</h1>
<div class=metanav>
<a href="/">home</a>
<a href="/channel">channel</a>
<a href="/submit">submit</a>
<!-- <a href="/submit">submit</a> -->
</div>
{{{ body }}}
</div>