about summary refs log tree commit diff
path: root/src/Blog.hs
diff options
context:
space:
mode:
authorVincent Ambo <viam@humac.com>2012-03-03T15·39+0100
committerVincent Ambo <viam@humac.com>2012-03-03T15·39+0100
commit96093c9009554cd63431022635fccf54e47438e2 (patch)
treeab73bc04716645ac52068336d4f45c470e600707 /src/Blog.hs
parent485e27147574106d5925ea9ab880739d8e1c4f6e (diff)
* Pagination (finally!)
* slight CSS change
Diffstat (limited to 'src/Blog.hs')
-rw-r--r--src/Blog.hs25
1 files changed, 19 insertions, 6 deletions
diff --git a/src/Blog.hs b/src/Blog.hs
index 7b39fe5c9928..575ec04fcf8a 100644
--- a/src/Blog.hs
+++ b/src/Blog.hs
@@ -72,12 +72,15 @@ blogTemplate lang t_append body = H.docTypeHtml $ do --add body
             H.a ! A.href (toValue imu) ! A.target "_blank" $ "iMessage"
             "."
 
-renderEntries :: [Entry] -> String-> Html
-renderEntries entries topText = H.div ! A.class_ "innerBox" $ do
-    H.div ! A.class_ "innerBoxTop" $ toHtml topText
-    H.div ! A.class_ "innerBoxMiddle" $ do
-        H.ul $ 
-            sequence_ . reverse $ map showEntry entries
+renderEntries :: Bool -> [Entry] -> String -> Maybe Html -> Html
+renderEntries showAll entries topText footerLinks = 
+    H.div ! A.class_ "innerBox" $ do
+        H.div ! A.class_ "innerBoxTop" $ toHtml topText
+        H.div ! A.class_ "innerBoxMiddle" $ do
+            H.ul $ if' showAll
+                (sequence_ $ map showEntry entries)
+                (sequence_ . take 6 $ map showEntry entries)
+            getFooterLinks footerLinks
     where
         showEntry :: Entry -> Html
         showEntry e = H.li $ do 
@@ -86,6 +89,8 @@ renderEntries entries topText = H.div ! A.class_ "innerBox" $ do
         entryLink e = H.a ! A.href (toValue $ concat $ intersperse' "/" $ linkElems e) $
                         toHtml ("[" ++ show(length $ comments e) ++ "]")
         linkElems e = [show(lang e), show(year e), show(month e), show(day e), _id e]
+        getFooterLinks (Just h) = h
+        getFooterLinks Nothing = mempty
 
 renderEntry :: Entry -> Html
 renderEntry entry = H.div ! A.class_ "innerBox" $ do
@@ -114,6 +119,14 @@ renderComments comments lang = sequence_ $ map showComment comments
         showTime _ Nothing = "[???]" -- this can not happen??
         timeString = (showTime lang) . getTime
 
+showLinks :: Maybe Int -> BlogLang -> Html
+showLinks (Just i) lang = H.div ! A.class_ "centerbox" $ do
+    H.a ! A.href (toValue $ "/?page=" ++ show (i+1)) $ toHtml $ backText lang
+    toHtml (" -- " :: String)
+    H.a ! A.href (toValue $ "/?page=" ++ show (i-1)) $ toHtml $ nextText lang
+showLinks Nothing lang = H.div ! A.class_ "centerbox" $
+    H.a ! A.href "/?page=2" $ toHtml $  backText lang
+
 showFooter :: BlogLang -> String -> Html
 showFooter l v = H.div ! A.class_ "rightbox" ! A.style "text-align:right;" $ do
     toHtml ("Proudly made with " :: String)