From 27f70f9886b7b77039ca47539900f4383d79c1b9 Mon Sep 17 00:00:00 2001 From: pacien Date: Sun, 25 Oct 2020 06:01:59 +0100 Subject: compiler/ItemProcessors: register .webp as picture file extension GitHub: closes #278 --- compiler/src/ItemProcessors.hs | 1 + 1 file changed, 1 insertion(+) (limited to 'compiler/src') diff --git a/compiler/src/ItemProcessors.hs b/compiler/src/ItemProcessors.hs index f967954..476b7d7 100644 --- a/compiler/src/ItemProcessors.hs +++ b/compiler/src/ItemProcessors.hs @@ -54,6 +54,7 @@ formatFromPath = ".tiff" -> PictureFormat ".hdr" -> PictureFormat ".gif" -> PictureFormat + ".webp" -> PictureFormat ".txt" -> PlainTextFormat ".md" -> PlainTextFormat -- TODO: handle markdown separately ".pdf" -> PortableDocumentFormat -- cgit v1.2.3 From 005ea7957a75e53b443bbc5a596909df457343b8 Mon Sep 17 00:00:00 2001 From: pacien Date: Mon, 26 Oct 2020 12:43:49 +0100 Subject: compiler/Caching: fix cache thumbnail masking in index GitHub: closes #280 --- compiler/src/Caching.hs | 6 +++--- compiler/src/Compiler.hs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'compiler/src') 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 cachedMap = Map.fromList (map withKey cachedItemList) lookupCache path = Map.lookup (webPath path) cachedMap -useCached :: ItemCache -> (GalleryItem -> a) -> Cache a +useCached :: ItemCache -> (GalleryItem -> Maybe a) -> Cache a useCached cache propGetter processor itemPath resPath inputFsPath outputFsPath = do isDir <- doesDirectoryExist outputFsPath @@ -63,7 +63,7 @@ useCached cache propGetter processor itemPath resPath inputFsPath outputFsPath = if fileExists then do needUpdate <- isOutdated True inputFsPath outputFsPath - case (needUpdate, cache itemPath) of + case (needUpdate, cache itemPath >>= propGetter) of (False, Just props) -> fromCache props _ -> update else @@ -73,4 +73,4 @@ useCached cache propGetter processor itemPath resPath inputFsPath outputFsPath = update = processor itemPath resPath inputFsPath outputFsPath fromCache props = putStrLn ("From cache:\t" ++ outputFsPath) - >> return (propGetter props) + >> 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 cachedIndex <- loadCachedIndex galleryIndexPath let cache = mkCache cachedIndex - let itemProc = itemProcessor config (cache Resource.properties) - let thumbnailProc = thumbnailProcessor config (cache Resource.thumbnail) + let itemProc = itemProcessor config (cache $ return . Resource.properties) + let thumbnailProc = thumbnailProcessor config (cache $ fmap return . Resource.thumbnail) let galleryBuilder = buildGalleryTree itemProc thumbnailProc (tagsFromDirectories config) resources <- galleryBuilder curatedInputTree @@ -170,7 +170,7 @@ compileGallery configPath inputDirPath outputDirPath outputIndexPath excludedDir then return Nothing else loadGalleryIndex galleryIndexPath - mkCache :: Maybe GalleryIndex -> (GalleryItem -> a) -> Cache a + mkCache :: Maybe GalleryIndex -> (GalleryItem -> Maybe a) -> Cache a mkCache refGalleryIndex = if rebuildAll then const noCache -- cgit v1.2.3 From 06228f6620643ef591eceeb86eb1b10efce69ef0 Mon Sep 17 00:00:00 2001 From: pacien Date: Fri, 25 Jun 2021 12:05:48 +0200 Subject: compiler/Input: remove duplicate assertion on input file tree --- compiler/src/Input.hs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'compiler/src') 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 @@ -- ldgallery - A static generator which turns a collection of tagged -- pictures into a searchable web gallery. -- --- Copyright (C) 2019-2020 Pacien TRAN-GIRARD +-- Copyright (C) 2019-2021 Pacien TRAN-GIRARD -- -- This program is free software: you can redistribute it and/or modify -- it under the terms of the GNU Affero General Public License as @@ -100,9 +100,7 @@ readSidecarFile filepath = readInputTree :: AnchoredFSNode -> IO InputTree -readInputTree (AnchoredFSNode _ File{}) = - throw $ AssertionFailed "Input directory is a file" -readInputTree (AnchoredFSNode anchor root@Dir{}) = mkDirNode root +readInputTree (AnchoredFSNode anchor root) = mkDirNode root where mkInputNode :: Map.Map FileName FSNode -> FSNode -> IO (Maybe InputTree) mkInputNode dir file@File{path} | not (isSidecar file) && not (isThumbnail file) = -- cgit v1.2.3 From ee5c85c76ac9e08a71ae09b42d11f60bd04aefca Mon Sep 17 00:00:00 2001 From: pacien Date: Sun, 4 Jul 2021 17:27:55 +0200 Subject: compiler: register distinct markdown item type --- compiler/src/ItemProcessors.hs | 6 ++++-- compiler/src/Resource.hs | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'compiler/src') diff --git a/compiler/src/ItemProcessors.hs b/compiler/src/ItemProcessors.hs index 476b7d7..fa99316 100644 --- a/compiler/src/ItemProcessors.hs +++ b/compiler/src/ItemProcessors.hs @@ -1,7 +1,7 @@ -- ldgallery - A static generator which turns a collection of tagged -- pictures into a searchable web gallery. -- --- Copyright (C) 2019-2020 Pacien TRAN-GIRARD +-- Copyright (C) 2019-2021 Pacien TRAN-GIRARD -- -- This program is free software: you can redistribute it and/or modify -- it under the terms of the GNU Affero General Public License as @@ -36,6 +36,7 @@ import Files data Format = PictureFormat | PlainTextFormat + | MarkdownFormat | PortableDocumentFormat | VideoFormat | AudioFormat @@ -56,7 +57,7 @@ formatFromPath = ".gif" -> PictureFormat ".webp" -> PictureFormat ".txt" -> PlainTextFormat - ".md" -> PlainTextFormat -- TODO: handle markdown separately + ".md" -> MarkdownFormat ".pdf" -> PortableDocumentFormat ".wav" -> AudioFormat ".oga" -> AudioFormat @@ -100,6 +101,7 @@ itemFileProcessor maxResolution = processorFor PictureFormat Nothing = transformThenDescribe copyFileProcessor getPictureProps processorFor PlainTextFormat _ = copyResource PlainText + processorFor MarkdownFormat _ = copyResource Markdown processorFor PortableDocumentFormat _ = copyResource PDF processorFor VideoFormat _ = copyResource Video 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 @@ -- ldgallery - A static generator which turns a collection of tagged -- pictures into a searchable web gallery. -- --- Copyright (C) 2019-2020 Pacien TRAN-GIRARD +-- Copyright (C) 2019-2021 Pacien TRAN-GIRARD -- -- This program is free software: you can redistribute it and/or modify -- it under the terms of the GNU Affero General Public License as @@ -90,6 +90,7 @@ data GalleryItemProps = { resource :: Resource , resolution :: Resolution } | PlainText { resource :: Resource } + | Markdown { resource :: Resource } | PDF { resource :: Resource } | Video { resource :: Resource } | Audio { resource :: Resource } -- cgit v1.2.3 From be5780ddb4e92a0292a88a75bf6923ccd1b2a049 Mon Sep 17 00:00:00 2001 From: pacien Date: Sun, 4 Sep 2022 18:14:42 +0200 Subject: compiler: reword log action for image processing Images aren't generated out of nowhere, they're processed. --- compiler/src/FileProcessors.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'compiler/src') 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 @@ -- ldgallery - A static generator which turns a collection of tagged -- pictures into a searchable web gallery. -- --- Copyright (C) 2019-2020 Pacien TRAN-GIRARD +-- Copyright (C) 2019-2022 Pacien TRAN-GIRARD -- -- This program is free software: you can redistribute it and/or modify -- it under the terms of the GNU Affero General Public License as @@ -79,7 +79,7 @@ copyFileProcessor inputPath outputPath = resizePictureUpTo :: Resolution -> FileTransformer resizePictureUpTo maxResolution inputPath outputPath = - putStrLn ("Generating:\t" ++ outputPath) + putStrLn ("Processing:\t" ++ outputPath) >> ensureParentDir (flip resize) outputPath inputPath where maxSize :: Resolution -> String -- cgit v1.2.3