{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
module DOM (
      HasContent(..)
    , htmlDocument
  ) where

import Article (Article)
import qualified Article (preview)
import ArticlesList (
    ArticlesList(..), description, getArticles, otherURL, rssLinkTexts
  )
import Blog (Blog(..), Skin(..), URL(..), template)
import Control.Monad.Reader (ReaderT, asks)
import Data.Map as Map (Map, toList)
import Data.Text (Text, pack, empty)
import DOM.Card (HasCard)
import qualified DOM.Card as Card (make)
import Files (absoluteLink)
import Lucid (
      HtmlT, a_, article_, body_, charset_, class_, div_, doctypehtml_, h1_, h2_
    , head_, header_, href_, li_, link_, id_, meta_, pre_, rel_, script_, src_
    , title_, toHtml, toHtmlRaw, type_, ul_
  )
import Markdown (Markdown(..), MarkdownContent(..))
import Page (Page)
import Prelude hiding (head, lookup)
import Pretty ((.$))
import System.FilePath.Posix ((<.>))

type HtmlGenerator = HtmlT (ReaderT Blog IO)

class HasCard a => HasContent a where
  content :: a -> HtmlGenerator ()

instance HasContent Article where
  content :: Article -> HtmlGenerator ()
content = Bool -> Markdown -> HtmlGenerator ()
mDContent Bool
True (Markdown -> HtmlGenerator ())
-> (Article -> Markdown) -> Article -> HtmlGenerator ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Article -> Markdown
forall a. MarkdownContent a => a -> Markdown
getMarkdown

instance HasContent Page where
  content :: Page -> HtmlGenerator ()
content = Bool -> Markdown -> HtmlGenerator ()
mDContent Bool
True (Markdown -> HtmlGenerator ())
-> (Page -> Markdown) -> Page -> HtmlGenerator ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Page -> Markdown
forall a. MarkdownContent a => a -> Markdown
getMarkdown

instance HasContent ArticlesList where
  content :: ArticlesList -> HtmlGenerator ()
content al :: ArticlesList
al@(ArticlesList {Bool
full :: ArticlesList -> Bool
full :: Bool
full}) = do
    Article -> Markdown
preview <- Int -> Article -> Markdown
Article.preview (Int -> Article -> Markdown)
-> HtmlT (ReaderT Blog IO) Int
-> HtmlT (ReaderT Blog IO) (Article -> Markdown)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((Blog -> Int) -> HtmlT (ReaderT Blog IO) Int
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks ((Blog -> Int) -> HtmlT (ReaderT Blog IO) Int)
-> (Blog -> Int) -> HtmlT (ReaderT Blog IO) Int
forall a b. (a -> b) -> a -> b
$Blog -> Skin
skin(Blog -> Skin) -> (Skin -> Int) -> Blog -> Int
forall a b c. (a -> b) -> (b -> c) -> a -> c
.$Skin -> Int
previewLinesCount)
    HtmlGenerator () -> HtmlGenerator ()
forall arg result. Term arg result => arg -> result
h2_ (HtmlGenerator () -> HtmlGenerator ())
-> (Text -> HtmlGenerator ()) -> Text -> HtmlGenerator ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> HtmlGenerator ()
forall a (m :: * -> *). (ToHtml a, Monad m) => a -> HtmlT m ()
toHtml (Text -> HtmlGenerator ())
-> HtmlT (ReaderT Blog IO) Text -> HtmlGenerator ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< ArticlesList -> HtmlT (ReaderT Blog IO) Text
forall (m :: * -> *). Renderer m => ArticlesList -> m Text
description ArticlesList
al
    HtmlGenerator () -> HtmlGenerator ()
forall arg result. Term arg result => arg -> result
ul_ (HtmlGenerator () -> HtmlGenerator ())
-> HtmlGenerator () -> HtmlGenerator ()
forall a b. (a -> b) -> a -> b
$ do
      (Blog -> Bool) -> HtmlT (ReaderT Blog IO) Bool
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks Blog -> Bool
hasRSS HtmlT (ReaderT Blog IO) Bool
-> (Bool -> HtmlGenerator ()) -> HtmlGenerator ()
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Bool -> HtmlGenerator ()
rssLink
      HtmlGenerator () -> HtmlGenerator ()
forall arg result. Term arg result => arg -> result
li_ (HtmlGenerator () -> HtmlGenerator ())
-> (HtmlGenerator () -> HtmlGenerator ())
-> HtmlGenerator ()
-> HtmlGenerator ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Attribute] -> HtmlGenerator () -> HtmlGenerator ()
forall arg result. Term arg result => arg -> result
a_ [Text -> Attribute
href_ (Text -> Attribute) -> (String -> Text) -> String -> Attribute
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Text
pack (String -> Attribute) -> String -> Attribute
forall a b. (a -> b) -> a -> b
$ ArticlesList -> String
otherURL ArticlesList
al, Text -> Attribute
class_ Text
"other"] (HtmlGenerator () -> HtmlGenerator ())
-> HtmlT (ReaderT Blog IO) (HtmlGenerator ()) -> HtmlGenerator ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< HtmlT (ReaderT Blog IO) (HtmlGenerator ())
otherLink
    [Attribute] -> HtmlGenerator () -> HtmlGenerator ()
