Widgets combine HTML with JS and CSS dependencies with a unique identifier generator, allowing you to create truly modular HTML components.
- type GWidget s m = GGWidget m (GHandler s m)
- newtype GGWidget m monad a = GWidget {
- unGWidget :: GWInner m monad a
- data PageContent url = PageContent {}
- whamlet :: QuasiQuoter
- whamletFile :: FilePath -> Q Exp
- ihamletToRepHtml :: (Monad mo, RenderMessage master message) => HtmlUrlI18n message (Route master) -> GGHandler sub master mo 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 :: Monad m => Html -> GGWidget master m ()
- setTitleI :: (RenderMessage master msg, Monad m) => msg -> GGWidget master (GGHandler sub master m) ()
- addHamletHead :: Monad m => HtmlUrl (Route master) -> GGWidget master m ()
- addHtmlHead :: Monad m => Html -> GGWidget master m ()
- addHamlet :: Monad m => HtmlUrl (Route master) -> GGWidget master m ()
- addHtml :: Monad m => Html -> GGWidget master m ()
- addWidget :: Monad mo => GGWidget m mo () -> GGWidget m mo ()
- addSubWidget :: YesodSubRoute sub master => sub -> GWidget sub master a -> GWidget sub' master a
- addCassius :: Monad m => CssUrl (Route master) -> GGWidget master m ()
- addCassiusMedia :: Monad m => Text -> CssUrl (Route master) -> GGWidget master m ()
- addLucius :: Monad m => CssUrl (Route master) -> GGWidget master m ()
- addLuciusMedia :: Monad m => Text -> CssUrl (Route master) -> GGWidget master m ()
- addStylesheet :: Monad m => Route master -> GGWidget master m ()
- addStylesheetAttrs :: Monad m => Route master -> [(Text, Text)] -> GGWidget master m ()
- addStylesheetRemote :: Monad m => Text -> GGWidget master m ()
- addStylesheetRemoteAttrs :: Monad m => Text -> [(Text, Text)] -> GGWidget master m ()
- addStylesheetEither :: Monad m => Either (Route master) Text -> GGWidget master m ()
- addJulius :: Monad m => JavascriptUrl (Route master) -> GGWidget master m ()
- addJuliusBody :: Monad m => JavascriptUrl (Route master) -> GGWidget master m ()
- addCoffee :: MonadIO m => CoffeeUrl (Route master) -> GGWidget master (GGHandler sub master m) ()
- addCoffeeBody :: MonadIO m => CoffeeUrl (Route master) -> GGWidget master (GGHandler sub master m) ()
- addScript :: Monad m => Route master -> GGWidget master m ()
- addScriptAttrs :: Monad m => Route master -> [(Text, Text)] -> GGWidget master m ()
- addScriptRemote :: Monad m => Text -> GGWidget master m ()
- addScriptRemoteAttrs :: Monad m => Text -> [(Text, Text)] -> GGWidget master m ()
- addScriptEither :: Monad m => Either (Route master) Text -> GGWidget master m ()
- extractBody :: Monad mo => GGWidget m mo () -> GGWidget m mo (HtmlUrl (Route m))
Datatype
newtype GGWidget m monad a Source
A generic widget, allowing specification of both the subsite and master
site datatypes. This is basically a large WriterT
stack keeping track of
dependencies along with a StateT
to track unique identifiers.
ToWidget sub master (GWidget sub master ()) | |
MonadTrans (GGWidget m) | |
Monad monad => Monad (GGWidget m monad) | |
Functor monad => Functor (GGWidget m monad) | |
(Monad monad, Functor monad) => Applicative (GGWidget m monad) | |
MonadIO monad => MonadIO (GGWidget m monad) | |
MonadControlIO monad => MonadControlIO (GGWidget m monad) | |
(a ~ (), Monad monad) => Monoid (GGWidget master monad 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 :: (Monad mo, RenderMessage master message) => HtmlUrlI18n message (Route master) -> GGHandler sub master mo RepHtmlSource
Wraps the Content
generated by hamletToContent
in a RepHtml
.
Convert to Widget
class ToWidget sub master a whereSource
ToWidget sub master Html | |
render ~ RY master => ToWidget sub master (render -> Coffeescript) | |
render ~ RY master => ToWidget sub master (render -> Javascript) | |
render ~ RY master => ToWidget sub master (render -> Css) | |
render ~ RY master => ToWidget sub master (render -> Html) | |
ToWidget sub master (GWidget sub master ()) |
class ToWidgetHead sub master a whereSource
toWidgetHead :: a -> GWidget sub master ()Source
ToWidgetHead sub master Html | |
render ~ RY master => ToWidgetHead sub master (render -> Coffeescript) | |
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 -> Coffeescript) | |
render ~ RY master => ToWidgetBody sub master (render -> Javascript) | |
render ~ RY master => ToWidgetBody sub master (render -> Html) |
Creating
Head of page
setTitle :: Monad m => Html -> GGWidget master m ()Source
Set the page title. Calling setTitle
multiple times overrides previously
set values.
setTitleI :: (RenderMessage master msg, Monad m) => msg -> GGWidget master (GGHandler sub master m) ()Source
Set the page title. Calling setTitle
multiple times overrides previously
set values.
addHamletHead :: Monad m => HtmlUrl (Route master) -> GGWidget master m ()Source
Add a Hamlet
to the head tag.
Body
addHamlet :: Monad m => HtmlUrl (Route master) -> GGWidget master m ()Source
Add a Hamlet
to the body tag.
addWidget :: Monad mo => GGWidget m mo () -> GGWidget m mo ()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 :: Monad m => CssUrl (Route master) -> GGWidget master m ()Source
Add some raw CSS to the style tag. Applies to all media types.
addCassiusMedia :: Monad m => Text -> CssUrl (Route master) -> GGWidget master m ()Source
Add some raw CSS to the style tag, for a specific media type.
addLuciusMedia :: Monad m => Text -> CssUrl (Route master) -> GGWidget master m ()Source
Identical to addCassiusMedia
.
addStylesheet :: Monad m => Route master -> GGWidget master m ()Source
Link to the specified local stylesheet.
addStylesheetAttrs :: Monad m => Route master -> [(Text, Text)] -> GGWidget master m ()Source
Link to the specified local stylesheet.
addStylesheetRemote :: Monad m => Text -> GGWidget master m ()Source
Link to the specified remote stylesheet.
addStylesheetRemoteAttrs :: Monad m => Text -> [(Text, Text)] -> GGWidget master m ()Source
Link to the specified remote stylesheet.
Javascript
addJulius :: Monad m => JavascriptUrl (Route master) -> GGWidget master m ()Source
Include raw Javascript in the page's script tag.
addJuliusBody :: Monad m => JavascriptUrl (Route master) -> GGWidget master m ()Source
Add a new script tag to the body with the contents of this Julius
template.
addCoffee :: MonadIO m => CoffeeUrl (Route master) -> GGWidget master (GGHandler sub master m) ()Source
Add Coffesscript to the page's script tag. Requires the coffeescript executable to be present at runtime.
addCoffeeBody :: MonadIO m => CoffeeUrl (Route master) -> GGWidget master (GGHandler sub master m) ()Source
Add a new script tag to the body with the contents of this Coffesscript template. Requires the coffeescript executable to be present at runtime.
addScript :: Monad m => Route master -> GGWidget master m ()Source
Link to the specified local script.
addScriptAttrs :: Monad m => Route master -> [(Text, Text)] -> GGWidget master m ()Source
Link to the specified local script.
addScriptRemote :: Monad m => Text -> GGWidget master m ()Source
Link to the specified remote script.
addScriptRemoteAttrs :: Monad m => Text -> [(Text, Text)] -> GGWidget master m ()Source
Link to the specified remote script.