diff options
Diffstat (limited to 'compiler/src/Gallery.hs')
-rw-r--r-- | compiler/src/Gallery.hs | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/compiler/src/Gallery.hs b/compiler/src/Gallery.hs index 1fa4036..a1b1674 100644 --- a/compiler/src/Gallery.hs +++ b/compiler/src/Gallery.hs | |||
@@ -86,8 +86,8 @@ data GalleryItem = GalleryItem | |||
86 | , date :: String -- TODO: checked ISO8601 date | 86 | , date :: String -- TODO: checked ISO8601 date |
87 | , description :: String | 87 | , description :: String |
88 | , tags :: [Tag] | 88 | , tags :: [Tag] |
89 | , path :: ResourcePath | 89 | , path :: Path |
90 | , thumbnail :: Maybe ResourcePath | 90 | , thumbnail :: Maybe Path |
91 | , properties :: GalleryItemProps | 91 | , properties :: GalleryItemProps |
92 | } deriving (Generic, Show) | 92 | } deriving (Generic, Show) |
93 | 93 | ||
@@ -97,30 +97,30 @@ instance ToJSON GalleryItem where | |||
97 | 97 | ||
98 | 98 | ||
99 | buildGalleryTree :: ResourceTree -> GalleryItem | 99 | buildGalleryTree :: ResourceTree -> GalleryItem |
100 | buildGalleryTree (ItemResource sidecar path@(filename:_) thumbnail) = | 100 | buildGalleryTree (ItemResource sidecar path thumbnail) = |
101 | GalleryItem | 101 | GalleryItem |
102 | { title = optMeta title filename | 102 | { title = optMeta title $ fileName path |
103 | , date = optMeta date "" -- TODO: check and normalise dates | 103 | , date = optMeta date "" -- TODO: check and normalise dates |
104 | , description = optMeta description "" | 104 | , description = optMeta description "" |
105 | , tags = optMeta tags [] | 105 | , tags = optMeta tags [] |
106 | , path = webPath path | 106 | , path = path |
107 | , thumbnail = fmap webPath thumbnail | 107 | , thumbnail = thumbnail |
108 | , properties = Unknown } -- TODO | 108 | , properties = Unknown } -- TODO |
109 | where | 109 | where |
110 | optMeta :: (Sidecar -> Maybe a) -> a -> a | 110 | optMeta :: (Sidecar -> Maybe a) -> a -> a |
111 | optMeta get fallback = fromMaybe fallback $ get sidecar | 111 | optMeta get fallback = fromMaybe fallback $ get sidecar |
112 | 112 | ||
113 | buildGalleryTree (DirResource dirItems path@(dirname:_) thumbnail) = | 113 | buildGalleryTree (DirResource dirItems path thumbnail) = |
114 | map buildGalleryTree dirItems | 114 | map buildGalleryTree dirItems |
115 | & \items -> GalleryItem | 115 | & \items -> GalleryItem |
116 | { title = dirname | 116 | { title = fileName path |
117 | -- TODO: consider using the most recent item's date? what if empty? | 117 | -- TODO: consider using the most recent item's date? what if empty? |
118 | , date = "" | 118 | , date = "" |
119 | -- TODO: consider allowing metadata sidecars for directories too | 119 | -- TODO: consider allowing metadata sidecars for directories too |
120 | , description = "" | 120 | , description = "" |
121 | , tags = aggregateChildTags items | 121 | , tags = aggregateChildTags items |
122 | , path = webPath path | 122 | , path = path |
123 | , thumbnail = fmap webPath thumbnail | 123 | , thumbnail = thumbnail |
124 | , properties = Directory items } | 124 | , properties = Directory items } |
125 | where | 125 | where |
126 | aggregateChildTags :: [GalleryItem] -> [Tag] | 126 | aggregateChildTags :: [GalleryItem] -> [Tag] |