packages feed

yesod-paginate 0.0 → 0.1

raw patch · 2 files changed

+15/−14 lines, 2 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

- Yesod.Paginate: instance Yesod master => YesodSubSite (Paginate master a) master
+ Yesod.Paginate: instance (Yesod master, HasReps rep) => YesodSubSite (Paginate master rep a) master
- Yesod.Paginate: Paginate :: Int -> (Int -> Int -> GHandler (Paginate master a) master [a]) -> GHandler (Paginate master a) master Int -> (Int -> Int -> [a] -> GHandler (Paginate master a) master RepHtml) -> Paginate master a
+ Yesod.Paginate: Paginate :: Int -> (Int -> Int -> GHandler (Paginate master rep a) master [a]) -> GHandler (Paginate master rep a) master Int -> (Int -> Int -> [a] -> GHandler (Paginate master rep a) master rep) -> Paginate master rep a
- Yesod.Paginate: data Paginate master a
+ Yesod.Paginate: data Paginate master rep a
- Yesod.Paginate: defaultPaginate :: (YesodPersist master, PersistBackend (YesodDB master (GHandler (Paginate master a) master)), PersistEntity a) => Int -> [Filter a] -> [Order a] -> (Int -> Int -> [a] -> GHandler (Paginate master a) master RepHtml) -> Paginate master a
+ Yesod.Paginate: defaultPaginate :: (YesodPersist master, PersistBackend (YesodDB master (GHandler (Paginate master rep a) master)), PersistEntity a) => Int -> [Filter a] -> [Order a] -> (Int -> Int -> [a] -> GHandler (Paginate master rep a) master rep) -> Paginate master rep a
- Yesod.Paginate: nextLink :: Paginate master a -> Int -> Int -> GHandler (Paginate master a) master (Maybe (Route (Paginate master a)))
+ Yesod.Paginate: nextLink :: Paginate master rep a -> Int -> Int -> GHandler (Paginate master rep a) master (Maybe (Route (Paginate master rep a)))
- Yesod.Paginate: pgnDefaultCount :: Paginate master a -> Int
+ Yesod.Paginate: pgnDefaultCount :: Paginate master rep a -> Int
- Yesod.Paginate: pgnDisplayItems :: Paginate master a -> Int -> Int -> [a] -> GHandler (Paginate master a) master RepHtml
+ Yesod.Paginate: pgnDisplayItems :: Paginate master rep a -> Int -> Int -> [a] -> GHandler (Paginate master rep a) master rep
- Yesod.Paginate: pgnGetItems :: Paginate master a -> Int -> Int -> GHandler (Paginate master a) master [a]
+ Yesod.Paginate: pgnGetItems :: Paginate master rep a -> Int -> Int -> GHandler (Paginate master rep a) master [a]
- Yesod.Paginate: pgnItemCount :: Paginate master a -> GHandler (Paginate master a) master Int
+ Yesod.Paginate: pgnItemCount :: Paginate master rep a -> GHandler (Paginate master rep a) master Int
- Yesod.Paginate: prevLink :: Paginate master a -> Int -> Int -> Maybe (Route (Paginate master a))
+ Yesod.Paginate: prevLink :: Paginate master rep a -> Int -> Int -> Maybe (Route (Paginate master rep a))

Files

