2017-06-29 15:08:27 +00:00
|
|
|
{-# LANGUAGE NoImplicitPrelude #-}
|
|
|
|
{-# LANGUAGE OverloadedStrings #-}
|
|
|
|
{-# LANGUAGE TemplateHaskell #-}
|
|
|
|
{-# LANGUAGE MultiParamTypeClasses #-}
|
|
|
|
{-# LANGUAGE TypeFamilies #-}
|
|
|
|
{-# LANGUAGE ScopedTypeVariables #-}
|
|
|
|
module Handler.Timeline where
|
|
|
|
|
|
|
|
import Import
|
|
|
|
|
2017-06-29 15:23:52 +00:00
|
|
|
-- TODO: Bearbeiten Sie die Aufgaben im Widget-Template "timeline"
|
2017-06-29 15:08:27 +00:00
|
|
|
getTimelineR :: Handler Html
|
|
|
|
getTimelineR = do
|
|
|
|
(uid, user) <- requireAuthPair
|
|
|
|
posts <- runDB $ selectList [PostUserId ==. uid] [Desc PostCreated]
|
|
|
|
(postWidget, postEnctype) <- generateFormPost (postForm Nothing uid)
|
|
|
|
let userName :: Text
|
|
|
|
userName = userIdent user
|
|
|
|
defaultLayout $ do
|
|
|
|
setTitle . toHtml $ userName <> "'s Timeline"
|
|
|
|
$(widgetFile "timeline")
|
|
|
|
|
|
|
|
-- TODO: Implementieren Sie ein Verhalten zum Speichern des Posts.
|
|
|
|
-- Nützliche Funktionen: runFormPost.
|
|
|
|
postTimelineR :: Handler Html
|
|
|
|
postTimelineR = do
|
|
|
|
getTimelineR
|
|
|
|
|
|
|
|
|
|
|
|
postForm :: Maybe PostId -> UserId -> Form Post
|
|
|
|
postForm p u = renderDivs $ Post
|
|
|
|
<$> pure u
|
|
|
|
<*> areq textField "Post" (Just "Post content")
|
|
|
|
<*> pure p
|
|
|
|
<*> lift (liftIO getCurrentTime)
|