packages feed

yesod-colonnade 1.3.0.1 → 1.3.0.2

raw patch · 4 files changed

+181/−136 lines, 4 filesdep −conduitdep −conduit-extradep ~basedep ~blaze-htmldep ~blaze-markupsetup-changednew-uploaderPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependencies removed: conduit, conduit-extra

Dependency ranges changed: base, blaze-html, blaze-markup, colonnade, text, yesod-core, yesod-elements

API changes (from Hackage documentation)

- Yesod.Colonnade: Cell :: [Attribute] -> !(WidgetFor site ()) -> Cell site
+ Yesod.Colonnade: Cell :: [Attribute] -> !WidgetFor site () -> Cell site
- Yesod.Colonnade: [cellContents] :: Cell site -> !(WidgetFor site ())
+ Yesod.Colonnade: [cellContents] :: Cell site -> !WidgetFor site ()

Files

+ CHANGELOG.md view
@@ -0,0 +1,5 @@+# Revision history for yesod-colonnade++## 1.3.0.2 -- 2024-03-06++* Update package metadata.
− Setup.hs
@@ -1,2 +0,0 @@-import Distribution.Simple-main = defaultMain
src/Yesod/Colonnade.hs view
@@ -1,19 +1,21 @@--- | Build HTML tables using @yesod@ and @colonnade@. To learn---   how to use this module, first read the documentation for @colonnade@,---   and then read the documentation for @blaze-colonnade@. This library---   and @blaze-colonnade@ are entirely distinct; neither depends on the---   other. However, the interfaces they expose are very similar, and---   the explanations provided counterpart are sufficient to understand---   this library.+{- | Build HTML tables using @yesod@ and @colonnade@. To learn+  how to use this module, first read the documentation for @colonnade@,+  and then read the documentation for @blaze-colonnade@. This library+  and @blaze-colonnade@ are entirely distinct; neither depends on the+  other. However, the interfaces they expose are very similar, and+  the explanations provided counterpart are sufficient to understand+  this library.+-} module Yesod.Colonnade   ( -- * Build-    Cell(..)+    Cell (..)   , cell   , stringCell   , textCell   , builderCell   , anchorCell   , anchorWidget+     -- * Apply   , encodeWidgetTable   , encodeCellTable@@ -21,28 +23,23 @@   , encodeListItems   ) where -import Yesod.Core-import Yesod.Core.Types (Body(..),GWData(..),WidgetFor(..),wdRef)-import Colonnade (Colonnade,Headed,Headless)-import Data.Text (Text)+import Colonnade (Colonnade, Headed)+import qualified Colonnade.Encode as E import Control.Monad-import Data.IORef (modifyIORef')-import Data.Monoid-import Data.String (IsString(..))-import Text.Blaze (Attribute,toValue) import Data.Foldable-import Yesod.Elements (table_,thead_,tbody_,tr_,td_,th_,ul_,li_,a_)-import Data.Semigroup (Semigroup) import qualified Data.Semigroup as SG-import qualified Text.Blaze.Html5.Attributes as HA-import qualified Text.Blaze.Html5 as H-import qualified Colonnade.Encode as E-import qualified Data.Text as Text+import Data.String (IsString (..))+import Data.Text (Text) import qualified Data.Text.Lazy as LText import qualified Data.Text.Lazy.Builder as TBuilder+import Text.Blaze (Attribute, toValue)+import qualified Text.Blaze.Html5.Attributes as HA+import Yesod.Core+import Yesod.Elements (a_, li_, table_, tbody_, td_, th_, thead_, tr_) --- | The attributes that will be applied to a @<td>@ and---   the HTML content that will go inside it.+{- | The attributes that will be applied to a @<td>@ and+  the HTML content that will go inside it.+-} data Cell site = Cell   { cellAttrs :: [Attribute]   , cellContents :: !(WidgetFor site ())@@ -73,98 +70,139 @@ builderCell :: TBuilder.Builder -> Cell site builderCell = cell . toWidget . toHtml . LText.toStrict . TBuilder.toLazyText --- | Create a 'Cell' whose content is hyperlinked by wrapping---   it in an @\<a\>@.-anchorCell :: -     (a -> Route site) -- ^ Route that will go in @href@ attribute-  -> (a -> WidgetFor site ()) -- ^ Content wrapped by @<a>@ tag-  -> a -- ^ Value-  -> Cell site+{- | Create a 'Cell' whose content is hyperlinked by wrapping+  it in an @\<a\>@.+-}+anchorCell ::+  -- | Route that will go in @href@ attribute+  (a -> Route site) ->+  -- | Content wrapped by @<a>@ tag+  (a -> WidgetFor site ()) ->+  -- | Value+  a ->+  Cell site anchorCell getRoute getContent = cell . anchorWidget getRoute getContent --- | Create a widget whose content is hyperlinked by wrapping---   it in an @\<a\>@.-anchorWidget :: -     (a -> Route site) -- ^ Route that will go in @href@ attribute-  -> (a -> WidgetFor site ()) -- ^ Content wrapped by @<a>@ tag-  -> a -- ^ Value-  -> WidgetFor site ()+{- | Create a widget whose content is hyperlinked by wrapping+  it in an @\<a\>@.+-}+anchorWidget ::+  -- | Route that will go in @href@ attribute+  (a -> Route site) ->+  -- | Content wrapped by @<a>@ tag+  (a -> WidgetFor site ()) ->+  -- | Value+  a ->+  WidgetFor site () anchorWidget getRoute getContent a = do   urlRender <- getUrlRender   a_ [HA.href (toValue (urlRender (getRoute a)))] (getContent a) --- | This determines the attributes that are added---   to the individual @li@s by concatenating the header\'s---   attributes with the data\'s attributes. -encodeListItems :: -     (WidgetFor site () -> WidgetFor site ())-     -- ^ Wrapper for items, often @ul@-  -> (WidgetFor site () -> WidgetFor site () -> WidgetFor site ())-     -- ^ Combines header with data-  -> Colonnade Headed a (Cell site)-     -- ^ How to encode data as a row-  -> a-     -- ^ The value to display-  -> WidgetFor site ()+{- | This determines the attributes that are added+  to the individual @li@s by concatenating the header\'s+  attributes with the data\'s attributes.+-}+encodeListItems ::+  -- | Wrapper for items, often @ul@+  (WidgetFor site () -> WidgetFor site ()) ->+  -- | Combines header with data+  (WidgetFor site () -> WidgetFor site () -> WidgetFor site ()) ->+  -- | How to encode data as a row+  Colonnade Headed a (Cell site) ->+  -- | The value to display+  a ->+  WidgetFor site () encodeListItems ulWrap combine enc =-  ulWrap . E.bothMonadic_ enc-    (\(Cell ha hc) (Cell ba bc) ->-      li_ (ha <> ba) (combine hc bc)-    )+  ulWrap+    . E.bothMonadic_+      enc+      ( \(Cell ha hc) (Cell ba bc) ->+          li_ (ha <> ba) (combine hc bc)+      ) --- | A two-column table with the header content displayed in the---   first column and the data displayed in the second column. Note---   that the generated HTML table does not have a @thead@.+{- | A two-column table with the header content displayed in the+  first column and the data displayed in the second column. Note+  that the generated HTML table does not have a @thead@.+-} encodeDefinitionTable ::-     [Attribute]-     -- ^ Attributes of @table@ element.-  -> Colonnade Headed a (Cell site)-     -- ^ How to encode data as a row-  -> a-     -- ^ The value to display-  -> WidgetFor site ()-encodeDefinitionTable attrs enc a = table_ attrs $ tbody_ [] $ -  E.bothMonadic_ enc-    (\theKey theValue -> tr_ [] $ do-      widgetFromCell td_ theKey-      widgetFromCell td_ theValue-    ) a+  -- | Attributes of @table@ element.+  [Attribute] ->+  -- | How to encode data as a row+  Colonnade Headed a (Cell site) ->+  -- | The value to display+  a ->+  WidgetFor site ()+encodeDefinitionTable attrs enc a =+  table_ attrs $+    tbody_ [] $+      E.bothMonadic_+        enc+        ( \theKey theValue -> tr_ [] $ do+            widgetFromCell td_ theKey+            widgetFromCell td_ theValue+        )+        a --- | Encode an html table with attributes on the table cells.---   If you are using the bootstrap css framework, then you may want---   to call this with the first argument as:------   > encodeCellTable (HA.class_ "table table-striped") ...-encodeCellTable :: (Foldable f, E.Headedness h)-  => [Attribute] -- ^ Attributes of @table@ element-  -> Colonnade h a (Cell site) -- ^ How to encode data as a row-  -> f a -- ^ Rows of data-  -> WidgetFor site ()-encodeCellTable = encodeTable-  (E.headednessPure mempty) mempty (const mempty) widgetFromCell +{- | Encode an html table with attributes on the table cells.+  If you are using the bootstrap css framework, then you may want+  to call this with the first argument as: +  > encodeCellTable (HA.class_ "table table-striped") ...+-}+encodeCellTable ::+  (Foldable f, E.Headedness h) =>+  -- | Attributes of @table@ element+  [Attribute] ->+  -- | How to encode data as a row+  Colonnade h a (Cell site) ->+  -- | Rows of data+  f a ->+  WidgetFor site ()+encodeCellTable =+  encodeTable+    (E.headednessPure mempty)+    mempty+    (const mempty)+    widgetFromCell+ -- | Encode an html table.-encodeWidgetTable :: (Foldable f, E.Headedness h)-  => [Attribute] -- ^ Attributes of @\<table\>@ element-  -> Colonnade h a (WidgetFor site ()) -- ^ How to encode data as columns-  -> f a -- ^ Rows of data-  -> WidgetFor site ()-encodeWidgetTable = encodeTable-  (E.headednessPure mempty) mempty (const mempty) ($ mempty) +encodeWidgetTable ::+  (Foldable f, E.Headedness h) =>+  -- | Attributes of @\<table\>@ element+  [Attribute] ->+  -- | How to encode data as columns+  Colonnade h a (WidgetFor site ()) ->+  -- | Rows of data+  f a ->+  WidgetFor site ()+encodeWidgetTable =+  encodeTable+    (E.headednessPure mempty)+    mempty+    (const mempty)+    ($ mempty) --- | Encode a table. This handles a very general case and---   is seldom needed by users. One of the arguments provided is---   used to add attributes to the generated @\<tr\>@ elements.+{- | Encode a table. This handles a very general case and+  is seldom needed by users. One of the arguments provided is+  used to add attributes to the generated @\<tr\>@ elements.+-} encodeTable ::-     (Foldable f, E.Headedness h)-  => h [Attribute] -- ^ Attributes of @\<thead\>@-  -> [Attribute] -- ^ Attributes of @\<tbody\>@ element-  -> (a -> [Attribute]) -- ^ Attributes of each @\<tr\>@ element-  -> (([Attribute] -> WidgetFor site () -> WidgetFor site ()) -> c -> WidgetFor site ()) -- ^ Wrap content and convert to 'Html'-  -> [Attribute] -- ^ Attributes of @\<table\>@ element-  -> Colonnade h a c -- ^ How to encode data as a row-  -> f a -- ^ Collection of data-  -> WidgetFor site ()+  (Foldable f, E.Headedness h) =>+  -- | Attributes of @\<thead\>@+  h [Attribute] ->+  -- | Attributes of @\<tbody\>@ element+  [Attribute] ->+  -- | Attributes of each @\<tr\>@ element+  (a -> [Attribute]) ->+  -- | Wrap content and convert to 'Html'+  (([Attribute] -> WidgetFor site () -> WidgetFor site ()) -> c -> WidgetFor site ()) ->+  -- | Attributes of @\<table\>@ element+  [Attribute] ->+  -- | How to encode data as a row+  Colonnade h a c ->+  -- | Collection of data+  f a ->+  WidgetFor site () encodeTable theadAttrs tbodyAttrs trAttrs wrapContent tableAttrs colonnade xs =   table_ tableAttrs $ do     for_ E.headednessExtract $ \unhead ->@@ -175,9 +213,8 @@         tr_ (trAttrs x) (E.rowMonadic_ colonnade (wrapContent td_) x)  widgetFromCell ::-     ([Attribute] -> WidgetFor site () -> WidgetFor site ())-  -> Cell site-  -> WidgetFor site ()+  ([Attribute] -> WidgetFor site () -> WidgetFor site ()) ->+  Cell site ->+  WidgetFor site () widgetFromCell f (Cell attrs contents) =   f attrs contents-
yesod-colonnade.cabal view
@@ -1,33 +1,38 @@-cabal-version: 2.0-name: yesod-colonnade-version: 1.3.0.1-synopsis: Helper functions for using yesod with colonnade-description: Yesod and colonnade-homepage: https://github.com/andrewthad/colonnade#readme-license: BSD3-license-file: LICENSE-author: Andrew Martin-maintainer: andrew.thaddeus@gmail.com-copyright: 2018 Andrew Martin-category: web-build-type: Simple+cabal-version:   3.0+name:            yesod-colonnade+version:         1.3.0.2+synopsis:        Helper functions for using yesod with colonnade+description:     Helper functions for using yesod with colonnade.+homepage:        https://github.com/byteverse/yesod-colonnade+bug-reports:     https://github.com/byteverse/yesod-colonnade/issues+license:         BSD-3-Clause+license-file:    LICENSE+author:          Andrew Martin+maintainer:      amartin@layer3com.com+copyright:       2018 Andrew Martin+category:        web+build-type:      Simple+extra-doc-files: CHANGELOG.md+tested-with:     GHC ==9.4.8 || ==9.6.3 || ==9.8.1 +common build-settings+  default-language: Haskell2010+  ghc-options:      -Wall -Wunused-packages+  build-depends:    base >=4.9.1 && <5+ library-  hs-source-dirs: src-  exposed-modules:-    Yesod.Colonnade+  import:          build-settings+  ghc-options:     -O2+  hs-source-dirs:  src+  exposed-modules: Yesod.Colonnade   build-depends:-      base >= 4.9.1.0 && < 4.12-    , colonnade >= 1.2 && < 1.3-    , yesod-core >= 1.6 && < 1.7-    , conduit >= 1.3 && < 1.4-    , conduit-extra >= 1.3 && < 1.4-    , text >= 1.0 && < 1.3-    , blaze-markup >= 0.7 && < 0.9-    , blaze-html >= 0.8 && < 0.10-    , yesod-elements >= 1.1 && < 1.2-  default-language: Haskell2010+    , blaze-html      >=0.8+    , blaze-markup    >=0.7+    , colonnade       >=1.2+    , text            >=1.0+    , yesod-core      >=1.6+    , yesod-elements  >=1.1  source-repository head-  type: git-  location: https://github.com/andrewthad/colonnade+  type:     git+  location: git://github.com/byteverse/yesod-colonnade.git