make sfw info fields a bit clearer

This commit is contained in:
Rhiannon Morris 2020-07-16 11:47:02 +02:00
parent 75b91f43b4
commit cc65ebb388
2 changed files with 6 additions and 3 deletions

View file

@ -17,7 +17,7 @@ dependSingle :: FilePath -- ^ yaml file name (relative to data dir!)
-> Text
dependSingle yaml info prefix build nsfw =
let dir = build </> prefix </> takeDirectory yaml
images = if nsfw then #images info else filter #sfw $ #images info
images = if nsfw then #images info else #sfwImages info
paths = map #path images
index = dir </> "index.html"
deps = thumbFile (thumbnail info) : map pageFile paths ++ paths

View file

@ -57,11 +57,14 @@ data Link =
}
deriving (Eq, Show)
instance HasField "nsfw" Info Bool where getField = all #nsfw . #images
instance HasField "sfw" Info Bool where getField = not . #nsfw
instance HasField "sfw" Image Bool where getField = not . #nsfw
instance HasField "sfw" Link Bool where getField = not . #nsfw
instance HasField "sfwImages" Info [Image] where
getField = filter #sfw . #images
instance HasField "allNsfw" Info Bool where getField = null . #sfwImages
instance HasField "anySfw" Info Bool where getField = not . #allNsfw
instance HasField "thumb" Info (Maybe FilePath) where
getField (Info {thumb', images}) = thumb' <|> #path <$> find #sfw images