forall arg result. Term arg result => arg -> result
div_ [Text -> Attribute
class_ Text
"articles"] (
        (Article -> HtmlGenerator ()) -> [Article] -> HtmlGenerator ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ (Bool -> Markdown -> HtmlGenerator ()
mDContent Bool
False (Markdown -> HtmlGenerator ())
-> (Article -> Markdown) -> Article -> HtmlGenerator ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Article -> Markdown
preview) ([Article] -> HtmlGenerator ())
-> HtmlT (ReaderT Blog IO) [Article] -> HtmlGenerator ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< ArticlesList -> HtmlT (ReaderT Blog IO) [Article]
forall (m :: * -> *).
MonadReader Blog m =>
ArticlesList -> m [Article]
getArticles ArticlesList
al
      )
    where
      otherLink :: HtmlT (ReaderT Blog IO) (HtmlGenerator ())
otherLink =
        Text -> HtmlGenerator ()
forall a (m :: * -> *). (ToHtml a, Monad m) => a -> HtmlT m ()
toHtml (Text -> HtmlGenerator ())
-> HtmlT (ReaderT Blog IO) Text
-> HtmlT (ReaderT Blog IO) (HtmlGenerator ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> String -> Environment -> HtmlT (ReaderT Blog IO) Text
forall (m :: * -> *). Renderer m => String -> Environment -> m Text
template (if Bool
full then String
"latestLink" else String
"allLink") []
      rssLink :: Bool -> HtmlGenerator ()
      rssLink :: Bool -> HtmlGenerator ()
rssLink Bool
True = do
        (Text
text, Text
title) <- ArticlesList -> HtmlT (ReaderT Blog IO) (Text, Text)
forall (m :: * -> *). Renderer m => ArticlesList -> m (Text, Text)
rssLinkTexts ArticlesList
al
        HtmlGenerator () -> HtmlGenerator ()
forall arg result. Term arg result => arg -> result
li_ (HtmlGenerator () -> HtmlGenerator ())
-> (HtmlGenerator () -> HtmlGenerator ())
-> HtmlGenerator ()
-> HtmlGenerator ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Attribute] -> HtmlGenerator () -> HtmlGenerator ()
forall arg result. Term arg result => arg -> result
a_ [Text -> Attribute
href_ Text
"rss.xml", Text -> Attribute
class_ Text
"RSS", Text -> Attribute
forall arg result. Term arg result => arg -> result
title_ Text
title] (HtmlGenerator () -> HtmlGenerator ())
-> HtmlGenerator () -> HtmlGenerator ()
forall a b. (a -> b) -> a -> b
$ Text -> HtmlGenerator ()
forall a (m :: * -> *). (ToHtml a, Monad m) => a -> HtmlT m ()
toHtml Text
text
      rssLink Bool
False = () -> HtmlGenerator ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

