From 86daf5b0f3f743ed405c3c44943f53d0c7210d2e Mon Sep 17 00:00:00 2001 From: Christine Dodrill Date: Fri, 5 Feb 2016 21:12:20 -0800 Subject: [PATCH] full functionality --- src/quotesite.nim | 12 +++++++++++- src/templates/browse.mustache | 2 +- src/templates/channel.mustache | 5 +++++ src/templates/layout.mustache | 4 ++-- 4 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 src/templates/channel.mustache diff --git a/src/quotesite.nim b/src/quotesite.nim index ece1980..b51ba30 100644 --- a/src/quotesite.nim +++ b/src/quotesite.nim @@ -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 = """

hi!

""" @@ -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() diff --git a/src/templates/browse.mustache b/src/templates/browse.mustache index 5744505..144724a 100644 --- a/src/templates/browse.mustache +++ b/src/templates/browse.mustache @@ -1,6 +1,6 @@ {{# quotes }}
-

{{channel}} - #{{listid}} - {{time}}

+

{{channel}} - #{{listid}} - {{time}}

({{nick}}) {{message}}

Added by {{adder}}. permalink
diff --git a/src/templates/channel.mustache b/src/templates/channel.mustache new file mode 100644 index 0000000..c0b823a --- /dev/null +++ b/src/templates/channel.mustache @@ -0,0 +1,5 @@ + diff --git a/src/templates/layout.mustache b/src/templates/layout.mustache index 60fc0b4..858ae4b 100644 --- a/src/templates/layout.mustache +++ b/src/templates/layout.mustache @@ -2,11 +2,11 @@ quotes{{# title }} - {{ title }}{{/ title }}