diff --git a/make-pages/Info.hs b/make-pages/Info.hs index d2d2baa..ac2cef0 100644 --- a/make-pages/Info.hs +++ b/make-pages/Info.hs @@ -35,24 +35,26 @@ import System.FilePath ((), takeBaseName, takeExtension, splitExtension) data Info = Info { - date :: !Date, - -- extra sort key after date + date :: !Date, + -- | extra sort key after date -- 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 - sortEx :: !Text, - updates :: !(Map Date Text), - title :: !Text, - artist :: !(Maybe Artist), -- nothing = me, obv - nsfwOnly :: !Bool, - tags :: ![Text], - nsfwTags :: ![Text], - desc :: !(Maybe Text), - nsfwDesc :: !(Maybe Text), - bg :: !(Maybe Text), - images :: ![Image], - thumb' :: !(Maybe FilePath), - links :: ![Link], - extras :: ![FilePath] + sortEx :: !Text, + updates :: !(Map Date Text), + -- | if false, don't show updated emblem even if @updates@ is non-empty + showUpdated :: !Bool, + title :: !Text, + artist :: !(Maybe Artist), -- nothing = me, obv + nsfwOnly :: !Bool, + tags :: ![Text], + nsfwTags :: ![Text], + desc :: !(Maybe Text), + nsfwDesc :: !(Maybe Text), + bg :: !(Maybe Text), + images :: ![Image], + thumb' :: !(Maybe FilePath), + links :: ![Link], + extras :: ![FilePath] } deriving (Eq, Show) @@ -111,7 +113,8 @@ instance HasField "latestYear" Info Int where 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 nsfw (Info {desc, nsfwDesc}) = desc <> (guard nsfw *> nsfwDesc) @@ -154,8 +157,9 @@ addSuffix suf path = instance FromYAML Info where parseYAML = YAML.withMap "info" \m -> Info <$> m .: "date" - <*> m .:? "sort" .!= "" - <*> m .:? "updates" .!= [] + <*> m .:? "sort" .!= "" + <*> m .:? "updates" .!= [] + <*> m .:? "show-updated" .!= True <*> m .: "title" <*> m .:? "artist" <*> m .:? "nsfw-only" .!= False