allow posts to be sorted within a single day

This commit is contained in:
Rhiannon Morris 2020-09-03 22:30:45 +02:00
parent 2adee9ee8e
commit ef9e6f4ad9

View file

@ -36,6 +36,10 @@ import Text.Read (readMaybe)
data Info = data Info =
Info { Info {
date :: !Day, date :: !Day,
-- 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,
title :: !Text, title :: !Text,
artist :: !(Maybe Artist), -- nothing = me, obv artist :: !(Maybe Artist), -- nothing = me, obv
nsfwOnly :: !Bool, nsfwOnly :: !Bool,
@ -118,7 +122,7 @@ linksFor :: Bool -> Info -> [Link]
linksFor nsfw = if nsfw then #links else #sfwLinks linksFor nsfw = if nsfw then #links else #sfwLinks
instance Ord Info where instance Ord Info where
compare = comparing \Info {date, title} -> (date, title) compare = comparing \Info {date, sortEx, title} -> (date, sortEx, title)
newtype NoThumb = NoThumb FilePath newtype NoThumb = NoThumb FilePath
@ -146,6 +150,7 @@ 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 .: "title" <*> m .: "title"
<*> m .:? "artist" <*> m .:? "artist"
<*> m .:? "nsfw-only" .!= False <*> m .:? "nsfw-only" .!= False