allow updates to be marked nsfw-only

This commit is contained in:
Rhiannon Morris 2020-11-16 23:30:56 +01:00
parent 6567bdf059
commit 9a54cc0d53
4 changed files with 85 additions and 36 deletions

View file

@ -11,7 +11,7 @@ import Data.Function (on, (&))
import qualified Data.HashMap.Strict as HashMap
import Data.HashSet (HashSet)
import qualified Data.HashSet as HashSet
import Data.List (intersperse, groupBy, sortOn)
import Data.List (intersperse, groupBy, sortBy, sortOn)
import qualified Data.Text.Lazy as Lazy
import System.FilePath (takeDirectory, joinPath, splitPath)
import GHC.Exts (Down (..), the)
@ -90,9 +90,10 @@ make' root (GalleryInfo {title, desc, prefix, filters, hidden}) infos = [b|@0
infosByYear =
[(the year, infopath) |
infopath@(_, info) <- infos,
then sortOn by Down info,
let year = #latestYear info,
then sortInfo by info,
let year = #latestYear info nsfw,
then group by Down year using groupBy']
sortInfo f = sortBy $ flip (compareFor nsfw `on` f)
groupBy' f = groupBy ((==) `on` f)
undir = joinPath (replicate (length (splitPath prefix)) "..")
@ -159,8 +160,8 @@ makeItem nsfw file info@(Info {title, bg}) = [b|@0
thumb = getThumb dir info
nsfw' = if nsfw && #anyNsfw info then [b| nsfw|] else ""
tags' = fold $ intersperse ";" $ map fromText $ tagsFor nsfw info
date = #latestDate info
date = #latestDate info nsfw
date' = formatShort date
year' = #year date
updated' = if #updated info then [b|true|] else [b|false|]
updated' = if #updated info nsfw then [b|true|] else [b|false|]
bgStyle = ifJust bg \col -> [b| style="background: $col"|]