add show-updated field

(if false, never show updated emblem in gallery view)
This commit is contained in:
Rhiannon Morris 2020-09-25 23:13:45 +02:00
parent 8d4ff29e56
commit 71c1458de3

View file

@ -36,11 +36,13 @@ import System.FilePath ((</>), takeBaseName, takeExtension, splitExtension)
data Info = data Info =
Info { Info {
date :: !Date, date :: !Date,
-- extra sort key after date -- | extra sort key after date
-- e.g. multiple things on the same day might have a,b,c in @sortEx@ to -- e.g. multiple things on the same day might have a,b,c in @sortEx@ to
-- put them in the right order in the gallery -- put them in the right order in the gallery
sortEx :: !Text, sortEx :: !Text,
updates :: !(Map Date Text), updates :: !(Map Date Text),
-- | if false, don't show updated emblem even if @updates@ is non-empty
showUpdated :: !Bool,
title :: !Text, title :: !Text,
artist :: !(Maybe Artist), -- nothing = me, obv artist :: !(Maybe Artist), -- nothing = me, obv
nsfwOnly :: !Bool, nsfwOnly :: !Bool,
@ -111,7 +113,8 @@ instance HasField "latestYear" Info Int where
getField = #year . #latestDate getField = #year . #latestDate
instance HasField "updated" Info Bool where getField = not . Map.null . #updates instance HasField "updated" Info Bool where
getField (Info {updates, showUpdated}) = showUpdated && not (Map.null updates)
descFor :: Bool -> Info -> Maybe Text descFor :: Bool -> Info -> Maybe Text
descFor nsfw (Info {desc, nsfwDesc}) = desc <> (guard nsfw *> nsfwDesc) descFor nsfw (Info {desc, nsfwDesc}) = desc <> (guard nsfw *> nsfwDesc)
@ -156,6 +159,7 @@ instance FromYAML Info where
Info <$> m .: "date" Info <$> m .: "date"
<*> m .:? "sort" .!= "" <*> m .:? "sort" .!= ""
<*> m .:? "updates" .!= [] <*> m .:? "updates" .!= []
<*> m .:? "show-updated" .!= True
<*> m .: "title" <*> m .: "title"
<*> m .:? "artist" <*> m .:? "artist"
<*> m .:? "nsfw-only" .!= False <*> m .:? "nsfw-only" .!= False