add extra link support to index page

This commit is contained in:
Rhiannon Morris 2020-07-19 12:22:02 +02:00
parent 980d790874
commit 5a1181ec76
3 changed files with 63 additions and 30 deletions

View file

@ -10,7 +10,7 @@ make :: IndexInfo -> Lazy.Text
make info = toLazyText $ make' info
make' :: IndexInfo -> Builder
make' (IndexInfo {title, galleries, footer}) = [b|@0
make' (IndexInfo {title, galleries, links, footer}) = [b|@0
<!DOCTYPE html>
<html lang=en>
<meta charset=utf-8>
@ -23,24 +23,44 @@ make' (IndexInfo {title, galleries, footer}) = [b|@0
</header>
<main>
$galleryList
$linkList
</main>
$footer'
|]
where
galleryList = if null galleries then "" else [b|@2
<ul class=gallery-list>
$4.items
</ul>
</main>
<footer>
$4*footer
</footer>
|]
where
items = map makeItem galleries
|]
where items = map makeItem galleries
linkList = if null links then "" else [b|@2
<ul class=link-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, prefix, filters}) = [b|@4
<li$nsfw><a href=$@prefix>$*title</a>
|]
where
nsfw = if hasNsfw filters then " class=nsfw" else ""
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 /= Just False