From ef9e6f4ad917a8a949030ec9f0ec55a16b39b93c Mon Sep 17 00:00:00 2001 From: Rhiannon Morris Date: Thu, 3 Sep 2020 22:30:45 +0200 Subject: [PATCH] allow posts to be sorted within a single day --- make-pages/Info.hs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/make-pages/Info.hs b/make-pages/Info.hs index 6cebea4..66ac8da 100644 --- a/make-pages/Info.hs +++ b/make-pages/Info.hs @@ -36,6 +36,10 @@ import Text.Read (readMaybe) data Info = Info { 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, artist :: !(Maybe Artist), -- nothing = me, obv nsfwOnly :: !Bool, @@ -118,7 +122,7 @@ linksFor :: Bool -> Info -> [Link] linksFor nsfw = if nsfw then #links else #sfwLinks instance Ord Info where - compare = comparing \Info {date, title} -> (date, title) + compare = comparing \Info {date, sortEx, title} -> (date, sortEx, title) newtype NoThumb = NoThumb FilePath @@ -146,6 +150,7 @@ addSuffix suf path = instance FromYAML Info where parseYAML = YAML.withMap "info" \m -> Info <$> m .: "date" + <*> m .:? "sort" .!= "" <*> m .: "title" <*> m .:? "artist" <*> m .:? "nsfw-only" .!= False