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