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|@0 $title

$title

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