{-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TemplateHaskell #-} module Blog where import BlogDB import Control.Monad (unless, when) import Data.Data (Data, Typeable) import Data.List (intersperse) import Data.Maybe (fromJust) import Data.Monoid (mempty) import Data.Text (Text, append, empty, pack) import Data.Text.Lazy (fromStrict) import Data.Time import Locales import System.Locale (defaultTimeLocale) import Text.Blaze.Html (preEscapedToHtml) import Text.Hamlet import Text.Lucius import Text.Markdown import qualified Data.Text as T -- custom list functions intersperse' :: a -> [a] -> [a] intersperse' sep l = sep : intersperse sep l replace :: Eq a => a -> a -> [a] -> [a] replace x y = map (\z -> if z == x then y else z) show' :: Show a => a -> Text show' = pack . show -- |After this time all entries are Markdown markdownCutoff :: UTCTime markdownCutoff = fromJust $ parseTime defaultTimeLocale "%s" "1367149834" -- blog CSS (admin is still static) stylesheetSource = $(luciusFile "res/blog.lucius") blogStyle = renderCssUrl undefined stylesheetSource -- blog HTML blogTemplate :: BlogLang -> Text -> Html -> Html blogTemplate lang t_append body = [shamlet| $doctype 5