{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeSynonymInstances #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE QuasiQuotes #-}
module Yesod.Core.Widget
(
WidgetT
, WidgetFor
, PageContent (..)
, whamlet
, whamletFile
, ihamletToRepHtml
, ihamletToHtml
, ToWidget (..)
, ToWidgetHead (..)
, ToWidgetBody (..)
, ToWidgetMedia (..)
, setTitle
, setTitleI
, setDescription
, setDescriptionI
, setOGType
, setOGImage
, addStylesheet
, addStylesheetAttrs
, addStylesheetRemote
, addStylesheetRemoteAttrs
, addStylesheetEither
, CssBuilder (..)
, addScript
, addScriptAttrs
, addScriptRemote
, addScriptRemoteAttrs
, addScriptEither
, handlerToWidget
, whamletFileWithSettings
, asWidgetT
) where
import Data.Monoid
import qualified Text.Blaze.Html5 as H
import Text.Hamlet
import Text.Cassius
import Text.Julius
import Yesod.Routes.Class
import Yesod.Core.Handler (getMessageRender, getUrlRenderParams)
import Text.Shakespeare.I18N (RenderMessage)
import Data.Text (Text)
import qualified Data.Map as Map
import Language.Haskell.TH.Quote (QuasiQuoter)
import Language.Haskell.TH.Syntax (Q, Exp (InfixE, VarE, LamE, AppE), Pat (VarP), newName)
import qualified Text.Hamlet as NP
import Data.Text.Lazy.Builder (fromLazyText)
import Text.Blaze.Html (toHtml, preEscapedToMarkup)
import qualified Data.Text.Lazy as TL
import qualified Data.Text.Lazy.Builder as TB
import Yesod.Core.Types
import Yesod.Core.Class.Handler
type WidgetT site (m :: * -> *) = WidgetFor site
{-# DEPRECATED WidgetT "Use WidgetFor directly" #-}
preEscapedLazyText :: TL.Text -> Html
preEscapedLazyText :: Text -> Html
preEscapedLazyText = Text -> Html
forall a. ToMarkup a => a -> Html
preEscapedToMarkup
class ToWidget site a where
toWidget :: (MonadWidget m, HandlerSite m ~ site) => a -> m ()
instance render ~ RY site => ToWidget site (render -> Html) where
toWidget :: (render -> Html) -> m ()
toWidget render -> Html
x = GWData (Route (HandlerSite m)) -> m ()
forall (m :: * -> *).
MonadWidget m =>
GWData (Route (HandlerSite m)) -> m ()
tell (GWData (Route (HandlerSite m)) -> m ())
-> GWData (Route (HandlerSite m)) -> m ()
forall a b. (a -> b) -> a -> b
$ Body (Route site)
-> Last Title
-> UniqueList (Script (Route site))
-> UniqueList (Stylesheet (Route site))
-> Map (Maybe Text) (CssBuilderUrl (Route site))
-> Maybe (JavascriptUrl (Route site))
-> Head (Route site)
-> GWData (Route site)
forall a.
Body a
-> Last Title
-> UniqueList (Script a)
-> UniqueList (Stylesheet a)
-> Map (Maybe Text) (CssBuilderUrl a)
-> Maybe (JavascriptUrl a)
-> Head a
-> GWData a
GWData (HtmlUrl (Route site) -> Body (Route site)
forall url. HtmlUrl url -> Body url
Body render -> Html
HtmlUrl (Route site)
x) Last Title
forall a. Monoid a => a
mempty UniqueList (Script (Route site))
forall a. Monoid a => a
mempty UniqueList (Stylesheet (Route site))
forall a. Monoid a => a
mempty Map (Maybe Text) (CssBuilderUrl (Route site))
forall a. Monoid a => a
mempty Maybe (JavascriptUrl (Route site))
forall a. Monoid a => a
mempty Head (Route site)
forall a. Monoid a => a
mempty
instance render ~ RY site => ToWidget site (render -> Css) where
toWidget :: (render -> Css) -> m ()
toWidget render -> Css
x = (render -> CssBuilder) -> m ()
forall site a (m :: * -> *).
(ToWidget site a, MonadWidget m, HandlerSite m ~ site) =>
a -> m ()
toWidget ((render -> CssBuilder) -> m ()) -> (render -> CssBuilder) -> m ()
forall a b. (a -> b) -> a -> b
$ Builder -> CssBuilder
CssBuilder (Builder -> CssBuilder)
-> (render -> Builder) -> render -> CssBuilder
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Builder
fromLazyText (Text -> Builder) -> (render -> Text) -> render -> Builder
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Css -> Text
renderCss (Css -> Text) -> (render -> Css) -> render -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. render -> Css
x
instance ToWidget site Css where
toWidget :: Css -> m ()
toWidget Css
x = (RY site -> CssBuilder) -> m ()
forall site a (m :: * -> *).
(ToWidget site a, MonadWidget m, HandlerSite m ~ site) =>
a -> m ()
toWidget ((RY site -> CssBuilder) -> m ())
-> (RY site -> CssBuilder) -> m ()
forall a b. (a -> b) -> a -> b
$ Builder -> CssBuilder
CssBuilder (Builder -> CssBuilder)
-> (RY site -> Builder) -> RY site -> CssBuilder
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Builder
fromLazyText (Text -> Builder) -> (RY site -> Text) -> RY site -> Builder
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Css -> Text
renderCss (Css -> Text) -> (RY site -> Css) -> RY site -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Css -> RY site -> Css
forall a b. a -> b -> a
const Css
x
instance render ~ RY site => ToWidget site (render -> CssBuilder) where
toWidget :: (render -> CssBuilder) -> m ()
toWidget render -> CssBuilder
x = GWData (Route (HandlerSite m)) -> m ()
forall (m :: * -> *).
MonadWidget m =>
GWData (Route (HandlerSite m)) -> m ()
tell (GWData (Route (HandlerSite m)) -> m ())
-> GWData (Route (HandlerSite m)) -> m ()
forall a b. (a -> b) -> a -> b
$ Body (Route site)
-> Last Title
-> UniqueList (Script (Route site))
-> UniqueList (Stylesheet (Route site))
-> Map (Maybe Text) (CssBuilderUrl (Route site))
-> Maybe (JavascriptUrl (Route site))
-> Head (Route site)
-> GWData (Route site)
forall a.
Body a
-> Last Title
-> UniqueList (Script a)
-> UniqueList (Stylesheet a)
-> Map (Maybe Text) (CssBuilderUrl a)
-> Maybe (JavascriptUrl a)
-> Head a
-> GWData a
GWData Body (Route site)
forall a. Monoid a => a
mempty Last Title
forall a. Monoid a => a
mempty UniqueList (Script (Route site))
forall a. Monoid a => a
mempty UniqueList (Stylesheet (Route site))
forall a. Monoid a => a
mempty (Maybe Text
-> (render -> Builder) -> Map (Maybe Text) (render -> Builder)
forall k a. k -> a -> Map k a
Map.singleton Maybe Text
forall a. Maybe a
Nothing ((render -> Builder) -> Map (Maybe Text) (render -> Builder))
-> (render -> Builder) -> Map (Maybe Text) (render -> Builder)
forall a b. (a -> b) -> a -> b
$ CssBuilder -> Builder
unCssBuilder (CssBuilder -> Builder)
-> (render -> CssBuilder) -> render -> Builder
forall b c a. (b -> c) -> (a -> b) -> a -> c
. render -> CssBuilder
x) Maybe (JavascriptUrl (Route site))
forall a. Monoid a => a
mempty Head (Route site)
forall a. Monoid a => a
mempty
instance ToWidget site CssBuilder where
toWidget :: CssBuilder -> m ()
toWidget CssBuilder
x = GWData (Route (HandlerSite m)) -> m ()
forall (m :: * -> *).
MonadWidget m =>
GWData (Route (HandlerSite m)) -> m ()
tell (GWData (Route (HandlerSite m)) -> m ())
-> GWData (Route (HandlerSite m)) -> m ()
forall a b. (a -> b) -> a -> b
$ Body (Route site)
-> Last Title
-> UniqueList (Script (Route site))
-> UniqueList (Stylesheet (Route site))
-> Map (Maybe Text) (CssBuilderUrl (Route site))
-> Maybe (JavascriptUrl (Route site))
-> Head (Route site)
-> GWData (Route site)
forall a.
Body a
-> Last Title
-> UniqueList (Script a)
-> UniqueList (Stylesheet a)
-> Map (Maybe Text) (CssBuilderUrl a)
-> Maybe (JavascriptUrl a)
-> Head a
-> GWData a
GWData Body (Route site)
forall a. Monoid a => a
mempty Last Title
forall a. Monoid a => a
mempty UniqueList (Script (Route site))
forall a. Monoid a => a
mempty UniqueList (Stylesheet (Route site))
forall a. Monoid a => a
mempty (Maybe Text
-> CssBuilderUrl (Route site)
-> Map (Maybe Text) (CssBuilderUrl (Route site))
forall k a. k -> a -> Map k a
Map.singleton Maybe Text
forall a. Maybe a
Nothing (CssBuilderUrl (Route site)
-> Map (Maybe Text) (CssBuilderUrl (Route site)))
-> CssBuilderUrl (Route site)
-> Map (Maybe Text) (CssBuilderUrl (Route site))
forall a b. (a -> b) -> a -> b
$ CssBuilder -> Builder
unCssBuilder (CssBuilder -> Builder)
-> ((Route site -> [(Text, Text)] -> Text) -> CssBuilder)
-> CssBuilderUrl (Route site)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CssBuilder -> (Route site -> [(Text, Text)] -> Text) -> CssBuilder
forall a b. a -> b -> a
const CssBuilder
x) Maybe (JavascriptUrl (Route site))
forall a. Monoid a => a
mempty Head (Route site)
forall a. Monoid a => a
mempty
instance render ~ RY site => ToWidget site (render -> Javascript) where
toWidget :: (render -> Javascript) -> m ()
toWidget render -> Javascript
x = GWData (Route (HandlerSite m)) -> m ()
forall (m :: * -> *).
MonadWidget m =>
GWData (Route (HandlerSite m)) -> m ()
tell (GWData (Route (HandlerSite m)) -> m ())
-> GWData (Route (HandlerSite m)) -> m ()
forall a b. (a -> b) -> a -> b
$ Body (Route site)
-> Last Title
-> UniqueList (Script (Route site))
-> UniqueList (Stylesheet (Route site))
-> Map (Maybe Text) (CssBuilderUrl (Route site))
-> Maybe (JavascriptUrl (Route site))
-> Head (Route site)
-> GWData (Route site)
forall a.
Body a
-> Last Title
-> UniqueList (Script a)
-> UniqueList (Stylesheet a)
-> Map (Maybe Text) (CssBuilderUrl a)
-> Maybe (JavascriptUrl a)
-> Head a
-> GWData a
GWData Body (Route site)
forall a. Monoid a => a
mempty Last Title
forall a. Monoid a => a
mempty UniqueList (Script (Route site))
forall a. Monoid a => a
mempty UniqueList (Stylesheet (Route site))
forall a. Monoid a => a
mempty Map (Maybe Text) (CssBuilderUrl (Route site))
forall a. Monoid a => a
mempty ((render -> Javascript) -> Maybe (render -> Javascript)
forall a. a -> Maybe a
Just render -> Javascript
x) Head (Route site)
forall a. Monoid a => a
mempty
instance ToWidget site Javascript where
toWidget :: Javascript -> m ()
toWidget Javascript
x = GWData (Route (HandlerSite m)) -> m ()
forall (m :: * -> *).
MonadWidget m =>
GWData (Route (HandlerSite m)) -> m ()
tell (GWData (Route (HandlerSite m)) -> m ())
-> GWData (Route (HandlerSite m)) -> m ()
forall a b. (a -> b) -> a -> b
$ Body (Route site)
-> Last Title
-> UniqueList (Script (Route site))
-> UniqueList (Stylesheet (Route site))
-> Map (Maybe Text) (CssBuilderUrl (Route site))
-> Maybe (JavascriptUrl (Route site))
-> Head (Route site)
-> GWData (Route site)
forall a.
Body a
-> Last Title
-> UniqueList (Script a)
-> UniqueList (Stylesheet a)
-> Map (Maybe Text) (CssBuilderUrl a)
-> Maybe (JavascriptUrl a)
-> Head a
-> GWData a
GWData Body (Route site)
forall a. Monoid a => a
mempty Last Title
forall a. Monoid a => a
mempty UniqueList (Script (Route site))
forall a. Monoid a => a
mempty UniqueList (Stylesheet (Route site))
forall a. Monoid a => a
mempty Map (Maybe Text) (CssBuilderUrl (Route site))
forall a. Monoid a => a
mempty (JavascriptUrl (Route site) -> Maybe (JavascriptUrl (Route site))
forall a. a -> Maybe a
Just (JavascriptUrl (Route site) -> Maybe (JavascriptUrl (Route site)))
-> JavascriptUrl (Route site) -> Maybe (JavascriptUrl (Route site))
forall a b. (a -> b) -> a -> b
$ Javascript -> JavascriptUrl (Route site)
forall a b. a -> b -> a
const Javascript
x) Head (Route site)
forall a. Monoid a => a
mempty
instance (site' ~ site, a ~ ()) => ToWidget site' (WidgetFor site a) where
toWidget :: WidgetFor site a -> m ()
toWidget = WidgetFor site a -> m ()
forall (m :: * -> *) a.
MonadWidget m =>
WidgetFor (HandlerSite m) a -> m a
liftWidget
instance ToWidget site Html where
toWidget :: Html -> m ()
toWidget = (RY site -> Html) -> m ()
forall site a (m :: * -> *).
(ToWidget site a, MonadWidget m, HandlerSite m ~ site) =>
a -> m ()
toWidget ((RY site -> Html) -> m ())
-> (Html -> RY site -> Html) -> Html -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Html -> RY site -> Html
forall a b. a -> b -> a
const
instance ToWidget site Text where
toWidget :: Text -> m ()
toWidget = Html -> m ()
forall site a (m :: * -> *).
(ToWidget site a, MonadWidget m, HandlerSite m ~ site) =>
a -> m ()
toWidget (Html -> m ()) -> (Text -> Html) -> Text -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Html
forall a. ToMarkup a => a -> Html
toHtml
instance ToWidget site TL.Text where
toWidget :: Text -> m ()
toWidget = Html -> m ()
forall site a (m :: * -> *).
(ToWidget site a, MonadWidget m, HandlerSite m ~ site) =>
a -> m ()
toWidget (Html -> m ()) -> (Text -> Html) -> Text -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Html
forall a. ToMarkup a => a -> Html
toHtml
instance ToWidget site TB.Builder where
toWidget :: Builder -> m ()
toWidget = Html -> m ()
forall site a (m :: * -> *).
(ToWidget site a, MonadWidget m, HandlerSite m ~ site) =>
a -> m ()
toWidget (Html -> m ()) -> (Builder -> Html) -> Builder -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Builder -> Html
forall a. ToMarkup a => a -> Html
toHtml
class ToWidgetMedia site a where
toWidgetMedia :: (MonadWidget m, HandlerSite m ~ site)
=> Text
-> a
-> m ()
instance render ~ RY site => ToWidgetMedia site (render -> Css) where
toWidgetMedia :: Text -> (render -> Css) -> m ()
toWidgetMedia Text
media render -> Css
x = Text -> (render -> CssBuilder) -> m ()
forall site a (m :: * -> *).
(ToWidgetMedia site a, MonadWidget m, HandlerSite m ~ site) =>
Text -> a -> m ()
toWidgetMedia Text
media ((render -> CssBuilder) -> m ()) -> (render -> CssBuilder) -> m ()
forall a b. (a -> b) -> a -> b
$ Builder -> CssBuilder
CssBuilder (Builder -> CssBuilder)
-> (render -> Builder) -> render -> CssBuilder
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Builder
fromLazyText (Text -> Builder) -> (render -> Text) -> render -> Builder
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Css -> Text
renderCss (Css -> Text) -> (render -> Css) -> render -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. render -> Css
x
instance ToWidgetMedia site Css where
toWidgetMedia :: Text -> Css -> m ()
toWidgetMedia Text
media Css
x = Text -> (RY site -> CssBuilder) -> m ()
forall site a (m :: * -> *).
(ToWidgetMedia site a, MonadWidget m, HandlerSite m ~ site) =>
Text -> a -> m ()
toWidgetMedia Text
media ((RY site -> CssBuilder) -> m ())
-> (RY site -> CssBuilder) -> m ()
forall a b. (a -> b) -> a -> b
$ Builder -> CssBuilder
CssBuilder (Builder -> CssBuilder)
-> (RY site -> Builder) -> RY site -> CssBuilder
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> Builder
fromLazyText (Text -> Builder) -> (RY site -> Text) -> RY site -> Builder
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Css -> Text
renderCss (Css -> Text) -> (RY site -> Css) -> RY site -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Css -> RY site -> Css
forall a b. a -> b -> a
const Css
x
instance render ~ RY site => ToWidgetMedia site (render -> CssBuilder) where
toWidgetMedia :: Text -> (render -> CssBuilder) -> m ()
toWidgetMedia Text
media render -> CssBuilder
x = GWData (Route (HandlerSite m)) -> m ()
forall (m :: * -> *).
MonadWidget m =>
GWData (Route (HandlerSite m)) -> m ()
tell (GWData (Route (HandlerSite m)) -> m ())
-> GWData (Route (HandlerSite m)) -> m ()
forall a b. (a -> b) -> a -> b
$ Body (Route site)
-> Last Title
-> UniqueList (Script (Route site))
-> UniqueList (Stylesheet (Route site))
-> Map (Maybe Text) (CssBuilderUrl (Route site))
-> Maybe (JavascriptUrl (Route site))
-> Head (Route site)
-> GWData (Route site)
forall a.
Body a
-> Last Title
-> UniqueList (Script a)
-> UniqueList (Stylesheet a)
-> Map (Maybe Text) (CssBuilderUrl a)
-> Maybe (JavascriptUrl a)
-> Head a
-> GWData a
GWData Body (Route site)
forall a. Monoid a => a
mempty Last Title
forall a. Monoid a => a
mempty UniqueList (Script (Route site))
forall a. Monoid a => a
mempty UniqueList (Stylesheet (Route site))
forall a. Monoid a => a
mempty (Maybe Text
-> (render -> Builder) -> Map (Maybe Text) (render -> Builder)
forall k a. k -> a -> Map k a
Map.singleton (Text -> Maybe Text
forall a. a -> Maybe a
Just Text
media) ((render -> Builder) -> Map (Maybe Text) (render -> Builder))
-> (render -> Builder) -> Map (Maybe Text) (render -> Builder)
forall a b. (a -> b) -> a -> b
$ CssBuilder -> Builder
unCssBuilder (CssBuilder -> Builder)
-> (render -> CssBuilder) -> render -> Builder
forall b c a. (b -> c) -> (a -> b) -> a -> c
. render -> CssBuilder
x) Maybe (JavascriptUrl (Route site))
forall a. Monoid a => a
mempty Head (Route site)
forall a. Monoid a => a
mempty
instance ToWidgetMedia site CssBuilder where
toWidgetMedia :: Text -> CssBuilder -> m ()
toWidgetMedia Text
media CssBuilder
x = GWData (Route (HandlerSite m)) -> m ()
forall (m :: * -> *).
MonadWidget m =>
GWData (Route (HandlerSite m)) -> m ()
tell (GWData (Route (HandlerSite m)) -> m ())
-> GWData (Route (HandlerSite m)) -> m ()
forall a b. (a -> b) -> a -> b
$ Body (Route site)
-> Last Title
-> UniqueList (Script (Route site))
-> UniqueList (Stylesheet (Route site))
-> Map (Maybe Text) (CssBuilderUrl (Route site))
-> Maybe (JavascriptUrl (Route site))
-> Head (Route site)
-> GWData (Route site)
forall a.
Body a
-> Last Title
-> UniqueList (Script a)
-> UniqueList (Stylesheet a)
-> Map (Maybe Text) (CssBuilderUrl a)
-> Maybe (JavascriptUrl a)
-> Head a
-> GWData a
GWData Body (Route site)
forall a. Monoid a => a
mempty Last Title
forall a. Monoid a => a
mempty UniqueList (Script (Route site))
forall a. Monoid a => a
mempty UniqueList (Stylesheet (Route site))
forall a. Monoid a => a
mempty (Maybe Text
-> CssBuilderUrl (Route site)
-> Map (Maybe Text) (CssBuilderUrl (Route site))
forall k a. k -> a -> Map k a
Map.singleton (Text -> Maybe Text
forall a. a -> Maybe a
Just Text
media) (CssBuilderUrl (Route site)
-> Map (Maybe Text) (CssBuilderUrl (Route site)))
-> CssBuilderUrl (Route site)
-> Map (Maybe Text) (CssBuilderUrl (Route site))
forall a b. (a -> b) -> a -> b
$ CssBuilder -> Builder
unCssBuilder (CssBuilder -> Builder)
-> ((Route site -> [(Text, Text)] -> Text) -> CssBuilder)
-> CssBuilderUrl (Route site)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CssBuilder -> (Route site -> [(Text, Text)] -> Text) -> CssBuilder
forall a b. a -> b -> a
const CssBuilder
x) Maybe (JavascriptUrl (Route site))
forall a. Monoid a => a
mempty Head (Route site)
forall a. Monoid a => a
mempty
class ToWidgetBody site a where
toWidgetBody :: (MonadWidget m, HandlerSite m ~ site) => a -> m ()
instance render ~ RY site => ToWidgetBody site (render -> Html) where
toWidgetBody :: (render -> Html) -> m ()
toWidgetBody = (render -> Html) -> m ()
forall site a (m :: * -> *).
(ToWidget site a, MonadWidget m, HandlerSite m ~ site) =>
a -> m ()
toWidget
instance render ~ RY site => ToWidgetBody site (render -> Javascript) where
toWidgetBody :: (render -> Javascript) -> m ()
toWidgetBody render -> Javascript
j = ((Route site -> [(Text, Text)] -> Text) -> Html) -> m ()
forall site a (m :: * -> *).
(ToWidget site a, MonadWidget m, HandlerSite m ~ site) =>
a -> m ()
toWidget (((Route site -> [(Text, Text)] -> Text) -> Html) -> m ())
-> ((Route site -> [(Text, Text)] -> Text) -> Html) -> m ()
forall a b. (a -> b) -> a -> b
$ \Route site -> [(Text, Text)] -> Text
r -> Html -> Html
H.script (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ Text -> Html
preEscapedLazyText (Text -> Html) -> Text -> Html
forall a b. (a -> b) -> a -> b
$ (Route site -> [(Text, Text)] -> Text)
-> JavascriptUrl (Route site) -> Text
forall url.
(url -> [(Text, Text)] -> Text) -> JavascriptUrl url -> Text
renderJavascriptUrl Route site -> [(Text, Text)] -> Text
r render -> Javascript
JavascriptUrl (Route site)
j
instance ToWidgetBody site Javascript where
toWidgetBody :: Javascript -> m ()
toWidgetBody Javascript
j = (RY site -> Html) -> m ()
forall site a (m :: * -> *).
(ToWidget site a, MonadWidget m, HandlerSite m ~ site) =>
a -> m ()
toWidget ((RY site -> Html) -> m ()) -> (RY site -> Html) -> m ()
forall a b. (a -> b) -> a -> b
$ \RY site
_ -> Html -> Html
H.script (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ Text -> Html
preEscapedLazyText (Text -> Html) -> Text -> Html
forall a b. (a -> b) -> a -> b
$ Javascript -> Text
renderJavascript Javascript
j
instance ToWidgetBody site Html where
toWidgetBody :: Html -> m ()
toWidgetBody = Html -> m ()
forall site a (m :: * -> *).
(ToWidget site a, MonadWidget m, HandlerSite m ~ site) =>
a -> m ()
toWidget
class ToWidgetHead site a where
toWidgetHead :: (MonadWidget m, HandlerSite m ~ site) => a -> m ()
instance render ~ RY site => ToWidgetHead site (render -> Html) where
toWidgetHead :: (render -> Html) -> m ()
toWidgetHead = GWData (Route site) -> m ()
forall (m :: * -> *).
MonadWidget m =>
GWData (Route (HandlerSite m)) -> m ()
tell (GWData (Route site) -> m ())
-> (HtmlUrl (Route site) -> GWData (Route site))
-> HtmlUrl (Route site)
-> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Body (Route site)
-> Last Title
-> UniqueList (Script (Route site))
-> UniqueList (Stylesheet (Route site))
-> Map (Maybe Text) (CssBuilderUrl (Route site))
-> Maybe (JavascriptUrl (Route site))
-> Head (Route site)
-> GWData (Route site)
forall a.
Body a
-> Last Title
-> UniqueList (Script a)
-> UniqueList (Stylesheet a)
-> Map (Maybe Text) (CssBuilderUrl a)
-> Maybe (JavascriptUrl a)
-> Head a
-> GWData a
GWData Body (Route site)
forall a. Monoid a => a
mempty Last Title
forall a. Monoid a => a
mempty UniqueList (Script (Route site))
forall a. Monoid a => a
mempty UniqueList (Stylesheet (Route site))
forall a. Monoid a => a
mempty Map (Maybe Text) (CssBuilderUrl (Route site))
forall a. Monoid a => a
mempty Maybe (JavascriptUrl (Route site))
forall a. Monoid a => a
mempty (Head (Route site) -> GWData (Route site))
-> (HtmlUrl (Route site) -> Head (Route site))
-> HtmlUrl (Route site)
-> GWData (Route site)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HtmlUrl (Route site) -> Head (Route site)
forall url. HtmlUrl url -> Head url
Head
instance render ~ RY site => ToWidgetHead site (render -> Css) where
toWidgetHead :: (render -> Css) -> m ()
toWidgetHead = (render -> Css) -> m ()
forall site a (m :: * -> *).
(ToWidget site a, MonadWidget m, HandlerSite m ~ site) =>
a -> m ()
toWidget
instance ToWidgetHead site Css where
toWidgetHead :: Css -> m ()
toWidgetHead = Css -> m ()
forall site a (m :: * -> *).
(ToWidget site a, MonadWidget m, HandlerSite m ~ site) =>
a -> m ()
toWidget
instance render ~ RY site => ToWidgetHead site (render -> CssBuilder) where
toWidgetHead :: (render -> CssBuilder) -> m ()
toWidgetHead = (render -> CssBuilder) -> m ()
forall site a (m :: * -> *).
(ToWidget site a, MonadWidget m, HandlerSite m ~ site) =>
a -> m ()
toWidget
instance ToWidgetHead site CssBuilder where
toWidgetHead :: CssBuilder -> m ()
toWidgetHead = CssBuilder -> m ()
forall site a (m :: * -> *).
(ToWidget site a, MonadWidget m, HandlerSite m ~ site) =>
a -> m ()
toWidget
instance render ~ RY site => ToWidgetHead site (render -> Javascript) where
toWidgetHead :: (render -> Javascript) -> m ()
toWidgetHead render -> Javascript
j = ((Route site -> [(Text, Text)] -> Text) -> Html) -> m ()
forall site a (m :: * -> *).
(ToWidgetHead site a, MonadWidget m, HandlerSite m ~ site) =>
a -> m ()
toWidgetHead (((Route site -> [(Text, Text)] -> Text) -> Html) -> m ())
-> ((Route site -> [(Text, Text)] -> Text) -> Html) -> m ()
forall a b. (a -> b) -> a -> b
$ \Route site -> [(Text, Text)] -> Text
r -> Html -> Html
H.script (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ Text -> Html
preEscapedLazyText (Text -> Html) -> Text -> Html
forall a b. (a -> b) -> a -> b
$ (Route site -> [(Text, Text)] -> Text)
-> JavascriptUrl (Route site) -> Text
forall url.
(url -> [(Text, Text)] -> Text) -> JavascriptUrl url -> Text
renderJavascriptUrl Route site -> [(Text, Text)] -> Text
r render -> Javascript
JavascriptUrl (Route site)
j
instance ToWidgetHead site Javascript where
toWidgetHead :: Javascript -> m ()
toWidgetHead Javascript
j = (RY site -> Html) -> m ()
forall site a (m :: * -> *).
(ToWidgetHead site a, MonadWidget m, HandlerSite m ~ site) =>
a -> m ()
toWidgetHead ((RY site -> Html) -> m ()) -> (RY site -> Html) -> m ()
forall a b. (a -> b) -> a -> b
$ \RY site
_ -> Html -> Html
H.script (Html -> Html) -> Html -> Html
forall a b. (a -> b) -> a -> b
$ Text -> Html
preEscapedLazyText (Text -> Html) -> Text -> Html
forall a b. (a -> b) -> a -> b
$ Javascript -> Text
renderJavascript Javascript
j
instance ToWidgetHead site Html where
toWidgetHead :: Html -> m ()
toWidgetHead = (RY site -> Html) -> m ()
forall site a (m :: * -> *).
(ToWidgetHead site a, MonadWidget m, HandlerSite m ~ site) =>
a -> m ()
toWidgetHead ((RY site -> Html) -> m ())
-> (Html -> RY site -> Html) -> Html -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Html -> RY site -> Html
forall a b. a -> b -> a
const
setTitle :: MonadWidget m => Html -> m ()
setTitle :: Html -> m ()
setTitle Html
x = GWData (Route (HandlerSite m)) -> m ()
forall (m :: * -> *).
MonadWidget m =>
GWData (Route (HandlerSite m)) -> m ()
tell (GWData (Route (HandlerSite m)) -> m ())
-> GWData (Route (HandlerSite m)) -> m ()
forall a b. (a -> b) -> a -> b
$ Body (Route (HandlerSite m))
-> Last Title
-> UniqueList (Script (Route (HandlerSite m)))
-> UniqueList (Stylesheet (Route (HandlerSite m)))
-> Map (Maybe Text) (CssBuilderUrl (Route (HandlerSite m)))
-> Maybe (JavascriptUrl (Route (HandlerSite m)))
-> Head (Route (HandlerSite m))
-> GWData (Route (HandlerSite m))
forall a.
Body a
-> Last Title
-> UniqueList (Script a)
-> UniqueList (Stylesheet a)
-> Map (Maybe Text) (CssBuilderUrl a)
-> Maybe (JavascriptUrl a)
-> Head a
-> GWData a
GWData Body (Route (HandlerSite m))
forall a. Monoid a => a
mempty (Maybe Title -> Last Title
forall a. Maybe a -> Last a
Last (Maybe Title -> Last Title) -> Maybe Title -> Last Title
forall a b. (a -> b) -> a -> b
$ Title -> Maybe Title
forall a. a -> Maybe a
Just (Title -> Maybe Title) -> Title -> Maybe Title
forall a b. (a -> b) -> a -> b
$ Html -> Title
Title Html
x) UniqueList (Script (Route (HandlerSite m)))
forall a. Monoid a => a
mempty UniqueList (Stylesheet (Route (HandlerSite m)))
forall a. Monoid a => a
mempty Map (Maybe Text) (CssBuilderUrl (Route (HandlerSite m)))
forall a. Monoid a => a
mempty Maybe (JavascriptUrl (Route (HandlerSite m)))
forall a. Monoid a => a
mempty Head (Route (HandlerSite m))
forall a. Monoid a => a
mempty
setTitleI :: (MonadWidget m, RenderMessage (HandlerSite m) msg) => msg -> m ()
setTitleI :: msg -> m ()
setTitleI msg
msg = do
msg -> Text
mr <- m (msg -> Text)
forall (m :: * -> *) message.
(MonadHandler m, RenderMessage (HandlerSite m) message) =>
m (message -> Text)
getMessageRender
Html -> m ()
forall (m :: * -> *). MonadWidget m => Html -> m ()
setTitle (Html -> m ()) -> Html -> m ()
forall a b. (a -> b) -> a -> b
$ Text -> Html
forall a. ToMarkup a => a -> Html
toHtml (Text -> Html) -> Text -> Html
forall a b. (a -> b) -> a -> b
$ msg -> Text
mr msg
msg
setDescription :: MonadWidget m => Text -> m ()
setDescription :: Text -> m ()
setDescription Text
description =
(RY (HandlerSite m) -> Html) -> m ()
forall site a (m :: * -> *).
(ToWidgetHead site a, MonadWidget m, HandlerSite m ~ site) =>
a -> m ()
toWidgetHead ((RY (HandlerSite m) -> Html) -> m ())
-> (RY (HandlerSite m) -> Html) -> m ()
forall a b. (a -> b) -> a -> b
$ [hamlet|<meta name=description content=#{description}>|]
setDescriptionI
:: (MonadWidget m, RenderMessage (HandlerSite m) msg)
=> msg -> m ()
setDescriptionI :: msg -> m ()
setDescriptionI msg
msg = do
msg -> Text
mr <- m (msg -> Text)
forall (m :: * -> *) message.
(MonadHandler m, RenderMessage (HandlerSite m) message) =>
m (message -> Text)
getMessageRender
(RY (HandlerSite m) -> Html) -> m ()
forall site a (m :: * -> *).
(ToWidgetHead site a, MonadWidget m, HandlerSite m ~ site) =>
a -> m ()
toWidgetHead ((RY (HandlerSite m) -> Html) -> m ())
-> (RY (HandlerSite m) -> Html) -> m ()
forall a b. (a -> b) -> a -> b
$ [hamlet|<meta name=description content=#{mr msg}>|]
setOGType :: MonadWidget m => Text -> m ()
setOGType :: Text -> m ()
setOGType Text
a = (RY (HandlerSite m) -> Html) -> m ()
forall site a (m :: * -> *).
(ToWidgetHead site a, MonadWidget m, HandlerSite m ~ site) =>
a -> m ()
toWidgetHead ((RY (HandlerSite m) -> Html) -> m ())
-> (RY (HandlerSite m) -> Html) -> m ()
forall a b. (a -> b) -> a -> b
$ [hamlet|<meta property="og:type" content=#{a}>|]
setOGImage :: MonadWidget m => Text -> m ()
setOGImage :: Text -> m ()
setOGImage Text
a = (RY (HandlerSite m) -> Html) -> m ()
forall site a (m :: * -> *).
(ToWidgetHead site a, MonadWidget m, HandlerSite m ~ site) =>
a -> m ()
toWidgetHead ((RY (HandlerSite m) -> Html) -> m ())
-> (RY (HandlerSite m) -> Html) -> m ()
forall a b. (a -> b) -> a -> b
$ [hamlet|<meta property="og:image" content=#{a}>|]
addStylesheet :: MonadWidget m => Route (HandlerSite m) -> m ()
addStylesheet :: Route (HandlerSite m) -> m ()
addStylesheet = (Route (HandlerSite m) -> [(Text, Text)] -> m ())
-> [(Text, Text)] -> Route (HandlerSite m) -> m ()
forall a b c. (a -> b -> c) -> b -> a -> c
flip Route (HandlerSite m) -> [(Text, Text)] -> m ()
forall (m :: * -> *).
MonadWidget m =>
Route (HandlerSite m) -> [(Text, Text)] -> m ()
addStylesheetAttrs []
addStylesheetAttrs :: MonadWidget m
=> Route (HandlerSite m)
-> [(Text, Text)]
-> m ()
addStylesheetAttrs :: Route (HandlerSite m) -> [(Text, Text)] -> m ()
addStylesheetAttrs Route (HandlerSite m)
x [(Text, Text)]
y = GWData (Route (HandlerSite m)) -> m ()
forall (m :: * -> *).
MonadWidget m =>
GWData (Route (HandlerSite m)) -> m ()
tell (GWData (Route (HandlerSite m)) -> m ())
-> GWData (Route (HandlerSite m)) -> m ()
forall a b. (a -> b) -> a -> b
$ Body (Route (HandlerSite m))
-> Last Title
-> UniqueList (Script (Route (HandlerSite m)))
-> UniqueList (Stylesheet (Route (HandlerSite m)))
-> Map (Maybe Text) (CssBuilderUrl (Route (HandlerSite m)))
-> Maybe (JavascriptUrl (Route (HandlerSite m)))
-> Head (Route (HandlerSite m))
-> GWData (Route (HandlerSite m))
forall a.
Body a
-> Last Title
-> UniqueList (Script a)
-> UniqueList (Stylesheet a)
-> Map (Maybe Text) (CssBuilderUrl a)
-> Maybe (JavascriptUrl a)
-> Head a
-> GWData a
GWData Body (Route (HandlerSite m))
forall a. Monoid a => a
mempty Last Title
forall a. Monoid a => a
mempty UniqueList (Script (Route (HandlerSite m)))
forall a. Monoid a => a
mempty (Stylesheet (Route (HandlerSite m))
-> UniqueList (Stylesheet (Route (HandlerSite m)))
forall x. x -> UniqueList x
toUnique (Stylesheet (Route (HandlerSite m))
-> UniqueList (Stylesheet (Route (HandlerSite m))))
-> Stylesheet (Route (HandlerSite m))
-> UniqueList (Stylesheet (Route (HandlerSite m)))
forall a b. (a -> b) -> a -> b
$ Location (Route (HandlerSite m))
-> [(Text, Text)] -> Stylesheet (Route (HandlerSite m))
forall url. Location url -> [(Text, Text)] -> Stylesheet url
Stylesheet (Route (HandlerSite m) -> Location (Route (HandlerSite m))
forall url. url -> Location url
Local Route (HandlerSite m)
x) [(Text, Text)]
y) Map (Maybe Text) (CssBuilderUrl (Route (HandlerSite m)))
forall a. Monoid a => a
mempty Maybe (JavascriptUrl (Route (HandlerSite m)))
forall a. Monoid a => a
mempty Head (Route (HandlerSite m))
forall a. Monoid a => a
mempty
addStylesheetRemote :: MonadWidget m => Text -> m ()
addStylesheetRemote :: Text -> m ()
addStylesheetRemote = (Text -> [(Text, Text)] -> m ()) -> [(Text, Text)] -> Text -> m ()
forall a b c. (a -> b -> c) -> b -> a -> c
flip Text -> [(Text, Text)] -> m ()
forall (m :: * -> *).
MonadWidget m =>
Text -> [(Text, Text)] -> m ()
addStylesheetRemoteAttrs []
addStylesheetRemoteAttrs :: MonadWidget m => Text -> [(Text, Text)] -> m ()
addStylesheetRemoteAttrs :: Text -> [(Text, Text)] -> m ()
addStylesheetRemoteAttrs Text
x [(Text, Text)]
y = GWData (Route (HandlerSite m)) -> m ()
forall (m :: * -> *).
MonadWidget m =>
GWData (Route (HandlerSite m)) -> m ()
tell (GWData (Route (HandlerSite m)) -> m ())
-> GWData (Route (HandlerSite m)) -> m ()
forall a b. (a -> b) -> a -> b
$ Body (Route (HandlerSite m))
-> Last Title
-> UniqueList (Script (Route (HandlerSite m)))
-> UniqueList (Stylesheet (Route (HandlerSite m)))
-> Map (Maybe Text) (CssBuilderUrl (Route (HandlerSite m)))
-> Maybe (JavascriptUrl (Route (HandlerSite m)))
-> Head (Route (HandlerSite m))
-> GWData (Route (HandlerSite m))
forall a.
Body a
-> Last Title
-> UniqueList (Script a)
-> UniqueList (Stylesheet a)
-> Map (Maybe Text) (CssBuilderUrl a)
-> Maybe (JavascriptUrl a)
-> Head a
-> GWData a
GWData Body (Route (HandlerSite m))
forall a. Monoid a => a
mempty Last Title
forall a. Monoid a => a
mempty UniqueList (Script (Route (HandlerSite m)))
forall a. Monoid a => a
mempty (Stylesheet (Route (HandlerSite m))
-> UniqueList (Stylesheet (Route (HandlerSite m)))
forall x. x -> UniqueList x
toUnique (Stylesheet (Route (HandlerSite m))
-> UniqueList (Stylesheet (Route (HandlerSite m))))
-> Stylesheet (Route (HandlerSite m))
-> UniqueList (Stylesheet (Route (HandlerSite m)))
forall a b. (a -> b) -> a -> b
$ Location (Route (HandlerSite m))
-> [(Text, Text)] -> Stylesheet (Route (HandlerSite m))
forall url. Location url -> [(Text, Text)] -> Stylesheet url
Stylesheet (Text -> Location (Route (HandlerSite m))
forall url. Text -> Location url
Remote Text
x) [(Text, Text)]
y) Map (Maybe Text) (CssBuilderUrl (Route (HandlerSite m)))
forall a. Monoid a => a
mempty Maybe (JavascriptUrl (Route (HandlerSite m)))
forall a. Monoid a => a
mempty Head (Route (HandlerSite m))
forall a. Monoid a => a
mempty
addStylesheetEither :: MonadWidget m
=> Either (Route (HandlerSite m)) Text
-> m ()
addStylesheetEither :: Either (Route (HandlerSite m)) Text -> m ()
addStylesheetEither = (Route (HandlerSite m) -> m ())
-> (Text -> m ()) -> Either (Route (HandlerSite m)) Text -> m ()
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either Route (HandlerSite m) -> m ()
forall (m :: * -> *).
MonadWidget m =>
Route (HandlerSite m) -> m ()
addStylesheet Text -> m ()
forall (m :: * -> *). MonadWidget m => Text -> m ()
addStylesheetRemote
addScriptEither :: MonadWidget m
=> Either (Route (HandlerSite m)) Text
-> m ()
addScriptEither :: Either (Route (HandlerSite m)) Text -> m ()
addScriptEither = (Route (HandlerSite m) -> m ())
-> (Text -> m ()) -> Either (Route (HandlerSite m)) Text -> m ()
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either Route (HandlerSite m) -> m ()
forall (m :: * -> *).
MonadWidget m =>
Route (HandlerSite m) -> m ()
addScript Text -> m ()
forall (m :: * -> *). MonadWidget m => Text -> m ()
addScriptRemote
addScript :: MonadWidget m => Route (HandlerSite m) -> m ()
addScript :: Route (HandlerSite m) -> m ()
addScript = (Route (HandlerSite m) -> [(Text, Text)] -> m ())
-> [(Text, Text)] -> Route (HandlerSite m) -> m ()
forall a b c. (a -> b -> c) -> b -> a -> c
flip Route (HandlerSite m) -> [(Text, Text)] -> m ()
forall (m :: * -> *).
MonadWidget m =>
Route (HandlerSite m) -> [(Text, Text)] -> m ()
addScriptAttrs []
addScriptAttrs :: MonadWidget m => Route (HandlerSite m) -> [(Text, Text)] -> m ()
addScriptAttrs :: Route (HandlerSite m) -> [(Text, Text)] -> m ()
addScriptAttrs Route (HandlerSite m)
x [(Text, Text)]
y = GWData (Route (HandlerSite m)) -> m ()
forall (m :: * -> *).
MonadWidget m =>
GWData (Route (HandlerSite m)) -> m ()
tell (GWData (Route (HandlerSite m)) -> m ())
-> GWData (Route (HandlerSite m)) -> m ()
forall a b. (a -> b) -> a -> b
$ Body (Route (HandlerSite m))
-> Last Title
-> UniqueList (Script (Route (HandlerSite m)))
-> UniqueList (Stylesheet (Route (HandlerSite m)))
-> Map (Maybe Text) (CssBuilderUrl (Route (HandlerSite m)))
-> Maybe (JavascriptUrl (Route (HandlerSite m)))
-> Head (Route (HandlerSite m))
-> GWData (Route (HandlerSite m))
forall a.
Body a
-> Last Title
-> UniqueList (Script a)
-> UniqueList (Stylesheet a)
-> Map (Maybe Text) (CssBuilderUrl a)
-> Maybe (JavascriptUrl a)
-> Head a
-> GWData a
GWData Body (Route (HandlerSite m))
forall a. Monoid a => a
mempty Last Title
forall a. Monoid a => a
mempty (Script (Route (HandlerSite m))
-> UniqueList (Script (Route (HandlerSite m)))
forall x. x -> UniqueList x
toUnique (Script (Route (HandlerSite m))
-> UniqueList (Script (Route (HandlerSite m))))
-> Script (Route (HandlerSite m))
-> UniqueList (Script (Route (HandlerSite m)))
forall a b. (a -> b) -> a -> b
$ Location (Route (HandlerSite m))
-> [(Text, Text)] -> Script (Route (HandlerSite m))
forall url. Location url -> [(Text, Text)] -> Script url
Script (Route (HandlerSite m) -> Location (Route (HandlerSite m))
forall url. url -> Location url
Local Route (HandlerSite m)
x) [(Text, Text)]
y) UniqueList (Stylesheet (Route (HandlerSite m)))
forall a. Monoid a => a
mempty Map (Maybe Text) (CssBuilderUrl (Route (HandlerSite m)))
forall a. Monoid a => a
mempty Maybe (JavascriptUrl (Route (HandlerSite m)))
forall a. Monoid a => a
mempty Head (Route (HandlerSite m))
forall a. Monoid a => a
mempty
addScriptRemote :: MonadWidget m => Text -> m ()
addScriptRemote :: Text -> m ()
addScriptRemote = (Text -> [(Text, Text)] -> m ()) -> [(Text, Text)] -> Text -> m ()
forall a b c. (a -> b -> c) -> b -> a -> c
flip Text -> [(Text, Text)] -> m ()
forall (m :: * -> *).
MonadWidget m =>
Text -> [(Text, Text)] -> m ()
addScriptRemoteAttrs []
addScriptRemoteAttrs :: MonadWidget m => Text -> [(Text, Text)] -> m ()
addScriptRemoteAttrs :: Text -> [(Text, Text)] -> m ()
addScriptRemoteAttrs Text
x [(Text, Text)]
y = GWData (Route (HandlerSite m)) -> m ()
forall (m :: * -> *).
MonadWidget m =>
GWData (Route (HandlerSite m)) -> m ()
tell (GWData (Route (HandlerSite m)) -> m ())
-> GWData (Route (HandlerSite m)) -> m ()
forall a b. (a -> b) -> a -> b
$ Body (Route (HandlerSite m))
-> Last Title
-> UniqueList (Script (Route (HandlerSite m)))
-> UniqueList (Stylesheet (Route (HandlerSite m)))
-> Map (Maybe Text) (CssBuilderUrl (Route (HandlerSite m)))
-> Maybe (JavascriptUrl (Route (HandlerSite m)))
-> Head (Route (HandlerSite m))
-> GWData (Route (HandlerSite m))
forall a.
Body a
-> Last Title
-> UniqueList (Script a)
-> UniqueList (Stylesheet a)
-> Map (Maybe Text) (CssBuilderUrl a)
-> Maybe (JavascriptUrl a)
-> Head a
-> GWData a
GWData Body (Route (HandlerSite m))
forall a. Monoid a => a
mempty Last Title
forall a. Monoid a => a
mempty (Script (Route (HandlerSite m))
-> UniqueList (Script (Route (HandlerSite m)))
forall x. x -> UniqueList x
toUnique (Script (Route (HandlerSite m))
-> UniqueList (Script (Route (HandlerSite m))))
-> Script (Route (HandlerSite m))
-> UniqueList (Script (Route (HandlerSite m)))
forall a b. (a -> b) -> a -> b
$ Location (Route (HandlerSite m))
-> [(Text, Text)] -> Script (Route (HandlerSite m))
forall url. Location url -> [(Text, Text)] -> Script url
Script (Text -> Location (Route (HandlerSite m))
forall url. Text -> Location url
Remote Text
x) [(Text, Text)]
y) UniqueList (Stylesheet (Route (HandlerSite m)))
forall a. Monoid a => a
mempty Map (Maybe Text) (CssBuilderUrl (Route (HandlerSite m)))
forall a. Monoid a => a
mempty Maybe (JavascriptUrl (Route (HandlerSite m)))
forall a. Monoid a => a
mempty Head (Route (HandlerSite m))
forall a. Monoid a => a
mempty
whamlet :: QuasiQuoter
whamlet :: QuasiQuoter
whamlet = Q HamletRules -> HamletSettings -> QuasiQuoter
NP.hamletWithSettings Q HamletRules
rules HamletSettings
NP.defaultHamletSettings
whamletFile :: FilePath -> Q Exp
whamletFile :: FilePath -> Q Exp
whamletFile = Q HamletRules -> HamletSettings -> FilePath -> Q Exp
NP.hamletFileWithSettings Q HamletRules
rules HamletSettings
NP.defaultHamletSettings
whamletFileWithSettings :: NP.HamletSettings -> FilePath -> Q Exp
whamletFileWithSettings :: HamletSettings -> FilePath -> Q Exp
whamletFileWithSettings = Q HamletRules -> HamletSettings -> FilePath -> Q Exp
NP.hamletFileWithSettings Q HamletRules
rules
asWidgetT :: WidgetT site m () -> WidgetT site m ()
asWidgetT :: WidgetT site m () -> WidgetT site m ()
asWidgetT = WidgetT site m () -> WidgetT site m ()
forall a. a -> a
id
rules :: Q NP.HamletRules
rules :: Q HamletRules
rules = do
Exp
ah <- [|asWidgetT . toWidget|]
let helper :: Q Exp -> (Exp -> Q Exp) -> Q Exp
helper Q Exp
qg Exp -> Q Exp
f = do
Name
x <- FilePath -> Q Name
newName FilePath
"urender"
Exp
e <- Exp -> Q Exp
f (Exp -> Q Exp) -> Exp -> Q Exp
forall a b. (a -> b) -> a -> b
$ Name -> Exp
VarE Name
x
let e' :: Exp
e' = [Pat] -> Exp -> Exp
LamE [Name -> Pat
VarP Name
x] Exp
e
Exp
g <- Q Exp
qg
Exp
bind <- [|(>>=)|]
Exp -> Q Exp
forall (m :: * -> *) a. Monad m => a -> m a
return (Exp -> Q Exp) -> Exp -> Q Exp
forall a b. (a -> b) -> a -> b
$ Maybe Exp -> Exp -> Maybe Exp -> Exp
InfixE (Exp -> Maybe Exp
forall a. a -> Maybe a
Just Exp
g) Exp
bind (Exp -> Maybe Exp
forall a. a -> Maybe a
Just Exp
e')
let ur :: (Env -> t) -> t
ur Env -> t
f = do
let env :: Env
env = Maybe ((Exp -> Q Exp) -> Q Exp)
-> Maybe ((Exp -> Q Exp) -> Q Exp) -> Env
NP.Env
(((Exp -> Q Exp) -> Q Exp) -> Maybe ((Exp -> Q Exp) -> Q Exp)
forall a. a -> Maybe a
Just (((Exp -> Q Exp) -> Q Exp) -> Maybe ((Exp -> Q Exp) -> Q Exp))
-> ((Exp -> Q Exp) -> Q Exp) -> Maybe ((Exp -> Q Exp) -> Q Exp)
forall a b. (a -> b) -> a -> b
$ Q Exp -> (Exp -> Q Exp) -> Q Exp
helper [|getUrlRenderParams|])
(((Exp -> Q Exp) -> Q Exp) -> Maybe ((Exp -> Q Exp) -> Q Exp)
forall a. a -> Maybe a
Just (((Exp -> Q Exp) -> Q Exp) -> Maybe ((Exp -> Q Exp) -> Q Exp))
-> ((Exp -> Q Exp) -> Q Exp) -> Maybe ((Exp -> Q Exp) -> Q Exp)
forall a b. (a -> b) -> a -> b
$ Q Exp -> (Exp -> Q Exp) -> Q Exp
helper [|fmap (toHtml .) getMessageRender|])
Env -> t
f Env
env
HamletRules -> Q HamletRules
forall (m :: * -> *) a. Monad m => a -> m a
return (HamletRules -> Q HamletRules) -> HamletRules -> Q HamletRules
forall a b. (a -> b) -> a -> b
$ Exp
-> ((Env -> Q Exp) -> Q Exp)
-> (Env -> Exp -> Q Exp)
-> HamletRules
NP.HamletRules Exp
ah (Env -> Q Exp) -> Q Exp
forall t. (Env -> t) -> t
ur ((Env -> Exp -> Q Exp) -> HamletRules)
-> (Env -> Exp -> Q Exp) -> HamletRules
forall a b. (a -> b) -> a -> b
$ \Env
_ Exp
b -> Exp -> Q Exp
forall (m :: * -> *) a. Monad m => a -> m a
return (Exp -> Q Exp) -> Exp -> Q Exp
forall a b. (a -> b) -> a -> b
$ Exp
ah Exp -> Exp -> Exp
`AppE` Exp
b
ihamletToRepHtml :: (MonadHandler m, RenderMessage (HandlerSite m) message)
=> HtmlUrlI18n message (Route (HandlerSite m))
-> m Html
ihamletToRepHtml :: HtmlUrlI18n message (Route (HandlerSite m)) -> m Html
ihamletToRepHtml = HtmlUrlI18n message (Route (HandlerSite m)) -> m Html
forall (m :: * -> *) message.
(MonadHandler m, RenderMessage (HandlerSite m) message) =>
HtmlUrlI18n message (Route (HandlerSite m)) -> m Html
ihamletToHtml
{-# DEPRECATED ihamletToRepHtml "Please use ihamletToHtml instead" #-}
ihamletToHtml :: (MonadHandler m, RenderMessage (HandlerSite m) message)
=> HtmlUrlI18n message (Route (HandlerSite m))
-> m Html
ihamletToHtml :: HtmlUrlI18n message (Route (HandlerSite m)) -> m Html
ihamletToHtml HtmlUrlI18n message (Route (HandlerSite m))
ih = do
Route (HandlerSite m) -> [(Text, Text)] -> Text
urender <- m (Route (HandlerSite m) -> [(Text, Text)] -> Text)
forall (m :: * -> *).
MonadHandler m =>
m (Route (HandlerSite m) -> [(Text, Text)] -> Text)
getUrlRenderParams
message -> Text
mrender <- m (message -> Text)
forall (m :: * -> *) message.
(MonadHandler m, RenderMessage (HandlerSite m) message) =>
m (message -> Text)
getMessageRender
Html -> m Html
forall (m :: * -> *) a. Monad m => a -> m a
return (Html -> m Html) -> Html -> m Html
forall a b. (a -> b) -> a -> b
$ HtmlUrlI18n message (Route (HandlerSite m))
ih (Text -> Html
forall a. ToMarkup a => a -> Html
toHtml (Text -> Html) -> (message -> Text) -> message -> Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. message -> Text
mrender) Route (HandlerSite m) -> [(Text, Text)] -> Text
urender
tell :: MonadWidget m => GWData (Route (HandlerSite m)) -> m ()
tell :: GWData (Route (HandlerSite m)) -> m ()
tell = WidgetFor (HandlerSite m) () -> m ()
forall (m :: * -> *) a.
MonadWidget m =>
WidgetFor (HandlerSite m) a -> m a
liftWidget (WidgetFor (HandlerSite m) () -> m ())
-> (GWData (Route (HandlerSite m)) -> WidgetFor (HandlerSite m) ())
-> GWData (Route (HandlerSite m))
-> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GWData (Route (HandlerSite m)) -> WidgetFor (HandlerSite m) ()
forall site. GWData (Route site) -> WidgetFor site ()
tellWidget
toUnique :: x -> UniqueList x
toUnique :: x -> UniqueList x
toUnique = ([x] -> [x]) -> UniqueList x
forall x. ([x] -> [x]) -> UniqueList x
UniqueList (([x] -> [x]) -> UniqueList x)
-> (x -> [x] -> [x]) -> x -> UniqueList x
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (:)
handlerToWidget :: HandlerFor site a -> WidgetFor site a
handlerToWidget :: HandlerFor site a -> WidgetFor site a
handlerToWidget (HandlerFor HandlerData site site -> IO a
f) = (WidgetData site -> IO a) -> WidgetFor site a
forall site a. (WidgetData site -> IO a) -> WidgetFor site a
WidgetFor ((WidgetData site -> IO a) -> WidgetFor site a)
-> (WidgetData site -> IO a) -> WidgetFor site a
forall a b. (a -> b) -> a -> b
$ HandlerData site site -> IO a
f (HandlerData site site -> IO a)
-> (WidgetData site -> HandlerData site site)
-> WidgetData site
-> IO a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WidgetData site -> HandlerData site site
forall site. WidgetData site -> HandlerData site site
wdHandler