diff options
Diffstat (limited to 'compiler/src')
-rw-r--r-- | compiler/src/Input.hs | 3 | ||||
-rw-r--r-- | compiler/src/Resource.hs | 6 |
2 files changed, 3 insertions, 6 deletions
diff --git a/compiler/src/Input.hs b/compiler/src/Input.hs index 86d3ec8..85c802e 100644 --- a/compiler/src/Input.hs +++ b/compiler/src/Input.hs | |||
@@ -30,6 +30,7 @@ import Data.Function ((&)) | |||
30 | import Data.Maybe (catMaybes) | 30 | import Data.Maybe (catMaybes) |
31 | import Data.Bool (bool) | 31 | import Data.Bool (bool) |
32 | import Data.List (find) | 32 | import Data.List (find) |
33 | import Data.Time.LocalTime (ZonedTime) | ||
33 | import Data.Yaml (ParseException, decodeFileEither) | 34 | import Data.Yaml (ParseException, decodeFileEither) |
34 | import Data.Aeson (FromJSON) | 35 | import Data.Aeson (FromJSON) |
35 | import System.FilePath (isExtensionOf, dropExtension) | 36 | import System.FilePath (isExtensionOf, dropExtension) |
@@ -60,7 +61,7 @@ data InputTree = | |||
60 | 61 | ||
61 | data Sidecar = Sidecar | 62 | data Sidecar = Sidecar |
62 | { title :: Maybe String | 63 | { title :: Maybe String |
63 | , date :: Maybe String | 64 | , date :: Maybe ZonedTime |
64 | , description :: Maybe String | 65 | , description :: Maybe String |
65 | , tags :: Maybe [String] | 66 | , tags :: Maybe [String] |
66 | } deriving (Generic, FromJSON, Show) | 67 | } deriving (Generic, FromJSON, Show) |
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 | ||