about summary refs log tree commit diff
path: root/services/tazblog
diff options
context:
space:
mode:
Diffstat (limited to 'services/tazblog')
-rw-r--r--services/tazblog/src/Blog.hs12
-rw-r--r--services/tazblog/src/RSS.hs14
-rw-r--r--services/tazblog/src/Server.hs6
-rw-r--r--services/tazblog/tazblog.cabal3
-rw-r--r--services/tazblog/tazblog.nix4
5 files changed, 18 insertions, 21 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)
diff --git a/services/tazblog/tazblog.cabal b/services/tazblog/tazblog.cabal
index 0db2f990c7b8..fc6b32a10085 100644
--- a/services/tazblog/tazblog.cabal
+++ b/services/tazblog/tazblog.cabal
@@ -13,7 +13,8 @@ library
   default-language: Haskell2010
   ghc-options: -W
   exposed-modules: Blog, BlogStore, Locales, Server, RSS
-  build-depends: base,
+  build-depends: aeson,
+                 base,
                  bytestring,
                  happstack-server,
                  text,
diff --git a/services/tazblog/tazblog.nix b/services/tazblog/tazblog.nix
index 0c2618bc018b..a29450ddc0ce 100644
--- a/services/tazblog/tazblog.nix
+++ b/services/tazblog/tazblog.nix
@@ -1,4 +1,4 @@
-{ mkDerivation, acid-state, base, base64-bytestring, blaze-html
+{ mkDerivation, aeson, acid-state, base, base64-bytestring, blaze-html
 , blaze-markup, bytestring, cache, crypto-api, cryptohash, dns, hamlet
 , happstack-server, markdown, mtl, network, network-uri
 , old-locale, options, rss, shakespeare, stdenv, text
@@ -11,7 +11,7 @@ mkDerivation {
   isLibrary = true;
   isExecutable = true;
   libraryHaskellDepends = [
-    base base64-bytestring blaze-html blaze-markup bytestring
+    aeson base base64-bytestring blaze-html blaze-markup bytestring
     cache crypto-api cryptohash dns hamlet happstack-server markdown mtl
     network network-uri old-locale rss shakespeare text time
     transformers