Commits

Luke Plant committed 6a02304

Made category post index view work like normal post index view

  • Participants
  • Parent commits 6287976

Comments (0)

Files changed (2)

src/Blog/Templates.hs

               -> Html
 mainIndexPage postInfo curpage moreposts =
     page $ defaultPageVars
-             { pcontent = formatIndex postInfo curpage moreposts
+             { pcontent = formatIndex "Recent posts" indexUrl postInfo curpage moreposts
              , ptitle = ""
              }
 
-formatIndex :: [(P.Post, [C.Category])] -> Int -> Bool -> Html
-formatIndex postInfo curpage shownext =
-    (h1 << "Recent posts")
+formatIndex :: String -> String -> [(P.Post, [C.Category])] -> Int -> Bool -> Html
+formatIndex title url postInfo curpage shownext =
+    (h1 << title)
     +++
     (do (post, cats) <- postInfo
         return (
                  << (primHtml $ P.summary_formatted post))
                )
     ) +++ (
-           pagingLinks indexUrl curpage shownext
+           pagingLinks url curpage shownext
           )
 
 categoriesPage :: [C.Category] -> Html
     (thediv ! [theclass "category"]
      << categoryLink cat)
 
-categoryPage :: C.Category -> [P.Post] -> Int -> Bool -> Html
+categoryPage :: C.Category -> [(P.Post, [C.Category])] -> Int -> Bool -> Html
 categoryPage cat posts curpage moreposts =
     page $ defaultPageVars
-         { pcontent = formatCategoryIndex cat posts curpage moreposts
+         { pcontent = formatIndex ("Category: " ++ C.name cat) (categoryUrl cat) posts curpage moreposts
          , ptitle = C.name cat
          }
 
-formatCategoryIndex cat posts curpage moreposts = 
-    (h1 << ("Category: " ++ C.name cat))
-    +++
-    (do post <- posts
-        return (
-                (thediv ! [ theclass "summarylink" ]
-                 << postLink post)
-                +++
-                (thediv ! [ theclass "summary" ]
-                 << (primHtml $ P.summary_formatted post))
-               )
-    ) +++ (
-           pagingLinks (categoryUrl cat) curpage moreposts
-          )
-
-
 postPage :: P.Post        -- ^ The Post to display
          -> CommentStage  -- ^ What stage comment submission is at
          -> Cm.Comment    -- ^ Data for the comment form

src/Blog/Views.hs

     Nothing -> return $ Just $ custom404
     Just cat -> do
               (posts,more) <- getPostsForCategory cn cat (getPage req)
-              return $ Just $ standardResponse $ categoryPage cat posts curpage more
+              cats <- getCategoriesBulk cn posts
+              return $ Just $ standardResponse $ categoryPage cat (zip posts cats) curpage more
 
 -- | View that shows individual post
 postView :: String -> View