aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/Gallery.hs
diff options
context:
space:
mode:
authorpacien2019-12-27 10:08:19 +0100
committerpacien2019-12-27 10:08:19 +0100
commiteb7a652b2244ffa4dd5ba2440b7879127e7c6078 (patch)
tree71ab010b20a0f8d9f4a99179b68a7a12c081531d /compiler/src/Gallery.hs
parentaead07929e6ed13375b86539b1679a88993c9cf5 (diff)
downloadldgallery-eb7a652b2244ffa4dd5ba2440b7879127e7c6078.tar.gz
compiler: implement resource processing
but break directory cleanup
Diffstat (limited to 'compiler/src/Gallery.hs')
-rw-r--r--compiler/src/Gallery.hs15
1 files changed, 9 insertions, 6 deletions
diff --git a/compiler/src/Gallery.hs b/compiler/src/Gallery.hs
index ce52523..f12eddb 100644
--- a/compiler/src/Gallery.hs
+++ b/compiler/src/Gallery.hs
@@ -1,5 +1,3 @@
1{-# LANGUAGE DuplicateRecordFields, DeriveGeneric, DeriveAnyClass #-}
2
3-- ldgallery - A static generator which turns a collection of tagged 1-- ldgallery - A static generator which turns a collection of tagged
4-- pictures into a searchable web gallery. 2-- pictures into a searchable web gallery.
5-- 3--
@@ -18,6 +16,11 @@
18-- You should have received a copy of the GNU Affero General Public License 16-- You should have received a copy of the GNU Affero General Public License
19-- along with this program. If not, see <https://www.gnu.org/licenses/>. 17-- along with this program. If not, see <https://www.gnu.org/licenses/>.
20 18
19{-# LANGUAGE
20 DuplicateRecordFields
21 , DeriveGeneric
22 , DeriveAnyClass
23#-}
21 24
22module Gallery 25module Gallery
23 ( GalleryItem(..), buildGalleryTree 26 ( GalleryItem(..), buildGalleryTree
@@ -94,20 +97,20 @@ instance ToJSON GalleryItem where
94 97
95 98
96buildGalleryTree :: ResourceTree -> GalleryItem 99buildGalleryTree :: ResourceTree -> GalleryItem
97buildGalleryTree (ItemResource sidecar path@(filename:_) thumbnailPath) = 100buildGalleryTree (ItemResource sidecar path@(filename:_) thumbnail) =
98 GalleryItem 101 GalleryItem
99 { title = optMeta title filename 102 { title = optMeta title filename
100 , date = optMeta date "" -- TODO: check and normalise dates 103 , date = optMeta date "" -- TODO: check and normalise dates
101 , description = optMeta description "" 104 , description = optMeta description ""
102 , tags = optMeta tags [] 105 , tags = optMeta tags []
103 , path = webPath path 106 , path = webPath path
104 , thumbnail = Just $ webPath thumbnailPath 107 , thumbnail = fmap webPath thumbnail
105 , properties = Unknown } -- TODO 108 , properties = Unknown } -- TODO
106 where 109 where
107 optMeta :: (Sidecar -> Maybe a) -> a -> a 110 optMeta :: (Sidecar -> Maybe a) -> a -> a
108 optMeta get fallback = fromMaybe fallback $ get sidecar 111 optMeta get fallback = fromMaybe fallback $ get sidecar
109 112
110buildGalleryTree (DirResource dirItems path@(dirname:_) thumbnailPath) = 113buildGalleryTree (DirResource dirItems path@(dirname:_) thumbnail) =
111 map buildGalleryTree dirItems 114 map buildGalleryTree dirItems
112 & \items -> GalleryItem 115 & \items -> GalleryItem
113 { title = dirname 116 { title = dirname
@@ -117,7 +120,7 @@ buildGalleryTree (DirResource dirItems path@(dirname:_) thumbnailPath) =
117 , description = "" 120 , description = ""
118 , tags = aggregateChildTags items 121 , tags = aggregateChildTags items
119 , path = webPath path 122 , path = webPath path
120 , thumbnail = fmap webPath thumbnailPath 123 , thumbnail = fmap webPath thumbnail
121 , properties = Directory items } 124 , properties = Directory items }
122 where 125 where
123 aggregateChildTags :: [GalleryItem] -> [Tag] 126 aggregateChildTags :: [GalleryItem] -> [Tag]