diff options
author | Vincent Ambo <tazjin@google.com> | 2019-08-22T17·58+0100 |
---|---|---|
committer | Vincent Ambo <tazjin@google.com> | 2019-08-22T17·58+0100 |
commit | bd47122afb7d3da60ff61f6ca74994a133cc7a0c (patch) | |
tree | 2ffc76c71d79da5511521793faa193bcd4fd2168 /services/tazblog/src | |
parent | c5ef3e01b27b220d6b8c2b16584e752c69966e3d (diff) |
chore(blog): Minor changes to integrate DNS based backend r/51
Diffstat (limited to 'services/tazblog/src')
-rw-r--r-- | services/tazblog/src/Blog.hs | 12 | ||||
-rw-r--r-- | services/tazblog/src/RSS.hs | 14 | ||||
-rw-r--r-- | services/tazblog/src/Server.hs | 6 |
3 files changed, 14 insertions, 18 deletions
diff --git a/services/tazblog/src/Blog.hs b/services/tazblog/src/Blog.hs index b5d83a57699a..d02836a3f3ac 100644 --- a/services/tazblog/src/Blog.hs +++ b/services/tazblog/src/Blog.hs @@ -12,7 +12,6 @@ module Blog where import BlogStore -import Data.Maybe (fromJust) import Data.Text (Text, empty, pack) import Data.Text.Lazy (fromStrict) import Data.Time @@ -26,12 +25,9 @@ import qualified Data.Text as T 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 $ parseTimeM False defaultTimeLocale "%s" "1367149834" +-- |After this date all entries are Markdown +markdownCutoff :: Day +markdownCutoff = fromGregorian 2013 04 28 -- blog HTML blogTemplate :: BlogLang -> Text -> Html -> Html @@ -99,7 +95,7 @@ $maybe links <- pageLinks where linkElems Entry{..} = concat $ ["/", show lang, "/", show entryId] -showLinks :: Maybe Integer -> BlogLang -> Html +showLinks :: Maybe Int -> BlogLang -> Html showLinks (Just i) lang = [shamlet| $if ((>) i 1) <div .navigation> diff --git a/services/tazblog/src/RSS.hs b/services/tazblog/src/RSS.hs index 5d2340d5292f..02a2aafda969 100644 --- a/services/tazblog/src/RSS.hs +++ b/services/tazblog/src/RSS.hs @@ -5,7 +5,7 @@ import qualified Data.Text as T import Control.Monad (liftM) import Data.Maybe (fromMaybe) -import Data.Time (UTCTime, getCurrentTime) +import Data.Time (UTCTime(..), getCurrentTime, secondsToDiffTime) import Network.URI import Text.RSS @@ -13,11 +13,11 @@ import BlogStore import Locales createChannel :: BlogLang -> UTCTime -> [ChannelElem] -createChannel l now = [ Language $ show l - , Copyright "Vincent Ambo" - , WebMaster "tazjin@gmail.com" - , ChannelPubDate now - ] +createChannel l now = [ Language $ show l + , Copyright "Vincent Ambo" + , WebMaster "tazjin@gmail.com" + , ChannelPubDate now + ] createRSS :: BlogLang -> UTCTime -> [Item] -> RSS createRSS l t = RSS (rssTitle l) (rssLink l) (rssDesc l) (createChannel l t) @@ -26,7 +26,7 @@ createItem :: Entry -> Item createItem Entry{..} = [ Title $ T.unpack title , Link $ makeLink lang entryId , Description $ T.unpack btext - , PubDate edate] + , PubDate $ UTCTime edate $ secondsToDiffTime 0 ] makeLink :: BlogLang -> EntryId -> URI makeLink l i = let url = "http://tazj.in/" ++ show l ++ "/" ++ show i diff --git a/services/tazblog/src/Server.hs b/services/tazblog/src/Server.hs index 4be76052beeb..8a7384ccca3e 100644 --- a/services/tazblog/src/Server.hs +++ b/services/tazblog/src/Server.hs @@ -21,7 +21,7 @@ instance FromReqURI BlogLang where "en" -> Just EN _ -> Nothing -pageSize :: Integer +pageSize :: Int pageSize = 3 tmpPolicy :: BodyPolicy @@ -68,12 +68,12 @@ tryEntry (Just entry) _ = ok $ toResponse $ blogTemplate eLang eTitle $ renderEn eTitle = T.append ": " (title entry) eLang = lang entry -offset :: Maybe Integer -> Integer +offset :: Maybe Int -> Int offset = maybe 0 ((*) pageSize) showIndex :: BlogCache -> BlogLang -> ServerPart Response showIndex cache lang = do - (page :: Maybe Integer) <- optional $ lookRead "page" + (page :: Maybe Int) <- optional $ lookRead "page" entries <- listEntries cache (offset page) pageSize ok $ toResponse $ blogTemplate lang "" $ renderEntries entries (Just $ showLinks page lang) |