support pages being nsfw only even if they have a "sfw" image
This commit is contained in:
parent
d14571ec3e
commit
29a4d033a8
1 changed files with 3 additions and 1 deletions
|
@ -37,6 +37,7 @@ data Info =
|
||||||
date :: !Day,
|
date :: !Day,
|
||||||
title :: !Text,
|
title :: !Text,
|
||||||
artist :: !(Maybe Artist), -- nothing = me, obv
|
artist :: !(Maybe Artist), -- nothing = me, obv
|
||||||
|
nsfwOnly :: !Bool,
|
||||||
tags :: ![Text],
|
tags :: ![Text],
|
||||||
nsfwTags :: ![Text],
|
nsfwTags :: ![Text],
|
||||||
desc :: !(Maybe Text),
|
desc :: !(Maybe Text),
|
||||||
|
@ -146,6 +147,7 @@ instance FromYAML Info where
|
||||||
Info <$> m .: "date"
|
Info <$> m .: "date"
|
||||||
<*> m .: "title"
|
<*> m .: "title"
|
||||||
<*> m .:? "artist"
|
<*> m .:? "artist"
|
||||||
|
<*> m .:? "nsfw-only" .!= False
|
||||||
<*> m .:? "tags" .!= []
|
<*> m .:? "tags" .!= []
|
||||||
<*> m .:? "nsfw-tags" .!= []
|
<*> m .:? "nsfw-tags" .!= []
|
||||||
<*> m .:? "desc"
|
<*> m .:? "desc"
|
||||||
|
@ -227,7 +229,7 @@ readNsfwFilter "all" = pure AllN
|
||||||
readNsfwFilter _ = empty
|
readNsfwFilter _ = empty
|
||||||
|
|
||||||
matchNsfw :: NsfwFilter -> Info -> Bool
|
matchNsfw :: NsfwFilter -> Info -> Bool
|
||||||
matchNsfw NoNsfw i = #anySfw i
|
matchNsfw NoNsfw i = #anySfw i && not (#nsfwOnly i)
|
||||||
matchNsfw OnlyNsfw i = #anyNsfw i
|
matchNsfw OnlyNsfw i = #anyNsfw i
|
||||||
matchNsfw AllN _ = True
|
matchNsfw AllN _ = True
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue