diff options
author | pacien | 2020-02-16 12:15:08 +0100 |
---|---|---|
committer | Notkea | 2020-02-17 21:07:39 +0100 |
commit | 26a85722e74eae23a22350064eed204480bbd032 (patch) | |
tree | f5dd1a192ec59a7445f4e83da65cf2ba3e1020ff | |
parent | 395a76bc4193c0c7182f87778458a68d0079e836 (diff) | |
download | ldgallery-26a85722e74eae23a22350064eed204480bbd032.tar.gz |
compiler: unify directory special files
-rw-r--r-- | compiler/src/Input.hs | 11 | ||||
-rw-r--r-- | example/readme.md | 5 | ||||
-rw-r--r-- | example/src/Glacier 3000/_directory.jpg (renamed from example/src/Glacier 3000/thumbnail.jpg) | bin | 457873 -> 457873 bytes | |||
-rw-r--r-- | example/src/Glacier 3000/_directory.yaml (renamed from example/src/Glacier 3000/directory.yaml) | 0 | ||||
-rw-r--r-- | example/src/_directory.yaml (renamed from example/src/directory.yaml) | 0 | ||||
-rw-r--r-- | ldgallery.1.md | 8 |
6 files changed, 13 insertions, 11 deletions
diff --git a/compiler/src/Input.hs b/compiler/src/Input.hs index e0fc8ef..75d1ed3 100644 --- a/compiler/src/Input.hs +++ b/compiler/src/Input.hs | |||
@@ -80,8 +80,11 @@ emptySidecar = Sidecar | |||
80 | sidecarExt :: String | 80 | sidecarExt :: String |
81 | sidecarExt = "yaml" | 81 | sidecarExt = "yaml" |
82 | 82 | ||
83 | dirSidecar :: String | 83 | dirPropFile :: String |
84 | dirSidecar = "directory." ++ sidecarExt | 84 | dirPropFile = "_directory" |
85 | |||
86 | dirSidecar :: Path | ||
87 | dirSidecar = Path [dirPropFile] <.> sidecarExt | ||
85 | 88 | ||
86 | readSidecarFile :: FilePath -> IO Sidecar | 89 | readSidecarFile :: FilePath -> IO Sidecar |
87 | readSidecarFile filepath = | 90 | readSidecarFile filepath = |
@@ -111,7 +114,7 @@ readInputTree (AnchoredFSNode anchor root@Dir{}) = mkDirNode root | |||
111 | do | 114 | do |
112 | dirItems <- mapM mkInputNode items | 115 | dirItems <- mapM mkInputNode items |
113 | modTime <- getModificationTime $ localPath (anchor /> path) | 116 | modTime <- getModificationTime $ localPath (anchor /> path) |
114 | sidecar <- readSidecarFile $ localPath (anchor /> path </ dirSidecar) | 117 | sidecar <- readSidecarFile $ localPath (anchor /> path </> dirSidecar) |
115 | return $ InputDir path modTime sidecar (findThumbnail items) (catMaybes dirItems) | 118 | return $ InputDir path modTime sidecar (findThumbnail items) (catMaybes dirItems) |
116 | 119 | ||
117 | isSidecar :: FSNode -> Bool | 120 | isSidecar :: FSNode -> Bool |
@@ -125,7 +128,7 @@ readInputTree (AnchoredFSNode anchor root@Dir{}) = mkDirNode root | |||
125 | isThumbnail File{path} = | 128 | isThumbnail File{path} = |
126 | fileName path | 129 | fileName path |
127 | & fmap dropExtension | 130 | & fmap dropExtension |
128 | & (maybe False ("thumbnail" ==)) | 131 | & (maybe False (dirPropFile ==)) |
129 | 132 | ||
130 | findThumbnail :: [FSNode] -> Maybe Path | 133 | findThumbnail :: [FSNode] -> Maybe Path |
131 | findThumbnail = (fmap Files.path) . (find isThumbnail) | 134 | findThumbnail = (fmap Files.path) . (find isThumbnail) |
diff --git a/example/readme.md b/example/readme.md index eafdaf5..809ae68 100644 --- a/example/readme.md +++ b/example/readme.md | |||
@@ -13,12 +13,11 @@ Content | |||
13 | ├── _DSC8808-1.jpg -- a picture | 13 | ├── _DSC8808-1.jpg -- a picture |
14 | ├── _DSC8808-1.jpg.yaml -- its associated sidecar metadata file | 14 | ├── _DSC8808-1.jpg.yaml -- its associated sidecar metadata file |
15 | ├── Glacier 3000 -- a directory grouping gallery items | 15 | ├── Glacier 3000 -- a directory grouping gallery items |
16 | │ ├── thumbnail.jpg -- a thumbnail for the "Glacier 3000" directory | 16 | │ ├── _directory.jpg -- a thumbnail for the "Glacier 3000" directory |
17 | │ ├── directory.yaml -- sidecar metadata file for the "Glacier 3000" directory | 17 | │ ├── _directory.yaml -- sidecar metadata file for the "Glacier 3000" directory |
18 | │ ├── _DSC5475.jpg | 18 | │ ├── _DSC5475.jpg |
19 | │ ├── _DSC5475.jpg.yaml | 19 | │ ├── _DSC5475.jpg.yaml |
20 | │ ├── _DSC5542.jpg | 20 | │ ├── _DSC5542.jpg |
21 | │ └── _DSC5542.jpg.yaml | 21 | │ └── _DSC5542.jpg.yaml |
22 | ├── directory.yaml -- sidecar metadata file for the root directory | ||
23 | └── gallery.yaml -- gallery settings file | 22 | └── gallery.yaml -- gallery settings file |
24 | ``` | 23 | ``` |
diff --git a/example/src/Glacier 3000/thumbnail.jpg b/example/src/Glacier 3000/_directory.jpg index 19a716e..19a716e 100644 --- a/example/src/Glacier 3000/thumbnail.jpg +++ b/example/src/Glacier 3000/_directory.jpg | |||
Binary files differ | |||
diff --git a/example/src/Glacier 3000/directory.yaml b/example/src/Glacier 3000/_directory.yaml index 44674cf..44674cf 100644 --- a/example/src/Glacier 3000/directory.yaml +++ b/example/src/Glacier 3000/_directory.yaml | |||
diff --git a/example/src/directory.yaml b/example/src/_directory.yaml index ab81bb2..ab81bb2 100644 --- a/example/src/directory.yaml +++ b/example/src/_directory.yaml | |||
diff --git a/ldgallery.1.md b/ldgallery.1.md index 17056ce..91724a6 100644 --- a/ldgallery.1.md +++ b/ldgallery.1.md | |||
@@ -56,7 +56,7 @@ Available options are: | |||
56 | 56 | ||
57 | A gallery source directory contains the gallery items and their sidecar metadata files, optionally grouped inside sub-directories. | 57 | A gallery source directory contains the gallery items and their sidecar metadata files, optionally grouped inside sub-directories. |
58 | 58 | ||
59 | Directory thumbnails can be set by placing a picture file named "thumbnail", with any image file extension, inside of directories. | 59 | Directory thumbnails can be set by placing a picture file named "_directory", with any image file extension, inside of directories. |
60 | 60 | ||
61 | An example input gallery directory structure could be as follows: | 61 | An example input gallery directory structure could be as follows: |
62 | 62 | ||
@@ -65,8 +65,8 @@ An example input gallery directory structure could be as follows: | |||
65 | ├── DSC0001.jpg --------- a picture | 65 | ├── DSC0001.jpg --------- a picture |
66 | ├── DSC0001.jpg.yaml ---- its associated sidecar metadata file | 66 | ├── DSC0001.jpg.yaml ---- its associated sidecar metadata file |
67 | ├── Some directory ------ a directory grouping gallery items | 67 | ├── Some directory ------ a directory grouping gallery items |
68 | │ ├── thumbnail.jpg --- a thumbnail for its parent directory | 68 | │ ├── _directory.jpg -- a thumbnail for its parent directory |
69 | │ ├── directory.yaml -- directory sidecar metadata file | 69 | │ ├── _directory.yaml - directory sidecar metadata file |
70 | │ ├── DSC0002.jpg | 70 | │ ├── DSC0002.jpg |
71 | │ ├── DSC0002.jpg.yaml | 71 | │ ├── DSC0002.jpg.yaml |
72 | │ ├── DSC0003.jpg | 72 | │ ├── DSC0003.jpg |
@@ -80,7 +80,7 @@ An example input gallery directory structure could be as follows: | |||
80 | File metadata are read from sidecar files of the same name, with the ".yaml" extension appended. | 80 | File metadata are read from sidecar files of the same name, with the ".yaml" extension appended. |
81 | Metadata contained within item files themselves (e.g. Exif fields for pictures) are ignored. | 81 | Metadata contained within item files themselves (e.g. Exif fields for pictures) are ignored. |
82 | 82 | ||
83 | Directory metadata are read from sidecar files named "directory.yaml" located within the directory. | 83 | Directory metadata are read from sidecar files named "_directory.yaml" located within the directory. |
84 | 84 | ||
85 | When a sidecar file is absent or a particular key omitted, values are set as empty or to their fallback value specified below. | 85 | When a sidecar file is absent or a particular key omitted, values are set as empty or to their fallback value specified below. |
86 | 86 | ||