2020-07-16 10:29:32 -04:00
|
|
|
module IndexPage (make) where
|
|
|
|
|
|
|
|
import qualified Data.Text.Lazy as Lazy
|
|
|
|
|
|
|
|
import BuilderQQ
|
|
|
|
import Info
|
|
|
|
|
2020-08-11 14:29:54 -04:00
|
|
|
make :: Text -> IndexInfo -> Lazy.Text
|
|
|
|
make root info = toLazyText $ make' root info
|
2020-07-16 10:29:32 -04:00
|
|
|
|
2020-08-11 14:29:54 -04:00
|
|
|
make' :: Text -> IndexInfo -> Builder
|
|
|
|
make' root (IndexInfo {title, desc, galleries, links, footer}) = [b|@0
|
2020-07-16 10:29:32 -04:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang=en>
|
|
|
|
<meta charset=utf-8>
|
2020-08-04 17:12:58 -04:00
|
|
|
<link rel=stylesheet href=/style/shiny/index.css>
|
2020-08-04 18:52:56 -04:00
|
|
|
<link rel=icon href=/style/niss.svg>
|
2020-07-16 10:29:32 -04:00
|
|
|
|
2020-10-06 16:41:26 -04:00
|
|
|
<meta name=viewport content="width=1200,viewport-fit=cover">
|
|
|
|
|
2020-08-11 14:29:54 -04:00
|
|
|
<meta property=og:type content=og:website>
|
2020-08-30 13:13:40 -04:00
|
|
|
<meta property=og:title content="$title">
|
|
|
|
<meta property=og:site_name content="$title">
|
|
|
|
<meta property=og:description content="$desc">
|
|
|
|
<meta property=og:image content="$root/style/card.png">
|
2020-08-11 14:29:54 -04:00
|
|
|
<meta property=og:url content="$url">
|
2020-09-19 02:13:13 -04:00
|
|
|
<meta name=twitter:site content=@2_gecs>
|
2020-08-11 14:29:54 -04:00
|
|
|
<meta name=twitter:card content=summary>
|
|
|
|
|
2020-08-30 13:13:40 -04:00
|
|
|
<title>$title</title>
|
2020-07-16 10:29:32 -04:00
|
|
|
|
2020-10-06 16:07:39 -04:00
|
|
|
<div class=page>
|
|
|
|
<header>
|
|
|
|
<h1 id=title>$title</h1>
|
|
|
|
</header>
|
2020-07-16 10:29:32 -04:00
|
|
|
|
2020-10-06 16:07:39 -04:00
|
|
|
<main>
|
|
|
|
$4.galleryList
|
|
|
|
$4.linkList
|
|
|
|
</main>
|
2020-07-18 05:45:32 -04:00
|
|
|
|
2020-10-06 16:07:39 -04:00
|
|
|
$2.footer'
|
|
|
|
</div>
|
2020-07-16 10:29:32 -04:00
|
|
|
|]
|
|
|
|
where
|
2020-10-06 16:07:39 -04:00
|
|
|
galleryList = if null galleries then "" else [b|@0
|
2020-08-04 12:56:44 -04:00
|
|
|
<nav aria-label="gallery list">
|
|
|
|
<ul id=gallery-list class=list>
|
2020-10-06 16:07:39 -04:00
|
|
|
$4.items
|
2020-08-04 12:56:44 -04:00
|
|
|
</ul>
|
|
|
|
</nav>
|
2020-07-19 06:22:02 -04:00
|
|
|
|]
|
|
|
|
where items = map makeItem galleries
|
2020-10-06 16:07:39 -04:00
|
|
|
linkList = if null links then "" else [b|@0
|
2020-08-04 12:56:44 -04:00
|
|
|
<nav aria-label="other links">
|
|
|
|
<ul id=link-list class=list>
|
2020-10-06 16:07:39 -04:00
|
|
|
$4.items
|
2020-08-04 12:56:44 -04:00
|
|
|
</ul>
|
|
|
|
</nav>
|
2020-07-19 06:22:02 -04:00
|
|
|
|]
|
|
|
|
where items = map makeLink links
|
|
|
|
footer' = case footer of
|
|
|
|
Nothing -> ""
|
|
|
|
Just f -> [b|@0
|
|
|
|
<footer>
|
2020-08-30 13:13:40 -04:00
|
|
|
$2.f
|
2020-07-19 06:22:02 -04:00
|
|
|
</footer>
|
|
|
|
|]
|
2020-08-30 13:13:40 -04:00
|
|
|
url = [b|$root|]
|
2020-07-16 10:29:32 -04:00
|
|
|
|
|
|
|
makeItem :: GalleryInfo -> Builder
|
2020-10-06 16:07:39 -04:00
|
|
|
makeItem (GalleryInfo {title, desc, prefix, filters}) = [b|@0
|
2020-08-30 13:13:40 -04:00
|
|
|
<li$nsfw><a href=$prefix title="$desc">$title</a></li>
|
2020-07-16 10:29:32 -04:00
|
|
|
|]
|
2020-08-30 13:13:40 -04:00
|
|
|
where nsfw = if hasNsfw filters then [b| class=nsfw|] else ""
|
2020-07-19 06:22:02 -04:00
|
|
|
|
|
|
|
makeLink :: Link -> Builder
|
2020-10-06 16:07:39 -04:00
|
|
|
makeLink (Link {title, url, nsfw}) = [b|@0
|
2020-08-30 13:13:40 -04:00
|
|
|
<li$nsfw'><a href=$url>$title</a>
|
2020-07-19 06:22:02 -04:00
|
|
|
|]
|
2020-08-30 13:13:40 -04:00
|
|
|
where nsfw' = if nsfw then [b| class=nsfw|] else ""
|
2020-07-17 06:29:13 -04:00
|
|
|
|
|
|
|
hasNsfw :: GalleryFilters -> Bool
|
2020-07-24 19:10:52 -04:00
|
|
|
hasNsfw (GalleryFilters {nsfw}) = nsfw /= NoNsfw
|