gallery/make-pages/IndexPage.hs

47 lines
962 B
Haskell
Raw Normal View History

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