aboutsummaryrefslogtreecommitdiff
path: root/compiler/src
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/src')
-rw-r--r--compiler/src/Input.hs3
-rw-r--r--compiler/src/Resource.hs6
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 ((&))
30import Data.Maybe (catMaybes) 30import Data.Maybe (catMaybes)
31import Data.Bool (bool) 31import Data.Bool (bool)
32import Data.List (find) 32import Data.List (find)
33import Data.Time.LocalTime (ZonedTime)
33import Data.Yaml (ParseException, decodeFileEither) 34import Data.Yaml (ParseException, decodeFileEither)
34import Data.Aeson (FromJSON) 35import Data.Aeson (FromJSON)
35import System.FilePath (isExtensionOf, dropExtension) 36import System.FilePath (isExtensionOf, dropExtension)
@@ -60,7 +61,7 @@ data InputTree =
60 61
61data Sidecar = Sidecar 62data 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)
31import Data.Function ((&)) 31import Data.Function ((&))
32import qualified Data.Set as Set 32import qualified Data.Set as Set
33import Data.Time.LocalTime (ZonedTime, utc, utcToZonedTime, zonedTimeToUTC) 33import Data.Time.LocalTime (ZonedTime, utc, utcToZonedTime, zonedTimeToUTC)
34import Data.Time.Format.ISO8601 (iso8601ParseM)
35import System.Directory (getModificationTime) 34import System.Directory (getModificationTime)
36import Safe.Foldable (maximumByMay) 35import 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