packages feed

web-rep 0.1.2 → 0.1.3

raw patch · 6 files changed

+20/−14 lines, 6 filesdep +text-formatdep −formatting

Dependencies added: text-format

Dependencies removed: formatting

Files

src/Web/Page/Bootstrap.hs view
@@ -100,7 +100,7 @@     (with div_ ([class__ "card-body"]) bodyhtml)  -- | create a bootstrapped accordian class-accordion :: (MonadState Int m, Monad m) => Text -> Maybe Text -> [(Text, Html ())] -> m (Html ())+accordion :: (MonadState Int m) => Text -> Maybe Text -> [(Text, Html ())] -> m (Html ()) accordion pre x hs = do   idp' <- genNamePre pre   with div_ [class__ "accordion", id_ idp'] <$> aCards idp'@@ -112,7 +112,7 @@         pure $ accordionCard (x /= Just t) [] par idh idb t b  -- | create a bootstrapped accordian class-accordionChecked :: (MonadState Int m, Monad m) => Text -> [(Text, Html (), Html ())] -> m (Html ())+accordionChecked :: (MonadState Int m) => Text -> [(Text, Html (), Html ())] -> m (Html ()) accordionChecked pre hs = do   idp' <- genNamePre pre   with div_ [class__ "accordion", id_ idp'] <$> aCards idp'
src/Web/Page/Bridge.hs view
@@ -3,6 +3,7 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE QuasiQuotes #-} {-# OPTIONS_GHC -Wall #-}+{-# OPTIONS_GHC -Wredundant-constraints #-}  module Web.Page.Bridge   ( bridgePage@@ -137,10 +138,9 @@   Text.intercalate "\\'" . Text.split (=='\'') .   Text.intercalate "\\n" . Text.lines - -- | create Wai Middleware for a SharedRep providing an initialiser and action on events midShared ::-  (Show a) =>+  ( ) =>   SharedRep IO a ->   (Engine -> Rep a -> StateT (HashMap Text Text) IO ()) ->   (Engine -> Either Text (HashMap Text Text, Either Text a) -> IO ()) ->
src/Web/Page/Html.hs view
@@ -21,7 +21,8 @@ import Codec.Picture.Types (PixelRGB8(..)) import Data.Attoparsec.Text import Numeric-import Formatting hiding (string)+import Data.Text.Format+import Data.Text.Lazy.Builder (toLazyText)  class__ :: Text -> Attribute class__ t = class_ (" " <> t <> " ")@@ -57,7 +58,11 @@     (string "#" *> hexadecimal)  toHex :: PixelRGB8 -> Text-toHex (PixelRGB8 r g b) = sformat ("#" % ((left 2 '0') %. hex) % ((left 2 '0') %. hex) % ((left 2 '0') %. hex)) r g b+toHex (PixelRGB8 r g b) =+  "#"+  <> justifyRight 2 '0' (toStrict $ toLazyText $ hex r)+  <> justifyRight 2 '0' (toStrict $ toLazyText $ hex g)+  <> justifyRight 2 '0' (toStrict $ toLazyText $ hex b)  -- `ToHtml a` is used throughout because `Show a` gives "\"text\"" for show "text", and hilarity ensues when rendering to the web page. -- hence orphans
src/Web/Page/Rep/Input.hs view
@@ -3,6 +3,7 @@ {-# LANGUAGE OverloadedLabels #-} {-# LANGUAGE OverloadedStrings #-} {-# OPTIONS_GHC -Wall #-}+{-# OPTIONS_GHC -Wredundant-constraints #-}  module Web.Page.Rep.Input   ( repInput@@ -42,7 +43,7 @@ import Box.Cont ()  -- | create a sharedRep from an Input-repInput :: (Monad m, ToHtml a, Show a) => Parser a -> (a -> Text) -> Input a -> a -> SharedRep m a+repInput :: (Monad m, ToHtml a) => Parser a -> (a -> Text) -> Input a -> a -> SharedRep m a repInput p pr i a =   SharedRep $ do     name <- zoom _1 genName@@ -56,7 +57,7 @@         either (Left . (\x -> name <> ": " <> x) . pack) Right . parseOnly p <$> lookup name s))  -- | does not put a value into the HashMap on instantiation, consumes the value when found in the HashMap, and substitutes a default on lookup failure-repMessage :: (Monad m, ToHtml a, Show a) => Parser a -> (a -> Text) -> Input a -> a -> a -> SharedRep m a+repMessage :: (Monad m, ToHtml a) => Parser a -> (a -> Text) -> Input a -> a -> a -> SharedRep m a repMessage p _ i def a =   SharedRep $ do     name <- zoom _1 genName@@ -90,7 +91,7 @@ colorPicker label v = repInput fromHex toHex   (Input v label mempty ColorPicker) v -dropdown :: (Monad m, ToHtml a, Show a) =>+dropdown :: (Monad m, ToHtml a) =>   Parser a -> (a -> Text) -> Maybe Text -> [Text] -> a -> SharedRep m a dropdown p pr label opts v = repInput p pr    (Input v label mempty (Dropdown opts)) v@@ -99,7 +100,7 @@ datalist label opts v id'' = repInput takeText show   (Input v label mempty (Datalist opts id'')) v -dropdownSum :: (Monad m, ToHtml a, Show a) =>+dropdownSum :: (Monad m, ToHtml a) =>   Parser a -> (a -> Text) -> Maybe Text -> [Text] -> a -> SharedRep m a dropdownSum p pr label opts v = repInput p pr   (Input v label mempty (DropdownSum opts)) v
stack.yaml view
@@ -1,11 +1,11 @@-resolver: lts-14.11+resolver: lts-14.13  packages: - '.'  extra-deps:   - lucid-svg-0.7.1-  - box-0.0.1.5+  - box-0.1.0   - javascript-bridge-0.2.0  allow-newer: true
web-rep.cabal view
@@ -1,6 +1,6 @@ cabal-version: 1.12 name:           web-rep-version:        0.1.2+version:        0.1.3 synopsis:       representations of a web pag category: web description:    See readme.md for verbage (if any)@@ -38,7 +38,6 @@     , box     , clay     , foldl-    , formatting     , generic-lens     , interpolatedstring-perl6     , javascript-bridge@@ -52,6 +51,7 @@     , scotty     , streaming     , text+    , text-format     , transformers     , unordered-containers     , wai-middleware-static