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')
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 44d5de0b7fdc31a940ccf50dcf50a5430dd776ae Mon Sep 17 00:00:00 2001
From: pacien
Date: Sun, 25 Oct 2020 06:51:17 +0100
Subject: compiler/stack: update Stackage LTS to 16.19
---
compiler/stack.yaml | 7 +------
compiler/stack.yaml.lock | 8 ++++----
2 files changed, 5 insertions(+), 10 deletions(-)
(limited to 'compiler')
diff --git a/compiler/stack.yaml b/compiler/stack.yaml
index 58e9b6a..67e823b 100644
--- a/compiler/stack.yaml
+++ b/compiler/stack.yaml
@@ -17,12 +17,7 @@
#
# resolver: ./custom-snapshot.yaml
# resolver: https://example.com/snapshots/2018-01-01.yaml
-
-# Important:
-# ghc 8.8.2 is required on Windows (crash during compilation)
-# version 15.3 is the latest 8.8.2, do not upgrade until this issue has been resolved
-# https://gitlab.haskell.org/ghc/ghc/issues/17926
-resolver: lts-15.3
+resolver: lts-16.19
# User packages to be built.
diff --git a/compiler/stack.yaml.lock b/compiler/stack.yaml.lock
index eeb93a9..93f79d9 100644
--- a/compiler/stack.yaml.lock
+++ b/compiler/stack.yaml.lock
@@ -6,7 +6,7 @@
packages: []
snapshots:
- completed:
- size: 491373
- url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/15/3.yaml
- sha256: 29e9ff61b8bf4b4fcff55cde3ac106ebb971f0d21331dccac9eee63374fa6ca8
- original: lts-15.3
+ size: 532177
+ url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/16/19.yaml
+ sha256: d2b828ecf50386841d0c5700b58d38566992e10d63a062af497ab29ab031faa1
+ original: lts-16.19
--
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')
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 a4425869ea15234fee79b7d1219a3bea7ffb23a2 Mon Sep 17 00:00:00 2001
From: pacien
Date: Fri, 25 Jun 2021 12:03:55 +0200
Subject: license: make it more obvious for end users
---
compiler/app/Main.hs | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
(limited to 'compiler')
diff --git a/compiler/app/Main.hs b/compiler/app/Main.hs
index e71e0db..dc97b38 100644
--- a/compiler/app/Main.hs
+++ b/compiler/app/Main.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
@@ -94,6 +94,7 @@ options = Options
}
&= summary ("ldgallery v" ++ showVersion version ++ " - a static web gallery generator with tags")
+ &= details ["This software is distributed under the terms of the GNU Affero General Public License v3.0."]
&= program "ldgallery"
&= help "Compile a gallery"
&= helpArg [explicit, name "h", name "help"]
--
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')
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 671a372d87ff8311956f9158e8885ffc254fe1bc Mon Sep 17 00:00:00 2001
From: pacien
Date: Tue, 29 Jun 2021 13:14:14 +0200
Subject: compiler: add "portable" target
This adds a build flag for generating a portable version of the compiler
binary which make it look in its own runtime directory for its assets.
This is useful in particular for the portable release tarballs which
contain the web viewer at the same location instead of a pre-defined one
in the FHS.
GitHub: closes #286
---
compiler/app/Main.hs | 29 +++++++++++++----------------
compiler/app/ViewerDist.hs | 39 +++++++++++++++++++++++++++++++++++++++
compiler/package.yaml | 14 +++++++++++++-
3 files changed, 65 insertions(+), 17 deletions(-)
create mode 100644 compiler/app/ViewerDist.hs
(limited to 'compiler')
diff --git a/compiler/app/Main.hs b/compiler/app/Main.hs
index dc97b38..3e6f254 100644
--- a/compiler/app/Main.hs
+++ b/compiler/app/Main.hs
@@ -19,7 +19,7 @@
module Main where
import GHC.Generics (Generic)
-import Paths_ldgallery_compiler (version, getDataFileName)
+import Paths_ldgallery_compiler (version)
import Control.Monad (when)
import Data.Functor ((<&>))
import Data.Maybe (isJust)
@@ -31,7 +31,7 @@ import System.Console.CmdArgs
import Compiler
import Files (readDirectory, copyTo, remove)
-
+import ViewerDist (viewerDistPath)
newtype ViewerConfig = ViewerConfig
{ galleryRoot :: String
@@ -106,10 +106,7 @@ main =
do
opts <- cmdArgs options
buildGallery opts
-
- when (isJust $ withViewer opts) $ do
- viewerDist <- viewerDistPath $ withViewer opts
- deployViewer viewerDist opts
+ deployViewer opts
where
gallerySubdir :: String
@@ -118,11 +115,6 @@ main =
viewerConfig :: ViewerConfig
viewerConfig = ViewerConfig (gallerySubdir ++ "/")
- viewerDistPath :: Maybe FilePath -> IO FilePath
- viewerDistPath (Just "") = getDataFileName "viewer"
- viewerDistPath (Just dist) = return dist
- viewerDistPath Nothing = fail "No viewer distribution"
-
buildGallery :: Options -> IO ()
buildGallery opts =
checkDistinctPaths (inputDir opts) (outputDir opts)
@@ -146,10 +138,11 @@ main =
| isJust withViewer = outputDir > gallerySubdir
| otherwise = outputDir
- deployViewer :: FilePath -> Options -> IO ()
- deployViewer distPath Options{outputDir, cleanOutput} =
+ deployViewer :: Options -> IO ()
+ deployViewer Options{withViewer = Nothing} = pure ()
+ deployViewer Options{withViewer = Just viewerPath, outputDir, cleanOutput} =
when cleanOutput (cleanViewerDir outputDir)
- >> copyViewer distPath outputDir
+ >> viewerDistOr viewerPath >>= deployTo outputDir
>> writeJSON (outputDir > "config.json") viewerConfig
where
@@ -159,8 +152,12 @@ main =
<&> filter (/= gallerySubdir)
>>= mapM_ (remove . (target >))
- copyViewer :: FilePath -> FilePath -> IO ()
- copyViewer dist target =
+ viewerDistOr :: FilePath -> IO FilePath
+ viewerDistOr "" = viewerDistPath
+ viewerDistOr custom = pure custom
+
+ deployTo :: FilePath -> FilePath -> IO ()
+ deployTo target dist =
putStrLn "Copying viewer webapp"
>> readDirectory dist
>>= copyTo target
diff --git a/compiler/app/ViewerDist.hs b/compiler/app/ViewerDist.hs
new file mode 100644
index 0000000..2b80ffc
--- /dev/null
+++ b/compiler/app/ViewerDist.hs
@@ -0,0 +1,39 @@
+-- ldgallery - A static generator which turns a collection of tagged
+-- pictures into a searchable web gallery.
+--
+-- Copyright (C) 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
+-- published by the Free Software Foundation, either version 3 of the
+-- License, or (at your option) any later version.
+--
+-- This program is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU Affero General Public License for more details.
+--
+-- You should have received a copy of the GNU Affero General Public License
+-- along with this program. If not, see .
+
+{-# LANGUAGE CPP #-}
+
+module ViewerDist where
+
+#ifndef FLAG_PORTABLE
+
+import Paths_ldgallery_compiler (getDataFileName)
+
+viewerDistPath = getDataFileName "viewer"
+
+#else
+
+import Data.Functor ((<&>))
+import System.FilePath (takeDirectory, (>))
+import System.Environment (getExecutablePath)
+
+viewerDistPath = fmap takeDirectory getExecutablePath <&> (> "viewer")
+
+#endif
+
+viewerDistPath :: IO FilePath
diff --git a/compiler/package.yaml b/compiler/package.yaml
index faa2174..b02a40a 100644
--- a/compiler/package.yaml
+++ b/compiler/package.yaml
@@ -5,7 +5,7 @@ github: "pacien/ldgallery"
license: AGPL-3
author: "Pacien TRAN-GIRARD, Guillaume FOUET"
maintainer: ""
-copyright: "2019-2020 Pacien TRAN-GIRARD, Guillaume FOUET"
+copyright: "2019-2021 Pacien TRAN-GIRARD, Guillaume FOUET"
extra-source-files:
- readme.md
@@ -54,6 +54,15 @@ data-files: ["**/*"]
library:
source-dirs: src
+flags:
+ portable:
+ description: >
+ Make the output binary portable.
+ It will look in its own runtime location for its assets instead of
+ absolute installation paths.
+ manual: true
+ default: false
+
executables:
ldgallery:
main: Main.hs
@@ -64,6 +73,9 @@ executables:
- -with-rtsopts=-N
dependencies:
- ldgallery-compiler
+ when:
+ - condition: flag(portable)
+ cpp-options: -DFLAG_PORTABLE
tests:
ldgallery-compiler-test:
--
cgit v1.2.3
From 083f0658399afc206ea0751415d54a50d2aa4fe9 Mon Sep 17 00:00:00 2001
From: Zero~Informatique
Date: Tue, 29 Jun 2021 16:53:44 +0200
Subject: compiler: updated build script with arguments matching the CI
---
compiler/.gitignore | 1 +
1 file changed, 1 insertion(+)
(limited to 'compiler')
diff --git a/compiler/.gitignore b/compiler/.gitignore
index 778e7ef..3415fc8 100644
--- a/compiler/.gitignore
+++ b/compiler/.gitignore
@@ -1,3 +1,4 @@
.stack-work/
+dist/
ldgallery-compiler.cabal
*~
\ No newline at end of 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')
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 ce673a4b66c62fb0595c81cb79ba9d30768a9679 Mon Sep 17 00:00:00 2001
From: pacien
Date: Sun, 4 Sep 2022 17:12:46 +0200
Subject: project: set new version for release 2.1
---
compiler/ldgallery.1.md | 4 ++--
compiler/package.yaml | 3 +--
2 files changed, 3 insertions(+), 4 deletions(-)
(limited to 'compiler')
diff --git a/compiler/ldgallery.1.md b/compiler/ldgallery.1.md
index eda6cc2..2e247cd 100644
--- a/compiler/ldgallery.1.md
+++ b/compiler/ldgallery.1.md
@@ -2,7 +2,7 @@
pagetitle: Compiler user manual - ldgallery
title: LDGALLERY(1) ldgallery
author: Pacien TRAN-GIRARD, Guillaume FOUET
-date: 2020-09-19 (v2.0)
+date: 2022-09-04 (v2.1)
---
@@ -187,7 +187,7 @@ The ldgallery source code is available on .
# LICENSE
-Copyright (C) 2019-2020 Pacien TRAN-GIRARD and Guillaume FOUET.
+Copyright (C) 2019-2022 Pacien TRAN-GIRARD and Guillaume FOUET.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
diff --git a/compiler/package.yaml b/compiler/package.yaml
index b02a40a..7bd86e9 100644
--- a/compiler/package.yaml
+++ b/compiler/package.yaml
@@ -1,10 +1,9 @@
name: ldgallery-compiler
-version: 2.0
+version: 2.1
homepage: https://ldgallery.pacien.org
github: "pacien/ldgallery"
license: AGPL-3
author: "Pacien TRAN-GIRARD, Guillaume FOUET"
-maintainer: ""
copyright: "2019-2021 Pacien TRAN-GIRARD, Guillaume FOUET"
extra-source-files:
--
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')
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