diff options
Diffstat (limited to 'compiler/src/Resource.hs')
-rw-r--r-- | compiler/src/Resource.hs | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/compiler/src/Resource.hs b/compiler/src/Resource.hs index 804c9a1..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 | |||
56 | encodingOptions = JSON.defaultOptions | 56 | encodingOptions = 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 | } |
@@ -92,6 +92,7 @@ data GalleryItemProps = | |||
92 | | PlainText { resource :: Resource } | 92 | | PlainText { resource :: Resource } |
93 | | Markdown { resource :: Resource } | 93 | | Markdown { resource :: Resource } |
94 | | PDF { resource :: Resource } | 94 | | PDF { resource :: Resource } |
95 | | EPUB { resource :: Resource } | ||
95 | | Video { resource :: Resource } | 96 | | Video { resource :: Resource } |
96 | | Audio { resource :: Resource } | 97 | | Audio { resource :: Resource } |
97 | | Other { resource :: Resource } | 98 | | Other { resource :: Resource } |
@@ -179,7 +180,7 @@ buildGalleryTree processItem processThumbnail tagsFromDirsConfig = | |||
179 | & map (prefix tagsFromDirsConfig ++) | 180 | & map (prefix tagsFromDirsConfig ++) |
180 | 181 | ||
181 | aggregateTags :: [GalleryItem] -> [Tag] | 182 | aggregateTags :: [GalleryItem] -> [Tag] |
182 | aggregateTags = concatMap (\item -> tags (item::GalleryItem)) | 183 | aggregateTags = concatMap Resource.tags |
183 | 184 | ||
184 | maybeThumbnail :: Path -> Maybe Path -> IO (Maybe Thumbnail) | 185 | maybeThumbnail :: Path -> Maybe Path -> IO (Maybe Thumbnail) |
185 | maybeThumbnail _ Nothing = return Nothing | 186 | maybeThumbnail _ Nothing = return Nothing |
@@ -187,7 +188,7 @@ buildGalleryTree processItem processThumbnail tagsFromDirsConfig = | |||
187 | 188 | ||
188 | mostRecentModTime :: [GalleryItem] -> Maybe ZonedTime | 189 | mostRecentModTime :: [GalleryItem] -> Maybe ZonedTime |
189 | mostRecentModTime = | 190 | mostRecentModTime = |
190 | maximumByMay comparingTime . map (datetime::(GalleryItem -> ZonedTime)) | 191 | maximumByMay comparingTime . map Resource.datetime |
191 | 192 | ||
192 | comparingTime :: ZonedTime -> ZonedTime -> Ordering | 193 | comparingTime :: ZonedTime -> ZonedTime -> Ordering |
193 | comparingTime l r = compare (zonedTimeToUTC l) (zonedTimeToUTC r) | 194 | comparingTime l r = compare (zonedTimeToUTC l) (zonedTimeToUTC r) |
@@ -219,14 +220,11 @@ galleryOutputDiff resources ref = | |||
219 | 220 | ||
220 | resPath :: GalleryItemProps -> Maybe Path | 221 | resPath :: GalleryItemProps -> Maybe Path |
221 | resPath Directory{} = Nothing | 222 | resPath Directory{} = Nothing |
222 | resPath resourceProps = | 223 | resPath resourceProps = Just $ resourcePath $ resourceProps.resource |
223 | Just | ||
224 | $ resourcePath | ||
225 | $ (resource :: (GalleryItemProps -> Resource)) resourceProps | ||
226 | 224 | ||
227 | thumbnailPaths :: [GalleryItem] -> [Path] | 225 | thumbnailPaths :: [GalleryItem] -> [Path] |
228 | thumbnailPaths = | 226 | thumbnailPaths = |
229 | map (resourcePath . (resource :: (Thumbnail -> Resource))) | 227 | map (\thumbnail -> resourcePath thumbnail.resource) |
230 | . mapMaybe thumbnail | 228 | . mapMaybe thumbnail |
231 | 229 | ||
232 | (\\) :: [Path] -> [Path] -> [Path] | 230 | (\\) :: [Path] -> [Path] -> [Path] |