diff options
author | pacien | 2020-01-06 10:28:27 +0100 |
---|---|---|
committer | pacien | 2020-01-06 10:28:27 +0100 |
commit | 03d39102ba55cda7cbe80fcdeb9b250caaa70bd0 (patch) | |
tree | 679a36e4b5eaa9c49bb62b715772d96bd9a26aaa /compiler/src/Resource.hs | |
parent | 5f57fd4f21f7ecd4038ca6e66a4b89622cbcc9fc (diff) | |
download | ldgallery-03d39102ba55cda7cbe80fcdeb9b250caaa70bd0.tar.gz |
compiler: properly reject invalid dates in sidecar files
GitHub: closes #31
Diffstat (limited to 'compiler/src/Resource.hs')
-rw-r--r-- | compiler/src/Resource.hs | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/compiler/src/Resource.hs b/compiler/src/Resource.hs index 207239f..53d61ac 100644 --- a/compiler/src/Resource.hs +++ b/compiler/src/Resource.hs | |||
@@ -31,7 +31,6 @@ import Data.Maybe (mapMaybe, fromMaybe) | |||
31 | import Data.Function ((&)) | 31 | import Data.Function ((&)) |
32 | import qualified Data.Set as Set | 32 | import qualified Data.Set as Set |
33 | import Data.Time.LocalTime (ZonedTime, utc, utcToZonedTime, zonedTimeToUTC) | 33 | import Data.Time.LocalTime (ZonedTime, utc, utcToZonedTime, zonedTimeToUTC) |
34 | import Data.Time.Format.ISO8601 (iso8601ParseM) | ||
35 | import System.Directory (getModificationTime) | 34 | import System.Directory (getModificationTime) |
36 | import Safe.Foldable (maximumByMay) | 35 | import Safe.Foldable (maximumByMay) |
37 | 36 | ||
@@ -110,7 +109,7 @@ buildGalleryTree processItem processThumbnail tagsFromDirectories galleryName in | |||
110 | fileModTime <- lastModTime path | 109 | fileModTime <- lastModTime path |
111 | return GalleryItem | 110 | return GalleryItem |
112 | { title = itemTitle | 111 | { title = itemTitle |
113 | , date = fromMaybe fileModTime itemDate | 112 | , date = fromMaybe fileModTime $ Input.date sidecar |
114 | , description = optMeta description "" | 113 | , description = optMeta description "" |
115 | , tags = (optMeta tags []) ++ implicitParentTags parents | 114 | , tags = (optMeta tags []) ++ implicitParentTags parents |
116 | , path = parents </ itemTitle | 115 | , path = parents </ itemTitle |
@@ -120,9 +119,6 @@ buildGalleryTree processItem processThumbnail tagsFromDirectories galleryName in | |||
120 | itemTitle :: String | 119 | itemTitle :: String |
121 | itemTitle = optMeta title $ fromMaybe "" $ fileName path | 120 | itemTitle = optMeta title $ fromMaybe "" $ fileName path |
122 | 121 | ||
123 | itemDate :: Maybe ZonedTime | ||
124 | itemDate = Input.date sidecar >>= iso8601ParseM | ||
125 | |||
126 | optMeta :: (Sidecar -> Maybe a) -> a -> a | 122 | optMeta :: (Sidecar -> Maybe a) -> a -> a |
127 | optMeta get fallback = fromMaybe fallback $ get sidecar | 123 | optMeta get fallback = fromMaybe fallback $ get sidecar |
128 | 124 | ||