diff options
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/app/Main.hs | 17 | ||||
-rw-r--r-- | compiler/ldgallery.1.md | 48 | ||||
-rw-r--r-- | compiler/package.yaml | 2 | ||||
-rw-r--r-- | compiler/src/Caching.hs | 76 | ||||
-rw-r--r-- | compiler/src/Compiler.hs | 74 | ||||
-rw-r--r-- | compiler/src/Config.hs | 6 | ||||
-rw-r--r-- | compiler/src/FileProcessors.hs | 128 | ||||
-rw-r--r-- | compiler/src/Files.hs | 36 | ||||
-rw-r--r-- | compiler/src/Input.hs | 65 | ||||
-rw-r--r-- | compiler/src/ItemProcessors.hs | 115 | ||||
-rw-r--r-- | compiler/src/Processors.hs | 203 | ||||
-rw-r--r-- | compiler/src/Resource.hs | 90 |
12 files changed, 528 insertions, 332 deletions
diff --git a/compiler/app/Main.hs b/compiler/app/Main.hs index 48e5644..e71e0db 100644 --- a/compiler/app/Main.hs +++ b/compiler/app/Main.hs | |||
@@ -21,6 +21,7 @@ module Main where | |||
21 | import GHC.Generics (Generic) | 21 | import GHC.Generics (Generic) |
22 | import Paths_ldgallery_compiler (version, getDataFileName) | 22 | import Paths_ldgallery_compiler (version, getDataFileName) |
23 | import Control.Monad (when) | 23 | import Control.Monad (when) |
24 | import Data.Functor ((<&>)) | ||
24 | import Data.Maybe (isJust) | 25 | import Data.Maybe (isJust) |
25 | import Data.Version (showVersion) | 26 | import Data.Version (showVersion) |
26 | import Data.Aeson (ToJSON) | 27 | import Data.Aeson (ToJSON) |
@@ -32,7 +33,7 @@ import Compiler | |||
32 | import Files (readDirectory, copyTo, remove) | 33 | import Files (readDirectory, copyTo, remove) |
33 | 34 | ||
34 | 35 | ||
35 | data ViewerConfig = ViewerConfig | 36 | newtype ViewerConfig = ViewerConfig |
36 | { galleryRoot :: String | 37 | { galleryRoot :: String |
37 | } deriving (Generic, Show, ToJSON) | 38 | } deriving (Generic, Show, ToJSON) |
38 | 39 | ||
@@ -42,7 +43,7 @@ data Options = Options | |||
42 | , outputDir :: FilePath | 43 | , outputDir :: FilePath |
43 | , outputIndex :: FilePath | 44 | , outputIndex :: FilePath |
44 | , galleryConfig :: FilePath | 45 | , galleryConfig :: FilePath |
45 | , rebuilAll :: Bool | 46 | , rebuildAll :: Bool |
46 | , cleanOutput :: Bool | 47 | , cleanOutput :: Bool |
47 | , withViewer :: Maybe FilePath | 48 | , withViewer :: Maybe FilePath |
48 | } deriving (Show, Data, Typeable) | 49 | } deriving (Show, Data, Typeable) |
@@ -73,7 +74,7 @@ options = Options | |||
73 | &= name "gallery-config" | 74 | &= name "gallery-config" |
74 | &= explicit | 75 | &= explicit |
75 | &= help "Gallery configuration file (default=<input-dir>/gallery.yaml)" | 76 | &= help "Gallery configuration file (default=<input-dir>/gallery.yaml)" |
76 | , rebuilAll = False | 77 | , rebuildAll = False |
77 | &= name "r" | 78 | &= name "r" |
78 | &= name "rebuild-all" | 79 | &= name "rebuild-all" |
79 | &= explicit | 80 | &= explicit |
@@ -92,7 +93,7 @@ options = Options | |||
92 | &= help "Deploy either the bundled or the given static web viewer to the output directory" | 93 | &= help "Deploy either the bundled or the given static web viewer to the output directory" |
93 | } | 94 | } |
94 | 95 | ||
95 | &= summary ("ldgallery v" ++ (showVersion version) ++ " - a static web gallery generator with tags") | 96 | &= summary ("ldgallery v" ++ showVersion version ++ " - a static web gallery generator with tags") |
96 | &= program "ldgallery" | 97 | &= program "ldgallery" |
97 | &= help "Compile a gallery" | 98 | &= help "Compile a gallery" |
98 | &= helpArg [explicit, name "h", name "help"] | 99 | &= helpArg [explicit, name "h", name "help"] |
@@ -130,7 +131,7 @@ main = | |||
130 | (galleryOutputDir opts) | 131 | (galleryOutputDir opts) |
131 | (outputIndex opts) | 132 | (outputIndex opts) |
132 | [outputDir opts] | 133 | [outputDir opts] |
133 | (rebuilAll opts) | 134 | (rebuildAll opts) |
134 | (cleanOutput opts) | 135 | (cleanOutput opts) |
135 | where | 136 | where |
136 | checkDistinctPaths :: FilePath -> FilePath -> IO () | 137 | checkDistinctPaths :: FilePath -> FilePath -> IO () |
@@ -146,7 +147,7 @@ main = | |||
146 | 147 | ||
147 | deployViewer :: FilePath -> Options -> IO () | 148 | deployViewer :: FilePath -> Options -> IO () |
148 | deployViewer distPath Options{outputDir, cleanOutput} = | 149 | deployViewer distPath Options{outputDir, cleanOutput} = |
149 | (when cleanOutput $ cleanViewerDir outputDir) | 150 | when cleanOutput (cleanViewerDir outputDir) |
150 | >> copyViewer distPath outputDir | 151 | >> copyViewer distPath outputDir |
151 | >> writeJSON (outputDir </> "config.json") viewerConfig | 152 | >> writeJSON (outputDir </> "config.json") viewerConfig |
152 | 153 | ||
@@ -154,8 +155,8 @@ main = | |||
154 | cleanViewerDir :: FilePath -> IO () | 155 | cleanViewerDir :: FilePath -> IO () |
155 | cleanViewerDir target = | 156 | cleanViewerDir target = |
156 | listDirectory target | 157 | listDirectory target |
157 | >>= return . filter (/= gallerySubdir) | 158 | <&> filter (/= gallerySubdir) |
158 | >>= mapM_ remove . map (target </>) | 159 | >>= mapM_ (remove . (target </>)) |
159 | 160 | ||
160 | copyViewer :: FilePath -> FilePath -> IO () | 161 | copyViewer :: FilePath -> FilePath -> IO () |
161 | copyViewer dist target = | 162 | copyViewer dist target = |
diff --git a/compiler/ldgallery.1.md b/compiler/ldgallery.1.md index a60a3b1..eda6cc2 100644 --- a/compiler/ldgallery.1.md +++ b/compiler/ldgallery.1.md | |||
@@ -2,7 +2,7 @@ | |||
2 | pagetitle: Compiler user manual - ldgallery | 2 | pagetitle: Compiler user manual - ldgallery |
3 | title: LDGALLERY(1) ldgallery | 3 | title: LDGALLERY(1) ldgallery |
4 | author: Pacien TRAN-GIRARD, Guillaume FOUET | 4 | author: Pacien TRAN-GIRARD, Guillaume FOUET |
5 | date: 2020-04-30 (v1.0) | 5 | date: 2020-09-19 (v2.0) |
6 | --- | 6 | --- |
7 | 7 | ||
8 | 8 | ||
@@ -13,7 +13,7 @@ ldgallery - a static web gallery generator with tags | |||
13 | 13 | ||
14 | # DESCRIPTION | 14 | # DESCRIPTION |
15 | 15 | ||
16 | ldgallery is a static gallery generator which turns a collection of tagged pictures into a searchable web gallery. | 16 | ldgallery is a static gallery generator which turns a collection of tagged media files into a searchable web gallery. |
17 | 17 | ||
18 | The ldgallery compiler program processes pictures and aggregates metadata from plain text sidecar files to generate an indexed version of the gallery. | 18 | The ldgallery compiler program processes pictures and aggregates metadata from plain text sidecar files to generate an indexed version of the gallery. |
19 | It can optionally output a static web viewer along, which allows the content to be presented and searched through from a JavaScript-enabled web browser. | 19 | It can optionally output a static web viewer along, which allows the content to be presented and searched through from a JavaScript-enabled web browser. |
@@ -45,6 +45,7 @@ Available options are: | |||
45 | 45 | ||
46 | -r, \--rebuild-all | 46 | -r, \--rebuild-all |
47 | : Invalidate cache and recompile everything. | 47 | : Invalidate cache and recompile everything. |
48 | By default, the compiler skips items which haven't changed based on their modification time. | ||
48 | 49 | ||
49 | -c, \--clean-output | 50 | -c, \--clean-output |
50 | : Remove unnecessary files from the output directory. | 51 | : Remove unnecessary files from the output directory. |
@@ -67,22 +68,24 @@ Available options are: | |||
67 | 68 | ||
68 | A gallery source directory contains the gallery items and their sidecar metadata files, optionally grouped inside sub-directories. | 69 | A gallery source directory contains the gallery items and their sidecar metadata files, optionally grouped inside sub-directories. |
69 | 70 | ||
70 | Directory thumbnails can be set by placing a picture file named "_directory", with any image file extension, inside of directories. | 71 | Thumbnails can be associated to items by suffixing their name with "\_thumbnail", followed by an image file extension. |
72 | Directory thumbnails can be placed within their respective directories themselves, without any prefix. | ||
71 | 73 | ||
72 | An example input gallery directory structure could be as follows: | 74 | An example input gallery directory structure could be as follows: |
73 | 75 | ||
74 | ``` | 76 | ``` |
75 | ./example-gallery | 77 | ./example-gallery |
76 | ├── DSC0001.jpg --------- a picture | 78 | ├── DSC0001.jpg ----------------- a picture |
77 | ├── DSC0001.jpg.yaml ---- its associated sidecar metadata file | 79 | ├── DSC0001.jpg.yaml ------------ its associated sidecar metadata file |
78 | ├── Some directory ------ a directory grouping gallery items | 80 | ├── Some directory -------------- a directory grouping gallery items |
79 | │ ├── _directory.jpg -- a thumbnail for its parent directory | 81 | │ ├── _directory.yaml --------- directory sidecar metadata file |
80 | │ ├── _directory.yaml - directory sidecar metadata file | 82 | │ ├── _thumbnail.jpg ---------- a thumbnail for its parent directory |
81 | │ ├── DSC0002.jpg | 83 | │ ├── DSC0002.jpg |
82 | │ ├── DSC0002.jpg.yaml | 84 | │ ├── DSC0002.jpg.yaml |
83 | │ ├── DSC0003.jpg | 85 | │ ├── song.ogg |
84 | │ └── DSC0003.jpg.yaml | 86 | │ ├── song.ogg.yaml |
85 | └── gallery.yaml -------- gallery settings file | 87 | │ └── song.ogg_thumbnail.jpg -- a thumbnail for song.ogg |
88 | └── gallery.yaml ---------------- gallery settings file | ||
86 | ``` | 89 | ``` |
87 | 90 | ||
88 | 91 | ||
@@ -91,7 +94,7 @@ An example input gallery directory structure could be as follows: | |||
91 | File metadata are read from sidecar files of the same name, with the ".yaml" extension appended. | 94 | File metadata are read from sidecar files of the same name, with the ".yaml" extension appended. |
92 | Metadata contained within item files themselves (e.g. Exif fields for pictures) are ignored. | 95 | Metadata contained within item files themselves (e.g. Exif fields for pictures) are ignored. |
93 | 96 | ||
94 | Directory metadata are read from sidecar files named "_directory.yaml" located within the directory. | 97 | Directory metadata are read from sidecar files named "\_directory.yaml" located within the directory. |
95 | 98 | ||
96 | When a sidecar file is absent or a particular key omitted, values are set as empty or to their fallback value specified below. | 99 | When a sidecar file is absent or a particular key omitted, values are set as empty or to their fallback value specified below. |
97 | 100 | ||
@@ -99,17 +102,16 @@ title | |||
99 | : Title of the item. | 102 | : Title of the item. |
100 | Defaults to the name of the file or directory. | 103 | Defaults to the name of the file or directory. |
101 | 104 | ||
102 | <!-- not used in the viewer yet -- | ||
103 | datetime | 105 | datetime |
104 | : ISO 8601 zoned date and time. | 106 | : ISO 8601 zoned date and time. |
105 | Defaults to the last modification time of the file itself, | 107 | Defaults to the last modification time of the file itself, |
106 | or the most recent modification date of a directory's items. | 108 | or the most recent modification date of a directory's items. |
107 | --> | ||
108 | 109 | ||
109 | <!-- not used in the viewer yet -- | ||
110 | description | 110 | description |
111 | : Description for the item. | 111 | : Optional description for the item. |
112 | --> | 112 | Rich text formatting is possible through the use of the [GitHub Flavoured Markdown syntax][GFM]. |
113 | |||
114 | [GFM]: https://github.github.com/gfm/ | ||
113 | 115 | ||
114 | tags | 116 | tags |
115 | : List of tags for the item. | 117 | : List of tags for the item. |
@@ -119,7 +121,9 @@ tags | |||
119 | 121 | ||
120 | # GALLERY CONFIGURATION | 122 | # GALLERY CONFIGURATION |
121 | 123 | ||
122 | The gallery settings reside in a file named "gallery.yaml" located at the root of the gallery's source directory. | 124 | The gallery settings reside in a file named __gallery.yaml__ located at the root of the gallery's source directory. |
125 | |||
126 | Gallery configurations options are: | ||
123 | 127 | ||
124 | galleryTitle | 128 | galleryTitle |
125 | : Title of the gallery. | 129 | : Title of the gallery. |
@@ -127,7 +131,7 @@ galleryTitle | |||
127 | 131 | ||
128 | includedDirectories[] | 132 | includedDirectories[] |
129 | : Glob patterns of directory names to include in the gallery. | 133 | : Glob patterns of directory names to include in the gallery. |
130 | Defaults to ["*"] (matches all directory names). | 134 | Defaults to ["\*"] (matches all directory names). |