From 26a85722e74eae23a22350064eed204480bbd032 Mon Sep 17 00:00:00 2001 From: pacien Date: Sun, 16 Feb 2020 12:15:08 +0100 Subject: compiler: unify directory special files --- compiler/src/Input.hs | 11 +++++++---- example/readme.md | 5 ++--- example/src/Glacier 3000/_directory.jpg | Bin 0 -> 457873 bytes example/src/Glacier 3000/_directory.yaml | 4 ++++ example/src/Glacier 3000/directory.yaml | 4 ---- example/src/Glacier 3000/thumbnail.jpg | Bin 457873 -> 0 bytes example/src/_directory.yaml | 1 + example/src/directory.yaml | 1 - ldgallery.1.md | 8 ++++---- 9 files changed, 18 insertions(+), 16 deletions(-) create mode 100644 example/src/Glacier 3000/_directory.jpg create mode 100644 example/src/Glacier 3000/_directory.yaml delete mode 100644 example/src/Glacier 3000/directory.yaml delete mode 100644 example/src/Glacier 3000/thumbnail.jpg create mode 100644 example/src/_directory.yaml delete mode 100644 example/src/directory.yaml 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 sidecarExt :: String sidecarExt = "yaml" -dirSidecar :: String -dirSidecar = "directory." ++ sidecarExt +dirPropFile :: String +dirPropFile = "_directory" + +dirSidecar :: Path +dirSidecar = Path [dirPropFile] <.> sidecarExt readSidecarFile :: FilePath -> IO Sidecar readSidecarFile filepath = @@ -111,7 +114,7 @@ readInputTree (AnchoredFSNode anchor root@Dir{}) = mkDirNode root do dirItems <- mapM mkInputNode items modTime <- getModificationTime $ localPath (anchor /> path) - sidecar <- readSidecarFile $ localPath (anchor /> path path dirSidecar) return $ InputDir path modTime sidecar (findThumbnail items) (catMaybes dirItems) isSidecar :: FSNode -> Bool @@ -125,7 +128,7 @@ readInputTree (AnchoredFSNode anchor root@Dir{}) = mkDirNode root isThumbnail File{path} = fileName path & fmap dropExtension - & (maybe False ("thumbnail" ==)) + & (maybe False (dirPropFile ==)) findThumbnail :: [FSNode] -> Maybe Path 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 ├── _DSC8808-1.jpg -- a picture ├── _DSC8808-1.jpg.yaml -- its associated sidecar metadata file ├── Glacier 3000 -- a directory grouping gallery items -│   ├── thumbnail.jpg -- a thumbnail for the "Glacier 3000" directory -│   ├── directory.yaml -- sidecar metadata file for the "Glacier 3000" directory +│   ├── _directory.jpg -- a thumbnail for the "Glacier 3000" directory +│   ├── _directory.yaml -- sidecar metadata file for the "Glacier 3000" directory │   ├── _DSC5475.jpg │   ├── _DSC5475.jpg.yaml │   ├── _DSC5542.jpg │   └── _DSC5542.jpg.yaml -├── directory.yaml -- sidecar metadata file for the root directory └── gallery.yaml -- gallery settings file ``` diff --git a/example/src/Glacier 3000/_directory.jpg b/example/src/Glacier 3000/_directory.jpg new file mode 100644 index 0000000..19a716e Binary files /dev/null and b/example/src/Glacier 3000/_directory.jpg differ diff --git a/example/src/Glacier 3000/_directory.yaml b/example/src/Glacier 3000/_directory.yaml new file mode 100644 index 0000000..44674cf --- /dev/null +++ b/example/src/Glacier 3000/_directory.yaml @@ -0,0 +1,4 @@ +# The following tags are applied to all items in the directory +tags: + - location.switzerland.ormont-dessus + - glacier3000 diff --git a/example/src/Glacier 3000/directory.yaml b/example/src/Glacier 3000/directory.yaml deleted file mode 100644 index 44674cf..0000000 --- a/example/src/Glacier 3000/directory.yaml +++ /dev/null @@ -1,4 +0,0 @@ -# The following tags are applied to all items in the directory -tags: - - location.switzerland.ormont-dessus - - glacier3000 diff --git a/example/src/Glacier 3000/thumbnail.jpg b/example/src/Glacier 3000/thumbnail.jpg deleted file mode 100644 index 19a716e..0000000 Binary files a/example/src/Glacier 3000/thumbnail.jpg and /dev/null differ diff --git a/example/src/_directory.yaml b/example/src/_directory.yaml new file mode 100644 index 0000000..ab81bb2 --- /dev/null +++ b/example/src/_directory.yaml @@ -0,0 +1 @@ +title: Example gallery diff --git a/example/src/directory.yaml b/example/src/directory.yaml deleted file mode 100644 index ab81bb2..0000000 --- a/example/src/directory.yaml +++ /dev/null @@ -1 +0,0 @@ -title: Example gallery 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: A gallery source directory contains the gallery items and their sidecar metadata files, optionally grouped inside sub-directories. -Directory thumbnails can be set by placing a picture file named "thumbnail", with any image file extension, inside of directories. +Directory thumbnails can be set by placing a picture file named "_directory", with any image file extension, inside of directories. An example input gallery directory structure could be as follows: @@ -65,8 +65,8 @@ An example input gallery directory structure could be as follows: ├── DSC0001.jpg --------- a picture ├── DSC0001.jpg.yaml ---- its associated sidecar metadata file ├── Some directory ------ a directory grouping gallery items -│ ├── thumbnail.jpg --- a thumbnail for its parent directory -│ ├── directory.yaml -- directory sidecar metadata file +│ ├── _directory.jpg -- a thumbnail for its parent directory +│ ├── _directory.yaml - directory sidecar metadata file │ ├── DSC0002.jpg │ ├── DSC0002.jpg.yaml │ ├── DSC0003.jpg @@ -80,7 +80,7 @@ An example input gallery directory structure could be as follows: File metadata are read from sidecar files of the same name, with the ".yaml" extension appended. Metadata contained within item files themselves (e.g. Exif fields for pictures) are ignored. -Directory metadata are read from sidecar files named "directory.yaml" located within the directory. +Directory metadata are read from sidecar files named "_directory.yaml" located within the directory. When a sidecar file is absent or a particular key omitted, values are set as empty or to their fallback value specified below. -- cgit v1.2.3