46 lines
962 B
Haskell
46 lines
962 B
Haskell
module IndexPage (make) where
|
|
|
|
import qualified Data.Text.Lazy as Lazy
|
|
import Data.Text.Lazy.Builder (Builder, toLazyText)
|
|
|
|
import BuilderQQ
|
|
import Info
|
|
|
|
make :: IndexInfo -> Lazy.Text
|
|
make iinfo = toLazyText $ make' iinfo
|
|
|
|
make' :: IndexInfo -> Builder
|
|
make' (IndexInfo {galleries, footer}) = [b|@0
|
|
<!DOCTYPE html>
|
|
<html lang=en>
|
|
<meta charset=utf-8>
|
|
<link rel=stylesheet href=/style/index.css>
|
|
|
|
<title>gallery list</title>
|
|
|
|
<header>
|
|
<h1>gallery list</h1>
|
|
</header>
|
|
|
|
<main>
|
|
<ul class=gallery-list>
|
|
$4.items
|
|
</ul>
|
|
</main>
|
|
|
|
<footer>
|
|
$4*footer
|
|
</footer>
|
|
|]
|
|
where
|
|
items = map makeItem galleries
|
|
|
|
makeItem :: GalleryInfo -> Builder
|
|
makeItem (GalleryInfo {title, prefix, filters}) = [b|@4
|
|
<li$nsfw><a href=$@prefix>$*title</a>
|
|
|]
|
|
where
|
|
nsfw = if hasNsfw filters then " class=nsfw" else ""
|
|
|
|
hasNsfw :: GalleryFilters -> Bool
|
|
hasNsfw (GalleryFilters {nsfw}) = nsfw /= Just False
|