aboutsummaryrefslogtreecommitdiff
path: root/compiler/src
diff options
context:
space:
mode:
authorpacien2022-09-04 18:18:27 +0200
committerpacien2022-09-04 18:18:27 +0200
commit11bbbae2850b9c45da697a8ed9626495a50a38c0 (patch)
treeff2713118f8b45d36905bfea2933f08d8e70066d /compiler/src
parente93f7b1eb84c083d67567115284c0002a3a7d5fc (diff)
parent8349be992b46b77dee921f484cfbff8b758ff756 (diff)
downloadldgallery-11bbbae2850b9c45da697a8ed9626495a50a38c0.tar.gz
Merge branch 'develop': release v2.1v2.1
GitHub: related to #315
Diffstat (limited to 'compiler/src')
-rw-r--r--compiler/src/Caching.hs6
-rw-r--r--compiler/src/Compiler.hs6
-rw-r--r--compiler/src/FileProcessors.hs4
-rw-r--r--compiler/src/Input.hs6
-rw-r--r--compiler/src/ItemProcessors.hs7
-rw-r--r--compiler/src/Resource.hs3
6 files changed, 17 insertions, 15 deletions
diff --git a/compiler/src/Caching.hs b/compiler/src/Caching.hs
index c2b5a43..1a8b710 100644
--- a/compiler/src/Caching.hs
+++ b/compiler/src/Caching.hs
@@ -53,7 +53,7 @@ buildItemCache cachedItems = lookupCache
53 cachedMap = Map.fromList (map withKey cachedItemList) 53 cachedMap = Map.fromList (map withKey cachedItemList)
54 lookupCache path = Map.lookup (webPath path) cachedMap 54 lookupCache path = Map.lookup (webPath path) cachedMap
55 55
56useCached :: ItemCache -> (GalleryItem -> a) -> Cache a 56useCached :: ItemCache -> (GalleryItem -> Maybe a) -> Cache a
57useCached cache propGetter processor itemPath resPath inputFsPath outputFsPath = 57useCached cache propGetter processor itemPath resPath inputFsPath outputFsPath =
58 do 58 do
59 isDir <- doesDirectoryExist outputFsPath 59 isDir <- doesDirectoryExist outputFsPath
@@ -63,7 +63,7 @@ useCached cache propGetter processor itemPath resPath inputFsPath outputFsPath =
63 if fileExists then 63 if fileExists then
64 do 64 do
65 needUpdate <- isOutdated True inputFsPath outputFsPath 65 needUpdate <- isOutdated True inputFsPath outputFsPath
66 case (needUpdate, cache itemPath) of 66 case (needUpdate, cache itemPath >>= propGetter) of
67 (False, Just props) -> fromCache props 67 (False, Just props) -> fromCache props
68 _ -> update 68 _ -> update
69 else 69 else
@@ -73,4 +73,4 @@ useCached cache propGetter processor itemPath resPath inputFsPath outputFsPath =
73 update = processor itemPath resPath inputFsPath outputFsPath 73 update = processor itemPath resPath inputFsPath outputFsPath
74 fromCache props = 74 fromCache props =
75 putStrLn ("From cache:\t" ++ outputFsPath) 75 putStrLn ("From cache:\t" ++ outputFsPath)
76 >> return (propGetter props) 76 >> return props
diff --git a/compiler/src/Compiler.hs b/compiler/src/Compiler.hs
index 1ec55c5..4111f02 100644
--- a/compiler/src/Compiler.hs
+++ b/compiler/src/Compiler.hs
@@ -147,8 +147,8 @@ compileGallery configPath inputDirPath outputDirPath outputIndexPath excludedDir
147 cachedIndex <- loadCachedIndex galleryIndexPath 147 cachedIndex <- loadCachedIndex galleryIndexPath
148 let cache = mkCache cachedIndex 148 let cache = mkCache cachedIndex
149 149
150 let itemProc = itemProcessor config (cache Resource.properties) 150 let itemProc = itemProcessor config (cache $ return . Resource.properties)
151 let thumbnailProc = thumbnailProcessor config (cache Resource.thumbnail) 151 let thumbnailProc = thumbnailProcessor config (cache $ fmap return . Resource.thumbnail)
152 let galleryBuilder = buildGalleryTree itemProc thumbnailProc (tagsFromDirectories config) 152 let galleryBuilder = buildGalleryTree itemProc thumbnailProc (tagsFromDirectories config)
153 resources <- galleryBuilder curatedInputTree 153 resources <- galleryBuilder curatedInputTree
154 154
@@ -170,7 +170,7 @@ compileGallery configPath inputDirPath outputDirPath outputIndexPath excludedDir
170 then return Nothing 170 then return Nothing
171 else loadGalleryIndex galleryIndexPath 171 else loadGalleryIndex galleryIndexPath
172 172
173 mkCache :: Maybe GalleryIndex -> (GalleryItem -> a) -> Cache a 173 mkCache :: Maybe GalleryIndex -> (GalleryItem -> Maybe a) -> Cache a
174 mkCache refGalleryIndex = 174 mkCache refGalleryIndex =
175 if rebuildAll 175 if rebuildAll
176 then const noCache 176 then const noCache
diff --git a/compiler/src/FileProcessors.hs b/compiler/src/FileProcessors.hs
index 5c4e1c8..6e1738e 100644
--- a/compiler/src/FileProcessors.hs
+++ b/compiler/src/FileProcessors.hs
@@ -1,7 +1,7 @@
1-- ldgallery - A static generator which turns a collection of tagged 1-- ldgallery - A static generator which turns a collection of tagged
2-- pictures into a searchable web gallery. 2-- pictures into a searchable web gallery.
3-- 3--
4-- Copyright (C) 2019-2020 Pacien TRAN-GIRARD 4-- Copyright (C) 2019-2022 Pacien TRAN-GIRARD
5-- 5--
6-- This program is free software: you can redistribute it and/or modify 6-- This program is free software: you can redistribute it and/or modify
7-- it under the terms of the GNU Affero General Public License as 7-- it under the terms of the GNU Affero General Public License as
@@ -79,7 +79,7 @@ copyFileProcessor inputPath outputPath =
79 79
80resizePictureUpTo :: Resolution -> FileTransformer 80resizePictureUpTo :: Resolution -> FileTransformer
81resizePictureUpTo maxResolution inputPath outputPath = 81resizePictureUpTo maxResolution inputPath outputPath =
82 putStrLn ("Generating:\t" ++ outputPath) 82 putStrLn ("Processing:\t" ++ outputPath)
83 >> ensureParentDir (flip resize) outputPath inputPath 83 >> ensureParentDir (flip resize) outputPath inputPath
84 where 84 where
85 maxSize :: Resolution -> String 85 maxSize :: Resolution -> String
diff --git a/compiler/src/Input.hs b/compiler/src/Input.hs
index 48931ec..4cfabe6 100644
--- a/compiler/src/Input.hs
+++ b/compiler/src/Input.hs
@@ -1,7 +1,7 @@
1-- ldgallery - A static generator which turns a collection of tagged 1-- ldgallery - A static generator which turns a collection of tagged
2-- pictures into a searchable web gallery. 2-- pictures into a searchable web gallery.
3-- 3--
4-- Copyright (C) 2019-2020 Pacien TRAN-GIRARD 4-- Copyright (C) 2019-2021 Pacien TRAN-GIRARD
5-- 5--
6-- This program is free software: you can redistribute it and/or modify 6-- This program is free software: you can redistribute it and/or modify
7-- it under the terms of the GNU Affero General Public License as 7-- it under the terms of the GNU Affero General Public License as
@@ -100,9 +100,7 @@ readSidecarFile filepath =
100 100
101 101
102readInputTree :: AnchoredFSNode -> IO InputTree 102readInputTree :: AnchoredFSNode -> IO InputTree
103readInputTree (AnchoredFSNode _ File{}) = 103readInputTree (AnchoredFSNode anchor root) = mkDirNode root
104 throw $ AssertionFailed "Input directory is a file"
105readInputTree (AnchoredFSNode anchor root@Dir{}) = mkDirNode root
106 where 104 where
107 mkInputNode :: Map.Map FileName FSNode -> FSNode -> IO (Maybe InputTree) 105 mkInputNode :: Map.Map FileName FSNode -> FSNode -> IO (Maybe InputTree)
108 mkInputNode dir file@File{path} | not (isSidecar file) && not (isThumbnail file) = 106 mkInputNode dir file@File{path} | not (isSidecar file) && not (isThumbnail file) =
diff --git a/compiler/src/ItemProcessors.hs b/compiler/src/ItemProcessors.hs
index f967954..fa99316 100644
--- a/compiler/src/ItemProcessors.hs
+++ b/compiler/src/ItemProcessors.hs
@@ -1,7 +1,7 @@
1-- ldgallery - A static generator which turns a collection of tagged 1-- ldgallery - A static generator which turns a collection of tagged
2-- pictures into a searchable web gallery. 2-- pictures into a searchable web gallery.
3-- 3--
4-- Copyright (C) 2019-2020 Pacien TRAN-GIRARD 4-- Copyright (C) 2019-2021 Pacien TRAN-GIRARD
5-- 5--
6-- This program is free software: you can redistribute it and/or modify 6-- This program is free software: you can redistribute it and/or modify
7-- it under the terms of the GNU Affero General Public License as 7-- it under the terms of the GNU Affero General Public License as
@@ -36,6 +36,7 @@ import Files
36data Format = 36data Format =
37 PictureFormat 37 PictureFormat
38 | PlainTextFormat 38 | PlainTextFormat
39 | MarkdownFormat
39 | PortableDocumentFormat 40 | PortableDocumentFormat
40 | VideoFormat 41 | VideoFormat
41 | AudioFormat 42 | AudioFormat
@@ -54,8 +55,9 @@ formatFromPath =
54 ".tiff" -> PictureFormat 55 ".tiff" -> PictureFormat
55 ".hdr" -> PictureFormat 56 ".hdr" -> PictureFormat
56 ".gif" -> PictureFormat 57 ".gif" -> PictureFormat
58 ".webp" -> PictureFormat
57 ".txt" -> PlainTextFormat 59 ".txt" -> PlainTextFormat
58 ".md" -> PlainTextFormat -- TODO: handle markdown separately 60 ".md" -> MarkdownFormat
59 ".pdf" -> PortableDocumentFormat 61 ".pdf" -> PortableDocumentFormat
60 ".wav" -> AudioFormat 62 ".wav" -> AudioFormat
61 ".oga" -> AudioFormat 63 ".oga" -> AudioFormat
@@ -99,6 +101,7 @@ itemFileProcessor maxResolution =
99 processorFor PictureFormat Nothing = 101 processorFor PictureFormat Nothing =
100 transformThenDescribe copyFileProcessor getPictureProps 102 transformThenDescribe copyFileProcessor getPictureProps
101 processorFor PlainTextFormat _ = copyResource PlainText 103 processorFor PlainTextFormat _ = copyResource PlainText
104 processorFor MarkdownFormat _ = copyResource Markdown
102 processorFor PortableDocumentFormat _ = copyResource PDF 105 processorFor PortableDocumentFormat _ = copyResource PDF
103 processorFor VideoFormat _ = copyResource Video 106 processorFor VideoFormat _ = copyResource Video
104 processorFor AudioFormat _ = copyResource Audio 107 processorFor AudioFormat _ = copyResource Audio
diff --git a/compiler/src/Resource.hs b/compiler/src/Resource.hs
index f59eed6..804c9a1 100644
--- a/compiler/src/Resource.hs
+++ b/compiler/src/Resource.hs
@@ -1,7 +1,7 @@
1-- ldgallery - A static generator which turns a collection of tagged 1-- ldgallery - A static generator which turns a collection of tagged
2-- pictures into a searchable web gallery. 2-- pictures into a searchable web gallery.
3-- 3--
4-- Copyright (C) 2019-2020 Pacien TRAN-GIRARD 4-- Copyright (C) 2019-2021 Pacien TRAN-GIRARD
5-- 5--
6-- This program is free software: you can redistribute it and/or modify 6-- This program is free software: you can redistribute it and/or modify
7-- it under the terms of the GNU Affero General Public License as 7-- it under the terms of the GNU Affero General Public License as
@@ -90,6 +90,7 @@ data GalleryItemProps =
90 { resource :: Resource 90 { resource :: Resource
91 , resolution :: Resolution } 91 , resolution :: Resolution }
92 | PlainText { resource :: Resource } 92 | PlainText { resource :: Resource }
93 | Markdown { resource :: Resource }
93 | PDF { resource :: Resource } 94 | PDF { resource :: Resource }
94 | Video { resource :: Resource } 95 | Video { resource :: Resource }
95 | Audio { resource :: Resource } 96 | Audio { resource :: Resource }