Safe Haskell | None |
---|
Widgets combine HTML with JS and CSS dependencies with a unique identifier generator, allowing you to create truly modular HTML components.
- data GWidget sub master a
- data PageContent url = PageContent {}
- whamlet :: QuasiQuoter
- whamletFile :: FilePath -> Q Exp
- ihamletToRepHtml :: RenderMessage master message => HtmlUrlI18n message (Route master) -> GHandler sub master RepHtml
- class ToWidget sub master a where
- class ToWidgetHead sub master a where
- toWidgetHead :: a -> GWidget sub master ()
- class ToWidgetBody sub master a where
- toWidgetBody :: a -> GWidget sub master ()
- setTitle :: Html -> GWidget sub master ()
- setTitleI :: RenderMessage master msg => msg -> GWidget sub master ()
- addHamletHead :: HtmlUrl (Route master) -> GWidget sub master ()
- addHtmlHead :: Html -> GWidget sub master ()
- addHamlet :: HtmlUrl (Route master) -> GWidget sub master ()
- addHtml :: Html -> GWidget sub master ()
- addWidget :: GWidget sub master () -> GWidget sub master ()
- addSubWidget :: YesodSubRoute sub master => sub -> GWidget sub master a -> GWidget sub' master a
- addCassius :: CssUrl (Route master) -> GWidget sub master ()
- addCassiusMedia :: Text -> CssUrl (Route master) -> GWidget sub master ()
- addLucius :: CssUrl (Route master) -> GWidget sub master ()
- addLuciusMedia :: Text -> CssUrl (Route master) -> GWidget sub master ()
- addStylesheet :: Route master -> GWidget sub master ()
- addStylesheetAttrs :: Route master -> [(Text, Text)] -> GWidget sub master ()
- addStylesheetRemote :: Text -> GWidget sub master ()
- addStylesheetRemoteAttrs :: Text -> [(Text, Text)] -> GWidget sub master ()
- addStylesheetEither :: Either (Route master) Text -> GWidget sub master ()
- addJulius :: JavascriptUrl (Route master) -> GWidget sub master ()
- addJuliusBody :: JavascriptUrl (Route master) -> GWidget sub master ()
- addScript :: Route master -> GWidget sub master ()
- addScriptAttrs :: Route master -> [(Text, Text)] -> GWidget sub master ()
- addScriptRemote :: Text -> GWidget sub master ()
- addScriptRemoteAttrs :: Text -> [(Text, Text)] -> GWidget sub master ()
- addScriptEither :: Either (Route master) Text -> GWidget sub master ()
- unGWidget :: GWidget sub master a -> GHandler sub master (a, GWData (Route master))
Datatype
data GWidget sub master a Source
A generic widget, allowing specification of both the subsite and master
site datatypes. While this is simply a WriterT
, we define a newtype for
better error messages.
ToWidget sub master (GWidget sub master ()) | |
MonadBase IO (GWidget sub master) | |
MonadBaseControl IO (GWidget sub master) | |
Monad (GWidget sub master) | |
Functor (GWidget sub master) | |
Applicative (GWidget sub master) | |
Resource (GWidget sub master) | |
ResourceUnsafeIO (GWidget sub master) | |
ResourceIO (GWidget sub master) | |
ResourceThrow (GWidget sub master) | |
MonadIO (GWidget sub master) | |
MonadLift (GHandler sub master) (GWidget sub master) | |
~ * a () => Monoid (GWidget sub master a) |
data PageContent url Source
Content for a web page. By providing this datatype, we can easily create generic site templates, which would have the type signature:
PageContent url -> HtmlUrl url
Special Hamlet quasiquoter/TH for Widgets
whamletFile :: FilePath -> Q ExpSource
ihamletToRepHtml :: RenderMessage master message => HtmlUrlI18n message (Route master) -> GHandler sub master RepHtmlSource
Wraps the Content
generated by hamletToContent
in a RepHtml
.
Convert to Widget
class ToWidgetHead sub master a whereSource
toWidgetHead :: a -> GWidget sub master ()Source
ToWidgetHead sub master Html | |
~ * render (RY master) => ToWidgetHead sub master (render -> Javascript) | |
~ * render (RY master) => ToWidgetHead sub master (render -> Css) | |
~ * render (RY master) => ToWidgetHead sub master (render -> Html) |
class ToWidgetBody sub master a whereSource
toWidgetBody :: a -> GWidget sub master ()Source
ToWidgetBody sub master Html | |
~ * render (RY master) => ToWidgetBody sub master (render -> Javascript) | |
~ * render (RY master) => ToWidgetBody sub master (render -> Html) |
Creating
Head of page
setTitle :: Html -> GWidget sub master ()Source
Set the page title. Calling setTitle
multiple times overrides previously
set values.
setTitleI :: RenderMessage master msg => msg -> GWidget sub master ()Source
Set the page title. Calling setTitle
multiple times overrides previously
set values.
Body
addWidget :: GWidget sub master () -> GWidget sub master ()Source
Add another widget. This is defined as id
, by can help with types, and
makes widget blocks look more consistent.
addSubWidget :: YesodSubRoute sub master => sub -> GWidget sub master a -> GWidget sub' master aSource
CSS
addCassius :: CssUrl (Route master) -> GWidget sub master ()Source
Add some raw CSS to the style tag. Applies to all media types.
addCassiusMedia :: Text -> CssUrl (Route master) -> GWidget sub master ()Source
Add some raw CSS to the style tag, for a specific media type.
addLuciusMedia :: Text -> CssUrl (Route master) -> GWidget sub master ()Source
Identical to addCassiusMedia
.
addStylesheet :: Route master -> GWidget sub master ()Source
Link to the specified local stylesheet.
addStylesheetAttrs :: Route master -> [(Text, Text)] -> GWidget sub master ()Source
Link to the specified local stylesheet.
addStylesheetRemote :: Text -> GWidget sub master ()Source
Link to the specified remote stylesheet.
addStylesheetRemoteAttrs :: Text -> [(Text, Text)] -> GWidget sub master ()Source
Link to the specified remote stylesheet.
Javascript
addJulius :: JavascriptUrl (Route master) -> GWidget sub master ()Source
Include raw Javascript in the page's script tag.
addJuliusBody :: JavascriptUrl (Route master) -> GWidget sub master ()Source
Add a new script tag to the body with the contents of this Julius
template.
addScriptAttrs :: Route master -> [(Text, Text)] -> GWidget sub master ()Source
Link to the specified local script.
addScriptRemote :: Text -> GWidget sub master ()Source
Link to the specified remote script.
addScriptRemoteAttrs :: Text -> [(Text, Text)] -> GWidget sub master ()Source
Link to the specified remote script.