aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOzoneGrif2020-02-02 05:36:08 +0100
committerGitHub2020-02-02 05:36:08 +0100
commitf297cc4f69e5b9fd3463d36f4eff21ac916d2849 (patch)
treea8e53907f3d4c1ca380defbb5b89fa534a1b2d71
parentd1109852caba5942b037ea6ef998c67bef1d2920 (diff)
parent56901340cb510ee9012bb4a122b95831258e9789 (diff)
downloadldgallery-f297cc4f69e5b9fd3463d36f4eff21ac916d2849.tar.gz
Merge branch 'develop' into fix-implicit-output-exclusion
-rw-r--r--compiler/package.yaml1
-rw-r--r--compiler/src/Processors.hs6
-rw-r--r--compiler/src/Resource.hs21
3 files changed, 24 insertions, 4 deletions
diff --git a/compiler/package.yaml b/compiler/package.yaml
index 9b96d17..1769833 100644
--- a/compiler/package.yaml
+++ b/compiler/package.yaml
@@ -17,6 +17,7 @@ description: Please see the README on GitHub at <https://github.com/paci
17dependencies: 17dependencies:
18- base >= 4.7 && < 5 18- base >= 4.7 && < 5
19- containers 19- containers
20- data-ordlist
20- filepath 21- filepath
21- directory 22- directory
22- text 23- text
diff --git a/compiler/src/Processors.hs b/compiler/src/Processors.hs
index f2ade63..df7e632 100644
--- a/compiler/src/Processors.hs
+++ b/compiler/src/Processors.hs
@@ -86,7 +86,11 @@ resizePictureUpTo maxResolution inputPath outputPath =
86 maxSize Resolution{width, height} = show width ++ "x" ++ show height ++ ">" 86 maxSize Resolution{width, height} = show width ++ "x" ++ show height ++ ">"
87 87
88 resize :: FileName -> FileName -> IO () 88 resize :: FileName -> FileName -> IO ()
89 resize input output = callProcess "magick" [input, "-resize", maxSize maxResolution, output] 89 resize input output = callProcess "magick"
90 [ input
91 , "-auto-orient"
92 , "-resize", maxSize maxResolution
93 , output ]
90 94
91 95
92type Cache = FileProcessor -> FileProcessor 96type Cache = FileProcessor -> FileProcessor
diff --git a/compiler/src/Resource.hs b/compiler/src/Resource.hs
index c0ef317..599509e 100644
--- a/compiler/src/Resource.hs
+++ b/compiler/src/Resource.hs
@@ -24,8 +24,8 @@ module Resource
24 24
25 25
26import Control.Concurrent.ParallelIO.Global (parallel) 26import Control.Concurrent.ParallelIO.Global (parallel)
27import Data.List ((\\), sortBy) 27import Data.List (sortOn)
28import Data.Ord (comparing) 28import Data.List.Ordered (minusBy)
29import Data.Char (toLower) 29import Data.Char (toLower)
30import Data.Maybe (mapMaybe, fromMaybe, maybeToList) 30import Data.Maybe (mapMaybe, fromMaybe, maybeToList)
31import Data.Function ((&)) 31import Data.Function ((&))
@@ -202,11 +202,26 @@ galleryOutputDiff resources ref =
202 thumbnailPaths :: [GalleryItem] -> [Path] 202 thumbnailPaths :: [GalleryItem] -> [Path]
203 thumbnailPaths = (map resourcePath) . (mapMaybe thumbnail) 203 thumbnailPaths = (map resourcePath) . (mapMaybe thumbnail)
204 204
205 (\\) :: [Path] -> [Path] -> [Path]
206 a \\ b = minusOn orderedForm (sortOn orderedForm a) (sortOn orderedForm b)
207 where
208 orderedForm :: Path -> WebPath
209 orderedForm = webPath
210
211 minusOn :: Ord b => (a -> b) -> [a] -> [a] -> [a]
212 minusOn f l r = map snd $ minusBy comparingFst (packRef f l) (packRef f r)
213
214 packRef :: (a -> b) -> [a] -> [(b, a)]
215 packRef f = map (\x -> let y = f x in y `seq` (y, x))
216
217 comparingFst :: Ord b => (b, a) -> (b, a) -> Ordering
218 comparingFst (l, _) (r, _) = compare l r
219
205 220
206galleryCleanupResourceDir :: GalleryItem -> FileName -> IO () 221galleryCleanupResourceDir :: GalleryItem -> FileName -> IO ()
207galleryCleanupResourceDir resourceTree outputDir = 222galleryCleanupResourceDir resourceTree outputDir =
208 readDirectory outputDir 223 readDirectory outputDir
209 >>= return . galleryOutputDiff resourceTree . root 224 >>= return . galleryOutputDiff resourceTree . root
210 >>= return . sortBy (flip $ comparing pathLength) -- nested files before dirs 225 >>= return . sortOn ((0 -) . pathLength) -- nested files before their parent dirs
211 >>= return . map (localPath . (/>) outputDir) 226 >>= return . map (localPath . (/>) outputDir)
212 >>= mapM_ remove 227 >>= mapM_ remove