use class instead of twigils for builder

This commit is contained in:
Rhiannon Morris 2020-08-30 19:13:40 +02:00
parent e810c3eb08
commit 2adee9ee8e
8 changed files with 140 additions and 155 deletions

View file

@ -28,20 +28,20 @@ make' root (GalleryInfo {title, desc, prefix, filters, hidden}) infos = [b|@0
<link rel=alternate href=rss.xml type=application/rss+xml>
<meta property=og:type content=og:website>
<meta property=og:title content="$*title">
<meta property=og:site_name content="$*title">
<meta property=og:description content="$*desc">
<meta property=og:image content="$url/$@imagepath0">
<meta property=og:title content="$title">
<meta property=og:site_name content="$title">
<meta property=og:description content="$desc">
<meta property=og:image content="$url/$imagepath0">
<meta property=og:url content="$url">
<meta name=twitter:site content=@gec_ko_>
<meta name=twitter:card content=summary>
<script src=/script/gallery.js></script>
<title>$*title</title>
<title>$title</title>
<header>
<h1>$*title</h1>
<h1>$title</h1>
<h2 class="right corner">
<a href=rss.xml>rss</a>
</h2>
@ -74,7 +74,7 @@ make' root (GalleryInfo {title, desc, prefix, filters, hidden}) infos = [b|@0
</main>
<footer>
<a href=$@undir>all galleries</a>
<a href=$undir>all galleries</a>
</footer>
|]
where
@ -100,7 +100,7 @@ make' root (GalleryInfo {title, desc, prefix, filters, hidden}) infos = [b|@0
nsfw = #nsfw filters /= NoNsfw
url = [b|$*root/$@prefix|]
url = [b|$root/$prefix|]
imagepath0
| (_, (p0, i0) : _) : _ <- infosByYear = getThumb (takeDirectory p0) i0
| otherwise = "/style/card.png"
@ -108,13 +108,13 @@ make' root (GalleryInfo {title, desc, prefix, filters, hidden}) infos = [b|@0
makeFilter :: Text -> HashSet Text -> Text -> Int -> Builder
makeFilter prefix initial tag _count = [b|@8
<li>
<input type=checkbox id="$id'" value="$*tag"$checked>
<label for="$id'">$*tag</label>
<input type=checkbox id="$id'" value="$tag"$checked>
<label for="$id'">$tag</label>
|]
where
id' = [b|$*prefix$&_$tag'|]
id' = [b|$prefix$&_$tag'|]
tag' = escId tag
checked = if HashSet.member tag initial then " checked" else ""
checked = if HashSet.member tag initial then [b| checked|] else ""
makeYearItems :: Bool -- ^ nsfw
-> Integer -- ^ year
@ -127,21 +127,21 @@ makeYearItems nsfw year infos = [b|@4
|]
where
items = map (uncurry $ makeItem nsfw) infos
year' = show year & foldMap \c -> [b|<span class=y>$'c</span>|]
year' = show year & foldMap \c -> [b|<span class=y>$c</span>|]
makeItem :: Bool -> FilePath -> Info -> Builder
makeItem nsfw file info@(Info {title, bg}) = [b|@4
<li class="item post$nsfw'" data-tags="$tags'">
<figure>
<a href="$@dir">
<img src="$@thumb"$bgStyle>
<a href="$dir">
<img src="$thumb"$bgStyle>
</a>
<figcaption>$*title</figcaption>
<figcaption>$title</figcaption>
</figure>
|]
where
dir = takeDirectory file
thumb = getThumb dir info
nsfw' = if nsfw && #anyNsfw info then " nsfw" else ""
nsfw' = if nsfw && #anyNsfw info then [b| nsfw|] else ""
tags' = fold $ intersperse ";" $ map fromText $ tagsFor nsfw info
bgStyle = ifJust bg \col -> [b| style="background: $*col"|]
bgStyle = ifJust bg \col -> [b| style="background: $col"|]