Permalink
Browse files

adjust to my whitespace preferences

  • Loading branch information...
1 parent b199b87 commit 3c5b1fee6136d6ffb3cc89107f150932c80012f1 @pbrisbin committed Apr 26, 2012
Showing with 34 additions and 33 deletions.
  1. +18 −15 Yesod/Paginator.hs
  2. +16 −18 Yesod/Paginator/Widget.hs
View
@@ -72,22 +72,25 @@ paginateWith widget per items = do
return (xs, widget p per tot)
-selectPaginated :: (PersistEntity val,
- PersistQuery (PersistEntityBackend val) (GHandler s m),
- MonadTrans (PersistEntityBackend val)) =>
- Int
- -> [Filter val]
- -> [SelectOpt val]
- -> PersistEntityBackend val (GHandler s m) ([Entity val], GWidget s m ())
+selectPaginated :: ( PersistEntity val
+ , PersistQuery (PersistEntityBackend val) (GHandler s m)
+ , MonadTrans (PersistEntityBackend val)
+ )
+ => Int
+ -> [Filter val]
+ -> [SelectOpt val]
+ -> PersistEntityBackend val (GHandler s m) ([Entity val], GWidget s m ())
selectPaginated = selectPaginatedWith defaultWidget
-selectPaginatedWith :: (PersistEntity val,
- PersistQuery (PersistEntityBackend val) (GHandler s m),
- MonadTrans (PersistEntityBackend val)) =>
- PageWidget s m
- -> Int
- -> [Filter val]
- -> [SelectOpt val]
- -> PersistEntityBackend val (GHandler s m) ([Entity val], GWidget s m ())
+
+selectPaginatedWith :: ( PersistEntity val
+ , PersistQuery (PersistEntityBackend val) (GHandler s m)
+ , MonadTrans (PersistEntityBackend val)
+ )
+ => PageWidget s m
+ -> Int
+ -> [Filter val]
+ -> [SelectOpt val]
+ -> PersistEntityBackend val (GHandler s m) ([Entity val], GWidget s m ())
selectPaginatedWith widget per filters selectOpts = do
p <- lift getCurrentPage
tot <- count filters
View
@@ -9,31 +9,29 @@ module Yesod.Paginator.Widget
, PageWidgetConfig(..)
) where
-import Yesod
+import Yesod
+import Control.Monad (when)
+import Data.Maybe (fromMaybe)
+import Data.Text (Text)
-import Control.Monad (when)
-import Data.Maybe (fromMaybe)
-import Data.Text (Text)
import qualified Data.Text as T
type PageWidget s m = Int -> Int -> Int -> GWidget s m ()
-data PageWidgetConfig = PageWidgetConfig {
- prevText :: Text -- ^ The text for the 'previous page' link.
- , nextText :: Text -- ^ The text for the 'next page' link.
- , pageCount :: Int -- ^ The number of page links to show
- , ascending :: Bool -- ^ Whether to list pages in ascending order.
- , showEllipsis :: Bool -- ^ Whether to show an ellipsis if there are
- -- more pages than pageCount
-}
+data PageWidgetConfig = PageWidgetConfig
+ { prevText :: Text -- ^ The text for the 'previous page' link.
+ , nextText :: Text -- ^ The text for the 'next page' link.
+ , pageCount :: Int -- ^ The number of page links to show
+ , ascending :: Bool -- ^ Whether to list pages in ascending order.
+ , showEllipsis :: Bool -- ^ Whether to show an ellipsis if there are
+ } -- more pages than pageCount
-- | Individual links to pages need to follow strict (but sane) markup
-- to be styled correctly by bootstrap. This type allows construction
-- of such links in both enabled and disabled states.
data PageLink = Enabled Int Text Text -- ^ page, content, class
| Disabled Text Text -- ^ content, class
-
-- | Correctly show one of the constructed links
showLink :: [(Text, Text)] -> PageLink -> GWidget s m ()
showLink params (Enabled pg cnt cls) = do
@@ -57,10 +55,10 @@ showLink _ (Disabled cnt cls) =
|]
defaultWidget :: PageWidget s m
-defaultWidget = paginationWidget $ PageWidgetConfig { prevText = "«"
- , nextText = "»"
- , pageCount = 9
- , ascending = True
+defaultWidget = paginationWidget $ PageWidgetConfig { prevText = "«"
+ , nextText = "»"
+ , pageCount = 9
+ , ascending = True
, showEllipsis = True
}
@@ -131,4 +129,4 @@ getCurrentPage = fmap (fromMaybe 1 . go) $ lookupGetParam "p"
go mp = readIntegral . T.unpack =<< mp
showT :: (Show a) => a -> Text
-showT = T.pack . show
+showT = T.pack . show

0 comments on commit 3c5b1fe

Please sign in to comment.