From 66cf70220337a6523710864e26be362fb976943e Mon Sep 17 00:00:00 2001 From: fr33domlover Date: Sat, 21 May 2016 21:27:12 +0000 Subject: [PATCH] Add "new topic" link to discussion widget --- src/Vervis/Handler/Discussion.hs | 6 ++++-- src/Vervis/Handler/Ticket.hs | 6 ++++++ src/Vervis/Widget/Discussion.hs | 8 ++++---- templates/discussion/widget/tree.hamlet | 20 ++++++++++++++++++++ templates/ticket/one.hamlet | 2 +- 5 files changed, 35 insertions(+), 7 deletions(-) create mode 100644 templates/discussion/widget/tree.hamlet diff --git a/src/Vervis/Handler/Discussion.hs b/src/Vervis/Handler/Discussion.hs index 50d17c3..2227019 100644 --- a/src/Vervis/Handler/Discussion.hs +++ b/src/Vervis/Handler/Discussion.hs @@ -42,8 +42,10 @@ import Vervis.Model import Vervis.Settings (widgetFile) import Vervis.Widget.Discussion -getDiscussion :: (Int -> Route App) -> AppDB DiscussionId -> Handler Html -getDiscussion reply getdid = defaultLayout $ discussionW getdid reply +getDiscussion + :: (Int -> Route App) -> Route App -> AppDB DiscussionId -> Handler Html +getDiscussion reply topic getdid = + defaultLayout $ discussionW getdid topic reply getMessage :: (Int -> Route App) -> AppDB DiscussionId -> Int -> Handler Html getMessage reply getdid num = do diff --git a/src/Vervis/Handler/Ticket.hs b/src/Vervis/Handler/Ticket.hs index 76f12f7..281fb02 100644 --- a/src/Vervis/Handler/Ticket.hs +++ b/src/Vervis/Handler/Ticket.hs @@ -139,6 +139,11 @@ getTicketR shar proj num = do else return author return (author, closer, ticket) let desc = renderSourceT Markdown $ T.filter (/= '\r') $ ticketDesc ticket + discuss = + discussionW + (return $ ticketDiscuss ticket) + (TicketTopReplyR shar proj num) + (TicketReplyR shar proj num) defaultLayout $(widgetFile "ticket/one") putTicketR :: Text -> Text -> Int -> Handler Html @@ -196,6 +201,7 @@ getTicketDiscussionR :: Text -> Text -> Int -> Handler Html getTicketDiscussionR shar proj num = getDiscussion (TicketReplyR shar proj num) + (TicketTopReplyR shar proj num) (selectDiscussionId shar proj num) postTicketDiscussionR :: Text -> Text -> Int -> Handler Html diff --git a/src/Vervis/Widget/Discussion.hs b/src/Vervis/Widget/Discussion.hs index 7538f93..08db0c3 100644 --- a/src/Vervis/Widget/Discussion.hs +++ b/src/Vervis/Widget/Discussion.hs @@ -69,10 +69,10 @@ messageTreeW reply cReplies now t = go t ^{go tree} |] -discussionW :: AppDB DiscussionId -> (Int -> Route App) -> Widget -discussionW getdid reply = do +discussionW :: AppDB DiscussionId -> Route App -> (Int -> Route App) -> Widget +discussionW getdid topic reply = do forest <- handlerToWidget $ getDiscussionTree getdid cReplies <- newIdent now <- liftIO getCurrentTime - toWidget $(cassiusFile "templates/discussion/widget/tree.cassius") - traverse_ (messageTreeW reply cReplies now) forest + let msgTree = messageTreeW reply cReplies now + $(widgetFile "discussion/widget/tree") diff --git a/templates/discussion/widget/tree.hamlet b/templates/discussion/widget/tree.hamlet new file mode 100644 index 0000000..ee6ac9d --- /dev/null +++ b/templates/discussion/widget/tree.hamlet @@ -0,0 +1,20 @@ +$# This file is part of Vervis. +$# +$# Written in 2016 by fr33domlover . +$# +$# ♡ Copying is an act of love. Please copy, reuse and share. +$# +$# The author(s) have dedicated all copyright and related and neighboring +$# rights to this software to the public domain worldwide. This software is +$# distributed without any warranty. +$# +$# You should have received a copy of the CC0 Public Domain Dedication along +$# with this software. If not, see +$# . + +
+ new topic + +
+ $forall tree <- forest + ^{msgTree tree} diff --git a/templates/ticket/one.hamlet b/templates/ticket/one.hamlet index 109f8b0..76c39f5 100644 --- a/templates/ticket/one.hamlet +++ b/templates/ticket/one.hamlet @@ -37,4 +37,4 @@ $# .

Discussion -^{discussionW (return $ ticketDiscuss ticket) (TicketReplyR shar proj num)} +^{discuss}