aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpacien2022-10-30 01:05:45 +0200
committerpacien2022-10-30 01:10:54 +0200
commit0fddc74a3f9add47841124b4d77b097f4646d14f (patch)
treee0e841d9cfc101a1247e9526f7cf65d50d4ed4c2
parentf864eeca506331c1dee2cd3f5f0df4fe806f303a (diff)
downloadldgallery-0fddc74a3f9add47841124b4d77b097f4646d14f.tar.gz
compiler: fix support for non-utf8 terminals
The compiler echoes the names of the files being processed. Those file names may contain UTF-8 characters. However, some consoles may not support those. This is notably the case of the Windows CMD or on Linux with the legacy C locale. This caused the following error: ldgallery: <stdout>: commitBuffer: invalid argument (invalid character) This patch adds automatic transliteration when a non-UTF8 terminal is detected, so that neither the compiler or the terminal crash due to UTF8 characters. GitHub: closes #341
-rw-r--r--changelog.md1
-rw-r--r--compiler/app/Main.hs5
-rw-r--r--compiler/package.yaml3
-rw-r--r--flake.nix2
4 files changed, 6 insertions, 5 deletions
diff --git a/changelog.md b/changelog.md
index 0cf3194..9afc27a 100644
--- a/changelog.md
+++ b/changelog.md
@@ -10,6 +10,7 @@ release. Releases are tracked and referred to using git tags.
10- Bug fixes: 10- Bug fixes:
11 - compiler: fix detection of dimensions of EXIF-rotated pictures. 11 - compiler: fix detection of dimensions of EXIF-rotated pictures.
12 Rebuild the gallery with `--rebuild-all` to purge erroneous cached data. 12 Rebuild the gallery with `--rebuild-all` to purge erroneous cached data.
13 - compiler: fix support for non-UTF8 terminals.
13 - viewer: fix theme quirks (line spacing, icon colours). 14 - viewer: fix theme quirks (line spacing, icon colours).
14 - viewer: fix ghost keyboard hints when the search panel is closed. 15 - viewer: fix ghost keyboard hints when the search panel is closed.
15 16
diff --git a/compiler/app/Main.hs b/compiler/app/Main.hs
index 3e6f254..a9630ce 100644
--- a/compiler/app/Main.hs
+++ b/compiler/app/Main.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-2021 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
@@ -28,6 +28,7 @@ import Data.Aeson (ToJSON)
28import System.FilePath ((</>)) 28import System.FilePath ((</>))
29import System.Directory (canonicalizePath, listDirectory) 29import System.Directory (canonicalizePath, listDirectory)
30import System.Console.CmdArgs 30import System.Console.CmdArgs
31import Main.Utf8 (withUtf8)
31 32
32import Compiler 33import Compiler
33import Files (readDirectory, copyTo, remove) 34import Files (readDirectory, copyTo, remove)
@@ -103,7 +104,7 @@ options = Options
103 104
104main :: IO () 105main :: IO ()
105main = 106main =
106 do 107 withUtf8 $ do
107 opts <- cmdArgs options 108 opts <- cmdArgs options
108 buildGallery opts 109 buildGallery opts
109 deployViewer opts 110 deployViewer opts
diff --git a/compiler/package.yaml b/compiler/package.yaml
index 7bd86e9..0c07efe 100644
--- a/compiler/package.yaml
+++ b/compiler/package.yaml
@@ -4,7 +4,7 @@ homepage: https://ldgallery.pacien.org
4github: "pacien/ldgallery" 4github: "pacien/ldgallery"
5license: AGPL-3 5license: AGPL-3
6author: "Pacien TRAN-GIRARD, Guillaume FOUET" 6author: "Pacien TRAN-GIRARD, Guillaume FOUET"
7copyright: "2019-2021 Pacien TRAN-GIRARD, Guillaume FOUET" 7copyright: "2019-2022 Pacien TRAN-GIRARD, Guillaume FOUET"
8 8
9extra-source-files: 9extra-source-files:
10- readme.md 10- readme.md
@@ -29,6 +29,7 @@ dependencies:
29- safe 29- safe
30- time 30- time
31- process 31- process
32- with-utf8
32 33
33default-extensions: 34default-extensions:
34- DuplicateRecordFields 35- DuplicateRecordFields
diff --git a/flake.nix b/flake.nix
index 688601c..93d4f2e 100644
--- a/flake.nix
+++ b/flake.nix
@@ -123,8 +123,6 @@
123 src = ./example; 123 src = ./example;
124 nativeBuildInputs = [ ldgallery ]; 124 nativeBuildInputs = [ ldgallery ];
125 buildPhase = '' 125 buildPhase = ''
126 # Need UTF-8: https://github.com/ldgallery/ldgallery/issues/341
127 export LC_ALL=C.UTF-8
128 ldgallery --input-dir src --output-dir $out --with-viewer 126 ldgallery --input-dir src --output-dir $out --with-viewer
129 ''; 127 '';
130 installPhase = ":"; 128 installPhase = ":";