mDContent :: Bool -> Markdown -> HtmlGenerator ()
mDContent :: Bool -> Markdown -> HtmlGenerator ()
mDContent Bool
raw markdown :: Markdown
markdown@(Markdown {String
key :: Markdown -> String
key :: String
key, [String]
body :: Markdown -> [String]
body :: [String]
body}) =
  [Attribute] -> HtmlGenerator () -> HtmlGenerator ()
forall arg result. Term arg result => arg -> result
article_ [Text -> Attribute
id_ (Text -> Attribute) -> Text -> Attribute
forall a b. (a -> b) -> a -> b
$ String -> Text
pack String
key] (do
      HtmlGenerator () -> HtmlGenerator ()
forall arg result. Term arg result => arg -> result
header_ (HtmlGenerator () -> HtmlGenerator ())
-> (HtmlGenerator () -> HtmlGenerator ())
-> HtmlGenerator ()
-> HtmlGenerator ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HtmlGenerator () -> HtmlGenerator ()
forall arg result. Term arg result => arg -> result
h1_ (HtmlGenerator () -> HtmlGenerator ())
-> HtmlGenerator () -> HtmlGenerator ()
forall a b. (a -> b) -> a -> b
$ Bool -> Markdown -> HtmlGenerator ()
mDLink Bool
raw Markdown
markdown
      HtmlGenerator () -> HtmlGenerator ()
forall arg result. Term arg result => arg -> result
pre_ (HtmlGenerator () -> HtmlGenerator ())
-> (String -> HtmlGenerator ()) -> String -> HtmlGenerator ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> HtmlGenerator ()
forall a (m :: * -> *). (ToHtml a, Monad m) => a -> HtmlT m ()
toHtml (String -> HtmlGenerator ()) -> String -> HtmlGenerator ()
forall a b. (a -> b) -> a -> b
$ [String] -> String
unlines [String]
body
    )

mDLink :: Bool -> Markdown -> HtmlGenerator ()
mDLink :: Bool -> Markdown -> HtmlGenerator ()
mDLink Bool
raw (Markdown {String
path :: Markdown -> String
path :: String
Markdown.path, String
title :: Markdown -> String
title :: String
title}) =
  [Attribute] -> HtmlGenerator () -> HtmlGenerator ()
forall arg result. Term arg result => arg -> result
a_ [Text -> Attribute
href_ (Text -> Attribute) -> Text -> Attribute
forall a b. (a -> b) -> a -> b
$ String -> Text
pack String
url] (HtmlGenerator () -> HtmlGenerator ())
-> HtmlGenerator () -> HtmlGenerator ()
forall a b. (a -> b) -> a -> b
$ String -> HtmlGenerator ()
forall a (m :: * -> *). (ToHtml a, Monad m) => a -> HtmlT m ()
toHtml String
title
  where
    url :: String
url = String -> String
absoluteLink (String -> String) -> String -> String
forall a b. (a -> b) -> a -> b
$ String
path String -> String -> String
<.> (if Bool
raw then String
"md" else String
"html")

tag :: String -> HtmlGenerator ()
tag :: String -> HtmlGenerator ()
tag String
name =
  [Attribute] -> HtmlGenerator () -> HtmlGenerator ()
forall arg result. Term arg result => arg -> result
a_ [Text -> Attribute
href_ (Text -> Attribute) -> (String -> Text) -> String -> Attribute
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Text
pack (String -> Attribute) -> String -> Attribute
forall a b. (a -> b) -> a -> b
$ String -> String
absoluteLink String
name String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"/", Text -> Attribute
class_ Text
"tag"] (HtmlGenerator () -> HtmlGenerator ())
-> HtmlGenerator () -> HtmlGenerator ()
forall a b. (a -> b) -> a -> b
$ String -> HtmlGenerator ()
forall a (m :: * -> *). (ToHtml a, Monad m) => a -> HtmlT m ()
toHtml String
name

defaultBanner :: HtmlGenerator ()
defaultBanner :: HtmlGenerator ()
defaultBanner =
  [Attribute] -> HtmlGenerator () -> HtmlGenerator ()
