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 =
|
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),
|
||||||
title :: !Text,
|
-- | if false, don't show updated emblem even if @updates@ is non-empty
|
||||||
artist :: !(Maybe Artist), -- nothing = me, obv
|
showUpdated :: !Bool,
|
||||||
nsfwOnly :: !Bool,
|
title :: !Text,
|
||||||
tags :: ![Text],
|
artist :: !(Maybe Artist), -- nothing = me, obv
|
||||||
nsfwTags :: ![Text],
|
nsfwOnly :: !Bool,
|
||||||
desc :: !(Maybe Text),
|
tags :: ![Text],
|
||||||
nsfwDesc :: !(Maybe Text),
|
nsfwTags :: ![Text],
|
||||||
bg :: !(Maybe Text),
|
desc :: !(Maybe Text),
|
||||||
images :: ![Image],
|
nsfwDesc :: !(Maybe Text),
|
||||||
thumb' :: !(Maybe FilePath),
|
bg :: !(Maybe Text),
|
||||||
links :: ![Link],
|
images :: ![Image],
|
||||||
extras :: ![FilePath]
|
thumb' :: !(Maybe FilePath),
|
||||||
|
links :: ![Link],
|
||||||
|
extras :: ![FilePath]
|
||||||
}
|
}
|
||||||
deriving (Eq, Show)
|
deriving (Eq, Show)
|
||||||
|
|
||||||
|
@ -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)
|
||||||
|
@ -154,8 +157,9 @@ addSuffix suf path =
|
||||||
instance FromYAML Info where
|
instance FromYAML Info where
|
||||||
parseYAML = YAML.withMap "info" \m ->
|
parseYAML = YAML.withMap "info" \m ->
|
||||||
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
|
||||||
|
|
Loading…
Reference in a new issue