diff --git a/Handler/AdminComments.hs b/Handler/AdminComments.hs index 69a0b38..af32475 100644 --- a/Handler/AdminComments.hs +++ b/Handler/AdminComments.hs @@ -18,7 +18,6 @@ module Handler.AdminComments where import Import import Handler.Commons -import Data.Maybe import Data.Time -- import System.Locale diff --git a/Handler/Medium.hs b/Handler/Medium.hs index 4fa3bde..43eafac 100644 --- a/Handler/Medium.hs +++ b/Handler/Medium.hs @@ -47,7 +47,7 @@ getMediumR mediumId = do Nothing -> return Nothing let presence = userId == (Just ownerId) || userId == Just (albumOwner album) - (commentWidget, enctype) <- generateFormPost $ commentForm userId userSl mediumId Nothing + (commentWidget, enctype) <- generateFormPost $ commentForm (fromJust userId) (fromJust userSl) mediumId Nothing comments <- runDB $ selectList [ CommentOrigin ==. mediumId , CommentParent ==. Nothing ] @@ -76,18 +76,18 @@ postMediumR mediumId = do Just tempUserId -> do let userId = getUserIdFromText tempUserId u <- runDB $ getJust userId - let userSl = Just $ userSlug u - ((res, _), _) <- runFormPost $ commentForm (Just userId) userSl mediumId Nothing + let userSl = userSlug u + ((res, _), _) <- runFormPost $ commentForm userId userSl mediumId Nothing case res of FormSuccess temp -> do _ <- runDB $ insert temp --send mail to medium owner owner <- runDB $ getJust $ mediumOwner medium link <- ($ MediumR (commentOrigin temp)) <$> getUrlRender - sendMail (userEmail owner) ((fromJust $ commentAuthorSlug temp) `T.append` " commented on your medium") + sendMail (userEmail owner) ((commentAuthorSlug temp) `T.append` " commented on your medium") [shamlet|

Hello #{userSlug owner} -

#{fromJust $ commentAuthorSlug temp} commented on your medium: +

#{commentAuthorSlug temp} commented on your medium:

#{commentContent temp}

To follow the comment thread follow @@ -106,7 +106,7 @@ postMediumR mediumId = do setMessage "This image does not exist" redirect HomeR -commentForm :: Maybe UserId -> Maybe Text -> MediumId -> Maybe CommentId -> Form Comment +commentForm :: UserId -> Text -> MediumId -> Maybe CommentId -> Form Comment commentForm authorId authorSlug originId parentId = renderDivs $ Comment <$> pure authorId <*> pure authorSlug @@ -125,9 +125,9 @@ getCommentReplyR commentId = do Just tempUserId -> do let userId = getUserIdFromText tempUserId u <- runDB $ getJust userId - let userSl = Just $ userSlug u + let userSl = userSlug u let mediumId = commentOrigin comment - (replyWidget, enctype) <- generateFormPost $ commentForm (Just userId) userSl mediumId (Just commentId) + (replyWidget, enctype) <- generateFormPost $ commentForm userId userSl mediumId (Just commentId) formLayout $ do setTitle "Eidolon :: Reply to comment" $(widgetFile "commentReply") @@ -148,20 +148,20 @@ postCommentReplyR commentId = do Just tempUserId -> do let userId = getUserIdFromText tempUserId u <- runDB $ getJust userId - let userSl = Just $ userSlug u + let userSl = userSlug u let mediumId = commentOrigin comment - ((res, _), _) <- runFormPost $ commentForm (Just userId) userSl mediumId (Just commentId) + ((res, _), _) <- runFormPost $ commentForm userId userSl mediumId (Just commentId) case res of FormSuccess temp -> do _ <- runDB $ insert temp --send mail to parent author parent <- runDB $ getJust $ fromJust $ commentParent temp - parAuth <- runDB $ getJust $ fromJust $ commentAuthor parent + parAuth <- runDB $ getJust $ commentAuthor parent link <- ($ MediumR (commentOrigin temp)) <$> getUrlRender - sendMail (userEmail parAuth) ((fromJust $ commentAuthorSlug temp) `T.append` " replied to your comment") + sendMail (userEmail parAuth) ((commentAuthorSlug temp) `T.append` " replied to your comment") [shamlet|

Hello #{userSlug parAuth} -

#{fromJust $ commentAuthorSlug temp} replied to your comment: +

#{commentAuthorSlug temp} replied to your comment: #{commentContent temp}

To see the comment thread follow @@ -171,10 +171,10 @@ postCommentReplyR commentId = do --send mail to medium owner medium <- runDB $ getJust mediumId owner <- runDB $ getJust $ mediumOwner medium - sendMail (userEmail owner) ((fromJust $ commentAuthorSlug temp) `T.append` " commented on your medium") + sendMail (userEmail owner) ((commentAuthorSlug temp) `T.append` " commented on your medium") [shamlet|

Hello #{userSlug owner} -

#{fromJust $ commentAuthorSlug temp} commented your medium with: +

#{commentAuthorSlug temp} commented your medium with: #{commentContent temp}

To see the comment thread follow @@ -203,7 +203,7 @@ getCommentDeleteR commentId = do Just tempUserId -> do let userId = getUserIdFromText tempUserId if - Just userId == commentAuthor comment + Just userId == Just (commentAuthor comment) then do formLayout $ do setTitle "Eidolon :: Delete comment" @@ -228,7 +228,7 @@ postCommentDeleteR commentId = do Just tempUserId -> do let userId = getUserIdFromText tempUserId if - Just userId == commentAuthor comment + Just userId == Just (commentAuthor comment) then do confirm <- lookupPostParam "confirm" case confirm of diff --git a/config/models b/config/models index 4403479..fb17f80 100644 --- a/config/models +++ b/config/models @@ -55,8 +55,8 @@ Medium album AlbumId deriving Eq Show Comment - author UserId Maybe - authorSlug Text Maybe + author UserId + authorSlug Text origin MediumId parent CommentId Maybe time UTCTime diff --git a/templates/adminComments.hamlet b/templates/adminComments.hamlet index 5c33b7e..65d9618 100644 --- a/templates/adminComments.hamlet +++ b/templates/adminComments.hamlet @@ -16,7 +16,7 @@ $else $forall (Entity commentId comment) <- comments $if commentOrigin comment == mediumId

- #{fromJust $ commentAuthorSlug comment} wrote on #{formatTime defaultTimeLocale "%A %F %H:%M" $ commentTime comment}: + #{commentAuthorSlug comment} wrote on #{formatTime defaultTimeLocale "%A %F %H:%M" $ commentTime comment}:
#{commentContent comment}
Delete this comment @@ -24,7 +24,7 @@ $else $if commentParent reply == Just commentId $if commentOrigin reply == mediumId
- #{fromJust $ commentAuthorSlug comment} wrote on #{formatTime defaultTimeLocale "%A %F %H:%M" $ commentTime comment}: + #{commentAuthorSlug comment} wrote on #{formatTime defaultTimeLocale "%A %F %H:%M" $ commentTime comment}:
#{commentContent reply}
Delete this comment diff --git a/templates/commentReply.hamlet b/templates/commentReply.hamlet index 24bbf8d..0e09820 100644 --- a/templates/commentReply.hamlet +++ b/templates/commentReply.hamlet @@ -1,7 +1,7 @@