forall arg result. Term arg result => arg -> result
div_ [Text -> Attribute
id_ Text
"header"] (
      [Attribute] -> HtmlGenerator () -> HtmlGenerator ()
forall arg result. Term arg result => arg -> result
a_ [Text -> Attribute
href_ Text
"/"] (
          HtmlGenerator () -> HtmlGenerator ()
forall arg result. Term arg result => arg -> result
h1_ (HtmlGenerator () -> HtmlGenerator ())
-> (String -> HtmlGenerator ()) -> String -> HtmlGenerator ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> HtmlGenerator ()
forall a (m :: * -> *). (ToHtml a, Monad m) => a -> HtmlT m ()
toHtml (String -> HtmlGenerator ())
-> HtmlT (ReaderT Blog IO) String -> HtmlGenerator ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< (Blog -> String) -> HtmlT (ReaderT Blog IO) String
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks Blog -> String
name
        )
    )

faviconLink :: FilePath -> HtmlGenerator ()
faviconLink :: String -> HtmlGenerator ()
faviconLink String
url = [Attribute] -> HtmlGenerator ()
forall (m :: * -> *). Applicative m => [Attribute] -> HtmlT m ()
link_ [
    Text -> Attribute
rel_ Text
"shortcut icon", Text -> Attribute
href_ (Text -> Attribute) -> (String -> Text) -> String -> Attribute
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Text
pack (String -> Attribute) -> String -> Attribute
forall a b. (a -> b) -> a -> b
$ String -> String
absoluteLink String
url, Text -> Attribute
type_ Text
"image/x-icon"
  ]

optional :: (a -> HtmlGenerator ()) -> Maybe a -> HtmlGenerator ()
optional :: (a -> HtmlGenerator ()) -> Maybe a -> HtmlGenerator ()
optional = HtmlGenerator ()
-> (a -> HtmlGenerator ()) -> Maybe a -> HtmlGenerator ()
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (() -> HtmlGenerator ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()) 

navigationSection ::
  Text -> String -> ((String, a) -> HtmlGenerator ()) -> Map String a -> HtmlGenerator ()
navigationSection :: Text
-> String
-> ((String, a) -> HtmlGenerator ())
-> Map String a
-> HtmlGenerator ()
navigationSection Text
sectionId String
templateKey (String, a) -> HtmlGenerator ()
generator Map String a
collection
  | Map String a -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null Map String a
collection = () -> HtmlGenerator ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
  | Bool
otherwise =
      [Attribute] -> HtmlGenerator () -> HtmlGenerator ()
forall arg result. Term arg result => arg -> result
div_ [Text -> Attribute
id_ Text
sectionId, Text -> Attribute
class_ Text
"navigator"] (do
          HtmlGenerator () -> HtmlGenerator ()
forall arg result. Term arg result => arg -> result
h2_ (HtmlGenerator () -> HtmlGenerator ())
-> (Text -> HtmlGenerator ()) -> Text -> HtmlGenerator ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> HtmlGenerator ()
forall a (m :: * -> *). (ToHtml a, Monad m) => a -> HtmlT m ()
toHtml (Text -> HtmlGenerator ())
-> HtmlT (ReaderT Blog IO) Text -> HtmlGenerator ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< String -> Environment -> HtmlT (ReaderT Blog IO) Text
forall (m :: * -> *). Renderer m => String -> Environment -> m Text
template String
templateKey []
          HtmlGenerator () -> HtmlGenerator ()
forall arg result. Term arg result => arg -> result
ul_ (HtmlGenerator () -> HtmlGenerator ())
-> ([(String, a)] -> HtmlGenerator ())
-> [(String, a)]
-> HtmlGenerator ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((String, a) -> HtmlGenerator ())
-> [(String, a)] -> HtmlGenerator ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_  (HtmlGenerator () -> HtmlGenerator ()
forall arg result. Term arg result => arg -> result
li_ (HtmlGenerator () -> HtmlGenerator ())
-> ((String, a) -> HtmlGenerator ())
-> (String, a)
-> HtmlGenerator ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String, a) -> HtmlGenerator ()
generator) ([(String, a)] -> HtmlGenerator ())
-> [(String, a)] -> HtmlGenerator ()
forall a b. (a -> b) -> a -> b
$ Map String a -> [(String, a)]
forall k a. Map k a -> [(k, a)]
Map.toList Map String a
collection
        )

