yesod-pagination 0.4.0.0 → 0.5.0.0
raw patch · 3 files changed
+7/−5 lines, 3 filesdep −shakespeare-text
Dependencies removed: shakespeare-text
Files
- src/Yesod/Paginate.hs +3/−0
- tests/main.hs +2/−2
- yesod-pagination.cabal +2/−3
src/Yesod/Paginate.hs view
@@ -43,6 +43,7 @@ -- | Returned by 'paginate' and friends. data Page r = Page { pageResults :: [r] -- ^ Returned entities.+ , firstPage :: Maybe Text -- ^ Link to first page. , nextPage :: Maybe Text -- ^ Link to next page, pre-rendered. , previousPage :: Maybe Text -- ^ Link to previous page, pre-rendered. } deriving (Eq, Read, Show)@@ -94,10 +95,12 @@ let rt = fromMaybe (error "Attempting to use paginate on a server error page.") rt' qs = snd $ renderRoute rt+ fp = rend rt $ updateQs qs ("page", "1") np = rend rt $ updateQs qs ("page", [st|#{cp + 1}|]) pp = rend rt $ updateQs qs ("page", [st|#{cp - 1}|]) return Page { pageResults = take (fromIntegral $ pageSize c) es+ , firstPage = if cp >= 2 then Just fp else Nothing , nextPage = if fromIntegral (length es) == pageSize c + 1 then Just np else Nothing
tests/main.hs view
@@ -57,14 +57,14 @@ clearOut pool get ItemsR- wantPage $ Page [] Nothing Nothing+ wantPage $ Page [] Nothing Nothing Nothing yit "with some items" $ do clearOut pool k <- liftIO $ runSqlPersistMPool (insert $ Item "hello, world!") pool get ItemsR- wantPage $ Page [Entity k (Item "hello, world!")] Nothing Nothing+ wantPage $ Page [Entity k (Item "hello, world!")] Nothing Nothing Nothing yit "with two pages" $ do clearOut pool
yesod-pagination.cabal view
@@ -1,5 +1,5 @@ name: yesod-pagination-version: 0.4.0.0+version: 0.5.0.0 synopsis: Pagination in Yesod description: Easy pagination for Yesod. homepage: https://github.com/joelteon/yesod-pagination@@ -17,7 +17,6 @@ , data-default , esqueleto , shakespeare- , shakespeare-text , text , yesod hs-source-dirs: src@@ -34,7 +33,7 @@ , persistent-sqlite , resource-pool , resourcet- , shakespeare-text+ , shakespeare , text , utf8-string , wai-test