Yesod/Paginate.hs view
@@ -23,16 +23,17 @@ import Control.Applicative import Language.Haskell.TH.Syntax -data Paginate master a = Paginate+data Paginate master rep a = Paginate   { pgnDefaultCount :: Int                                                              -- ^ How many items to show per page by default-  , pgnGetItems     :: Int -> Int -> GHandler (Paginate master a) master [a]            -- ^ Get a certain count of items at a certain offset-  , pgnItemCount    :: GHandler (Paginate master a) master Int                          -- ^ How many items there are in all-  , pgnDisplayItems :: Int -> Int -> [a] -> GHandler (Paginate master a) master RepHtml -- ^ Render the items on a page given the count and offset+  , pgnGetItems     :: Int -> Int -> GHandler (Paginate master rep a) master [a]        -- ^ Get a certain count of items at a certain offset+  , pgnItemCount    :: GHandler (Paginate master rep a) master Int                      -- ^ How many items there are in all+  , pgnDisplayItems :: Int -> Int -> [a] -> GHandler (Paginate master rep a) master rep -- ^ Render the items on a page given the count and offset   }  mkYesodSub-  "Paginate master a"+  "Paginate master rep a"   [ ClassP ''Yesod [VarT $ mkName "master"]+  , ClassP ''HasReps [VarT $ mkName "rep"]   ] #if GHC7   [parseRoutes|@@ -44,31 +45,31 @@ /#Int/#Int  PaginateR       GET |] -getPaginateHomeR :: GHandler (Paginate master a) master RepHtml+getPaginateHomeR :: GHandler (Paginate master rep a) master rep getPaginateHomeR = do   pgn <- getYesodSub   toMaster <- getRouteToMaster   redirect RedirectSeeOther (toMaster (PaginateR (pgnDefaultCount pgn) 0)) -getPaginateStartR :: Int -> GHandler (Paginate master a) master RepHtml+getPaginateStartR :: Int -> GHandler (Paginate master rep a) master rep getPaginateStartR start = do   pgn <- getYesodSub   toMaster <- getRouteToMaster   redirect RedirectSeeOther (toMaster (PaginateR (pgnDefaultCount pgn) start)) -getPaginateR :: Int -> Int -> GHandler (Paginate master a) master RepHtml+getPaginateR :: Int -> Int -> GHandler (Paginate master rep a) master rep getPaginateR howmany start = do   pgn <- getYesodSub   xs <- pgnGetItems pgn howmany start   pgnDisplayItems pgn howmany start xs  defaultPaginate-  :: (YesodPersist master, PersistBackend (YesodDB master (GHandler (Paginate master a) master)), PersistEntity a)+  :: (YesodPersist master, PersistBackend (YesodDB master (GHandler (Paginate master rep a) master)), PersistEntity a)   => Int                                                                -- ^ Default number of items to show   -> [Filter a]                                                         -- ^ Filters to apply   -> [Order a]                                                          -- ^ Ordering to apply-  -> (Int -> Int -> [a] -> GHandler (Paginate master a) master RepHtml) -- ^ Display function-  -> Paginate master a+  -> (Int -> Int -> [a] -> GHandler (Paginate master rep a) master rep)     -- ^ Display function+  -> Paginate master rep a defaultPaginate x fs os d = Paginate   { pgnDefaultCount = x   , pgnGetItems = \y z -> map snd <$> runDB (selectList fs os y z)@@ -77,13 +78,13 @@   }  -- | Link to the previous page.-prevLink :: Paginate master a -> Int -> Int -> Maybe (Route (Paginate master a))+prevLink :: Paginate master rep a -> Int -> Int -> Maybe (Route (Paginate master rep a)) prevLink p howmany start   | start > 0 = Just (PaginateR howmany (max 0 (start-howmany)))   | otherwise = Nothing  -- | Link to the next page.-nextLink :: Paginate master a -> Int -> Int -> GHandler (Paginate master a) master (Maybe (Route (Paginate master a)))+nextLink :: Paginate master rep a -> Int -> Int -> GHandler (Paginate master rep a) master (Maybe (Route (Paginate master rep a))) nextLink p howmany start = go <$> pgnItemCount p where   go l | start < l-howmany-1 = Just (PaginateR howmany (start+howmany))        | otherwise           = Nothing
yesod-paginate.cabal view
@@ -2,7 +2,7 @@ -- options, see -- http://www.haskell.org/cabal/release/cabal-latest/doc/users-guide/authors.html#pkg-descr. Name:                 yesod-paginate-Version:              0.0+Version:              0.1 Synopsis:             Pagination for Yesod sites. Description:           License:              BSD3