htmlDocument :: HasContent a => a -> HtmlGenerator ()
htmlDocument :: a -> HtmlGenerator ()
htmlDocument a
someContent =
  HtmlGenerator () -> HtmlGenerator ()
forall (m :: * -> *) a. Applicative m => HtmlT m a -> HtmlT m a
doctypehtml_ (do
      HtmlGenerator () -> HtmlGenerator ()
forall arg result. Term arg result => arg -> result
head_ (do
          [Attribute] -> HtmlGenerator ()
forall (m :: * -> *). Applicative m => [Attribute] -> HtmlT m ()
meta_ [Text -> Attribute
charset_ Text
"utf-8"]
          HtmlGenerator () -> HtmlGenerator ()
forall arg result. Term arg result => arg -> result
title_ (HtmlGenerator () -> HtmlGenerator ())
-> (String -> HtmlGenerator ()) -> String -> HtmlGenerator ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> HtmlGenerator ()
forall a (m :: * -> *). (ToHtml a, Monad m) => a -> HtmlT m ()
toHtml (String -> HtmlGenerator ())
-> HtmlT (ReaderT Blog IO) String -> HtmlGenerator ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< (Blog -> String) -> HtmlT (ReaderT Blog IO) String
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks Blog -> String
name
          [Attribute] -> Text -> HtmlGenerator ()
forall arg result. TermRaw arg result => arg -> result
script_ [Text -> Attribute
src_ Text
"/js/remarkable.min.js"] Text
empty
          [Attribute] -> Text -> HtmlGenerator ()
forall arg result. TermRaw arg result => arg -> result
script_ [Text -> Attribute
src_ Text
"/js/hablo.js"] Text
empty
          (String -> HtmlGenerator ()) -> Maybe String -> HtmlGenerator ()
forall a. (a -> HtmlGenerator ()) -> Maybe a -> HtmlGenerator ()
optional String -> HtmlGenerator ()
faviconLink (Maybe String -> HtmlGenerator ())
-> HtmlT (ReaderT Blog IO) (Maybe String) -> HtmlGenerator ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< ((Blog -> Maybe String) -> HtmlT (ReaderT Blog IO) (Maybe String)
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks ((Blog -> Maybe String) -> HtmlT (ReaderT Blog IO) (Maybe String))
-> (Blog -> Maybe String) -> HtmlT (ReaderT Blog IO) (Maybe String)
forall a b. (a -> b) -> a -> b
$Blog -> Skin
skin(Blog -> Skin) -> (Skin -> Maybe String) -> Blog -> Maybe String
forall a b c. (a -> b) -> (b -> c) -> a -> c
.$Skin -> Maybe String
favicon)
          (String -> HtmlGenerator ()) -> Maybe String -> HtmlGenerator ()
forall a. (a -> HtmlGenerator ()) -> Maybe a -> HtmlGenerator ()
optional (a -> String -> HtmlGenerator ()
forall a (m :: * -> *).
(HasCard a, Renderer m) =>
a -> String -> HtmlT m ()
Card.make a
someContent) (Maybe String -> HtmlGenerator ())
-> HtmlT (ReaderT Blog IO) (Maybe String) -> HtmlGenerator ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< ((Blog -> Maybe String) -> HtmlT (ReaderT Blog IO) (Maybe String)
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks ((Blog -> Maybe String) -> HtmlT (ReaderT Blog IO) (Maybe String))
-> (Blog -> Maybe String) -> HtmlT (ReaderT Blog IO) (Maybe String)
forall a b. (a -> b) -> a -> b
$Blog -> URL
urls(Blog -> URL) -> (URL -> Maybe String) -> Blog -> Maybe String
forall a b c. (a -> b) -> (b -> c) -> a -> c
.$URL -> Maybe String
cards)
          (String -> HtmlGenerator ()) -> Maybe String -> HtmlGenerator ()
forall a. (a -> HtmlGenerator ()) -> Maybe a -> HtmlGenerator ()
optional String -> HtmlGenerator ()
forall a (m :: * -> *). (ToHtml a, Monad m) => a -> HtmlT m ()
toHtmlRaw (Maybe String -> HtmlGenerator ())
-> HtmlT (ReaderT Blog IO) (Maybe String) -> HtmlGenerator ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< ((Blog -> Maybe String) -> HtmlT (ReaderT Blog IO) (Maybe String)
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks ((Blog -> Maybe String) -> HtmlT (ReaderT Blog IO) (Maybe String))
-> (Blog -> Maybe String) -> HtmlT (ReaderT Blog IO) (Maybe String)
forall a b. (a -> b) -> a -> b
$Blog -> Skin
skin(Blog -> Skin) -> (Skin -> Maybe String) -> Blog -> Maybe String
forall a b c. (a -> b) -> (b -> c) -> a -> c
.$Skin -> Maybe String
head)
        )
      HtmlGenerator () -> HtmlGenerator ()
forall arg result. Term arg result => arg -> result
body_ (do
          HtmlGenerator ()
-> (String -> HtmlGenerator ()) -> Maybe String -> HtmlGenerator ()
forall b a. b -> (a -> b) -> Maybe a -> b
maybe HtmlGenerator ()
defaultBanner String -> HtmlGenerator ()
forall a (m :: * -> *). (ToHtml a, Monad m) => a -> HtmlT m ()
toHtmlRaw (Maybe String -> HtmlGenerator ())
-> HtmlT (ReaderT Blog IO) (Maybe String) -> HtmlGenerator ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< ((Blog -> Maybe String) -> HtmlT (ReaderT Blog IO) (Maybe String)
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks ((Blog -> Maybe String) -> HtmlT (ReaderT Blog IO) (Maybe String))
-> (Blog -> Maybe String) -> HtmlT (ReaderT Blog IO) (Maybe String)
forall a b. (a -> b) -> a -> b
$Blog -> Skin
skin(Blog -> Skin) -> (Skin -> Maybe String) -> Blog -> Maybe String
forall a b c. (a -> b) -> (b -> c) -> a -> c
.$Skin -> Maybe String
banner)
          (Blog -> Collection (Set String))
-> HtmlT (ReaderT Blog IO) (Collection (Set String))
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks Blog -> Collection (Set String)
tags HtmlT (ReaderT Blog IO) (Collection (Set String))
-> (Collection (Set String) -> HtmlGenerator ())
-> HtmlGenerator ()
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Text
-> String
-> ((String, Set String) -> HtmlGenerator ())
-> Collection (Set String)
-> HtmlGenerator ()
forall a.
Text
-> String
-> ((String, a) -> HtmlGenerator ())
-> Map String a
-> HtmlGenerator ()
navigationSection Text
"tags" String
"tagsList"
                          (\(String
key, Set String
_) -> String -> HtmlGenerator ()
tag String
key)
          (Blog -> Collection Page)
-> HtmlT (ReaderT Blog IO) (Collection Page)
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks Blog -> Collection Page
pages HtmlT (ReaderT Blog IO) (Collection Page)
-> (Collection Page -> HtmlGenerator ()) -> HtmlGenerator ()
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Text
-> String
-> ((String, Page) -> HtmlGenerator ())
-> Collection Page
-> HtmlGenerator ()
forall a.
Text
-> String
-> ((String, a) -> HtmlGenerator ())
-> Map String a
-> HtmlGenerator ()
navigationSection Text
"pages" String
"pagesList"
                          (\(String
_, Page
page) -> Bool -> Markdown -> HtmlGenerator ()
mDLink Bool
False (Markdown -> HtmlGenerator ()) -> Markdown -> HtmlGenerator ()
forall a b. (a -> b) -> a -> b
$ Page -> Markdown
forall a. MarkdownContent a => a -> Markdown
getMarkdown Page
page)
          [Attribute] -> HtmlGenerator () -> HtmlGenerator ()
forall arg result. Term arg result => arg -> result
div_ [Text -> Attribute
id_ Text
"contents"] (HtmlGenerator () -> HtmlGenerator ())
-> HtmlGenerator () -> HtmlGenerator ()
forall a b. (a -> b) -> a -> b
$ a -> HtmlGenerator ()
forall a. HasContent a => a -> HtmlGenerator ()
content a
someContent
        )
    )