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 }}
-

{{# title }}{{ title }}{{/ title }}

+

quotes - {{# title }}{{ title }}{{/ title }}

{{{ body }}}