add show-updated field
(if false, never show updated emblem in gallery view)
This commit is contained in:
parent
8d4ff29e56
commit
71c1458de3
1 changed files with 23 additions and 19 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue