module IndexPage (make) where import qualified Data.Text.Lazy as Lazy import BuilderQQ import Info make :: Text -> IndexInfo -> Lazy.Text make root info = toLazyText $ make' root info make' :: Text -> IndexInfo -> Builder make' root (IndexInfo {title, desc, galleries, links, footer}) = [b| $title

$title

$galleryList $linkList
$footer'
|] where galleryList = if null galleries then "" else [b| |] where items = map makeItem galleries linkList = if null links then "" else [b| |] where items = map makeLink links footer' = case footer of Nothing -> "" Just f -> [b| |] url = [b|$root|] makeItem :: GalleryInfo -> Builder makeItem (GalleryInfo {title, desc, prefix, filters}) = [b| $title |] where nsfw = if hasNsfw filters then [b| class=nsfw|] else "" makeLink :: Link -> Builder makeLink (Link {title, url, nsfw}) = [b| $title |] where nsfw' = if nsfw then [b| class=nsfw|] else "" hasNsfw :: GalleryFilters -> Bool hasNsfw (GalleryFilters {nsfw}) = nsfw /= NoNsfw