aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/Resource.hs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/src/Resource.hs')
-rw-r--r--compiler/src/Resource.hs15
1 files changed, 6 insertions, 9 deletions
diff --git a/compiler/src/Resource.hs b/compiler/src/Resource.hs
index 1868512..e8ca58c 100644
--- a/compiler/src/Resource.hs
+++ b/compiler/src/Resource.hs
@@ -1,7 +1,7 @@
1-- ldgallery - A static generator which turns a collection of tagged 1-- ldgallery - A static generator which turns a collection of tagged
2-- pictures into a searchable web gallery. 2-- pictures into a searchable web gallery.
3-- 3--
4-- Copyright (C) 2019-2021 Pacien TRAN-GIRARD 4-- Copyright (C) 2019-2022 Pacien TRAN-GIRARD
5-- 5--
6-- This program is free software: you can redistribute it and/or modify 6-- This program is free software: you can redistribute it and/or modify
7-- it under the terms of the GNU Affero General Public License as 7-- it under the terms of the GNU Affero General Public License as
@@ -56,7 +56,7 @@ encodingOptions :: JSON.Options
56encodingOptions = JSON.defaultOptions 56encodingOptions = JSON.defaultOptions
57 { JSON.fieldLabelModifier = map toLower 57 { JSON.fieldLabelModifier = map toLower
58 , JSON.constructorTagModifier = map toLower 58 , JSON.constructorTagModifier = map toLower
59 , JSON.sumEncoding = JSON.defaultTaggedObject 59 , JSON.sumEncoding = JSON.TaggedObject
60 { JSON.tagFieldName = "type" 60 { JSON.tagFieldName = "type"
61 , JSON.contentsFieldName = "contents" 61 , JSON.contentsFieldName = "contents"
62 } 62 }
@@ -180,7 +180,7 @@ buildGalleryTree processItem processThumbnail tagsFromDirsConfig =
180 & map (prefix tagsFromDirsConfig ++) 180 & map (prefix tagsFromDirsConfig ++)
181 181
182 aggregateTags :: [GalleryItem] -> [Tag] 182 aggregateTags :: [GalleryItem] -> [Tag]
183 aggregateTags = concatMap (\item -> tags (item::GalleryItem)) 183 aggregateTags = concatMap Resource.tags
184 184
185 maybeThumbnail :: Path -> Maybe Path -> IO (Maybe Thumbnail) 185 maybeThumbnail :: Path -> Maybe Path -> IO (Maybe Thumbnail)
186 maybeThumbnail _ Nothing = return Nothing 186 maybeThumbnail _ Nothing = return Nothing
@@ -188,7 +188,7 @@ buildGalleryTree processItem processThumbnail tagsFromDirsConfig =
188 188
189 mostRecentModTime :: [GalleryItem] -> Maybe ZonedTime 189 mostRecentModTime :: [GalleryItem] -> Maybe ZonedTime
190 mostRecentModTime = 190 mostRecentModTime =
191 maximumByMay comparingTime . map (datetime::(GalleryItem -> ZonedTime)) 191 maximumByMay comparingTime . map Resource.datetime
192 192
193 comparingTime :: ZonedTime -> ZonedTime -> Ordering 193 comparingTime :: ZonedTime -> ZonedTime -> Ordering
194 comparingTime l r = compare (zonedTimeToUTC l) (zonedTimeToUTC r) 194 comparingTime l r = compare (zonedTimeToUTC l) (zonedTimeToUTC r)
@@ -220,14 +220,11 @@ galleryOutputDiff resources ref =
220 220
221 resPath :: GalleryItemProps -> Maybe Path 221 resPath :: GalleryItemProps -> Maybe Path
222 resPath Directory{} = Nothing 222 resPath Directory{} = Nothing
223 resPath resourceProps = 223 resPath resourceProps = Just $ resourcePath $ resourceProps.resource
224 Just
225 $ resourcePath
226 $ (resource :: (GalleryItemProps -> Resource)) resourceProps
227 224
228 thumbnailPaths :: [GalleryItem] -> [Path] 225 thumbnailPaths :: [GalleryItem] -> [Path]
229 thumbnailPaths = 226 thumbnailPaths =
230 map (resourcePath . (resource :: (Thumbnail -> Resource))) 227 map (\thumbnail -> resourcePath thumbnail.resource)
231 . mapMaybe thumbnail 228 . mapMaybe thumbnail
232 229
233 (\\) :: [Path] -> [Path] -> [Path] 230 (\\) :: [Path] -> [Path] -> [Path]