66 lines
1.5 KiB
Haskell
66 lines
1.5 KiB
Haskell
module IndexPage (make) where
|
|
|
|
import qualified Data.Text.Lazy as Lazy
|
|
|
|
import BuilderQQ
|
|
import Info
|
|
|
|
make :: IndexInfo -> Lazy.Text
|
|
make info = toLazyText $ make' info
|
|
|
|
make' :: IndexInfo -> Builder
|
|
make' (IndexInfo {title, galleries, links, footer}) = [b|@0
|
|
<!DOCTYPE html>
|
|
<html lang=en>
|
|
<meta charset=utf-8>
|
|
<link rel=stylesheet href=/style/shiny/index.css title=shiny>
|
|
<link rel='alternate stylesheet' href=/style/tum/index.css title=tummy>
|
|
|
|
<title>$*title</title>
|
|
|
|
<header>
|
|
<h1>$*title</h1>
|
|
</header>
|
|
|
|
<main>
|
|
$galleryList
|
|
$linkList
|
|
</main>
|
|
|
|
$footer'
|
|
|]
|
|
where
|
|
galleryList = if null galleries then "" else [b|@2
|
|
<ul id=gallery-list class=list>
|
|
$4.items
|
|
</ul>
|
|
|]
|
|
where items = map makeItem galleries
|
|
linkList = if null links then "" else [b|@2
|
|
<ul id=link-list class=list>
|
|
$4.items
|
|
</ul>
|
|
|]
|
|
where items = map makeLink links
|
|
footer' = case footer of
|
|
Nothing -> ""
|
|
Just f -> [b|@0
|
|
<footer>
|
|
$2*f
|
|
</footer>
|
|
|]
|
|
|
|
makeItem :: GalleryInfo -> Builder
|
|
makeItem (GalleryInfo {title, desc, prefix, filters}) = [b|@4
|
|
<li$nsfw><a href=$@prefix title="$*desc">$*title</a></li>
|
|
|]
|
|
where nsfw = if hasNsfw filters then " class=nsfw" else ""
|
|
|
|
makeLink :: Link -> Builder
|
|
makeLink (Link {title, url, nsfw}) = [b|@4
|
|
<li$nsfw'><a href=$*url>$*title</a>
|
|
|]
|
|
where nsfw' = if nsfw then " class=nsfw" else ""
|
|
|
|
hasNsfw :: GalleryFilters -> Bool
|
|
hasNsfw (GalleryFilters {nsfw}) = nsfw /= NoNsfw
|