[multi page support Jeremy Shaw **20091107201858 Ignore-this: ac5944c32ac7b2f921f5ad7f24794c5d ] hunk ./State.hs 154 -getThreadsDB :: Int -> BoardName -> Query State (Either InvalidBoard [Thread]) +getThreadsDB :: Int -> BoardName -> Query State (Either InvalidBoard ([Thread], Int)) hunk ./State.hs 160 - let threads' = take 10 $ drop (pageNum * 10) $ sortBy (flip compare `on` (postId . last . posts)) (IxSet.toList ((threads state) @= (boardId board))) - in return (Right threads') + let threads' = sortBy (flip compare `on` (postId . last . posts)) (IxSet.toList ((threads state) @= (boardId board))) + pageThreads = take 10 $ drop (pageNum * 10) $ threads' + maxPageNum = (max ((length threads')-1) 0) `div` 10 + in return (Right (pageThreads, maxPageNum)) hunk ./State.hs 232 -getThreads :: (MonadIO m) => BoardName -> Int -> m (Either InvalidBoard [Thread]) +getThreads :: (MonadIO m) => BoardName -> Int -> m (Either InvalidBoard ([Thread], Int)) hunk ./State.hs 313 - type ReturnType GetThreads = (Either InvalidBoard [Thread]) + type ReturnType GetThreads = (Either InvalidBoard ([Thread], Int)) hunk ./Web.hs 13 -import Data.List (intercalate) +import Data.List (intersperse) hunk ./Web.hs 153 - (Right threads) -> toResponse <$> (unXMLGenT $ boardTemplate config here (Right boardName) (Text.unpack (unBoardName boardName)) () <% mapM threadHTML threads %>) + (Right (threads, maxPageNum)) -> + do + toResponse <$> (unXMLGenT $ boardTemplate config here (Right (boardName, maxPageNum)) (Text.unpack (unBoardName boardName)) () <% mapM threadHTML threads %>) hunk ./Web.hs 200 -

<% maybe "Anonymous" Text.unpack (poster post) %> <% maybe "" Text.unpack (subject post) %> <% formatTime defaultTimeLocale rfc822DateFormat (epochMilliToUTCTime (posted post)) %> No.<% show $ unPostId $ postId post %> []

+

<% maybe "Anonymous" Text.unpack (poster post) %> <% maybe "" Text.unpack (subject post) %> <% formatTime defaultTimeLocale rfc822DateFormat (epochMilliToUTCTime (posted post)) %> No.<% show $ unPostId $ postId post %>

hunk ./Web.hs 259 - -> (Either ThreadId BoardName) + -> (Either ThreadId (BoardName, Int)) hunk ./Web.hs 273 + <% pageNavigator %> hunk ./Web.hs 276 - intercal :: a -> [a] -> [a] - intercal e [] = [] - intercal e (h:t) = h : e : (intercal e t) hunk ./Web.hs 278 - [ <% intercal (pcdata " / ") $ links %> ] + [ <% intersperse (pcdata " / ") $ links %> ] hunk ./Web.hs 286 - (Right boardName) -> - do let board = fromJust $ IxSet.getOne (bds @= boardName) -

/<% Text.unpack $ abbrev board %>/ - <% Text.unpack $ name board %>

+ (Right (boardName, _)) -> + case IxSet.getOne (bds @= boardName) of + Nothing ->

<% Text.unpack (unBoardName boardName) %>

+ (Just board) ->

/<% Text.unpack $ abbrev board %>/ - <% Text.unpack $ name board %>

+ pageNavigator = + case postType of + (Left _) -> return (pcdata "") + (Right (boardName, maxPageNum)) -> + do pageURLs <- mapM (\n -> showURL (W_Board boardName (Just n))) [0..maxPageNum] + + hunk ./Web.hs 299 - (Right boardName) -> + (Right (boardName, _)) ->