diff options
author | "Vincent Ambo ext:(%22) <tazjin@me.com> | 2012-02-23T13·46+0100 |
---|---|---|
committer | "Vincent Ambo ext:(%22) <tazjin@me.com> | 2012-02-23T13·46+0100 |
commit | d04d693eb9047d0ce10ae1244f4de1678d0d117a (patch) | |
tree | d9b536f0423ab2439af6da84d0e002b59be1eeea /src | |
parent | a4119e1cfd3f599cf67012535a5a55bcbf4800c6 (diff) |
* comment parsing
Diffstat (limited to 'src')
-rw-r--r-- | src/Blog.hs | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/src/Blog.hs b/src/Blog.hs index bb74cbb16bef..1caa021d545a 100644 --- a/src/Blog.hs +++ b/src/Blog.hs @@ -5,6 +5,8 @@ module Blog where --import Control.Monad(when) import Data.Data (Data, Typeable) import Data.Monoid (mempty) +import Data.Time +import System.Locale (defaultTimeLocale) import Text.Blaze (toValue, preEscapedString) import Text.Blaze.Html5 (Html, (!), a, form, input, p, toHtml, label) import Text.Blaze.Html5.Attributes (action, enctype, href, name, size, type_, value) @@ -80,13 +82,28 @@ renderEntry entry = H.div ! A.class_ "innerBox" $ do preEscapedString $ text entry preEscapedString $ mtext entry H.div ! A.class_ "innerBoxComments" $ do - H.div ! A.name "cHead" ! A.style "font-size:large;font-weight:bold;" $ toHtml cHead - H.ul $ H.li $ toHtml noC + H.div ! A.name "cHead" ! A.style "font-size:large;font-weight:bold;" $ toHtml $ cHead (lang entry) + H.ul $ renderComments (comments entry) (lang entry) where - getTexts :: BlogLang -> (String, String) - getTexts EN = ("Comments:", " No comments yet") - getTexts DE = ("Kommentare:", " Keine Kommentare") - (cHead,noC) = getTexts (lang entry) + cHead EN = ("Comments:" :: String) + cHead DE = ("Kommentare:" :: String) + +renderComments :: [Comment] -> BlogLang -> Html +renderComments [] DE = H.li $ toHtml (" Keine Kommentare" :: String) +renderComments [] EN = H.li $ toHtml (" No comments yet" :: String) +renderComments comments _ = sequence_ $ map showComment comments + where + showComment :: Comment -> Html + showComment c = H.li $ do + H.a ! A.name (toValue $ cdate c) ! A.href (toValue $ "#" ++ show c) $ + H.i $ toHtml $ (cauthor c ++ ": ") + preEscapedString $ ctext c + getTime :: Integer -> Maybe UTCTime + getTime = parseTime defaultTimeLocale "%s" (show ) + showTime (Just t) = formatTime defaultTimeLocale "[Am %d.%m.%y um %H:%M Uhr]" t + showTime Nothing = "???" -- this can not happen?? + +--[Am %d.%m.%y um %H:%M Uhr] emptyTest :: BlogLang -> Html emptyTest lang = H.div ! A.class_ "innerBox" $ do |