aboutsummaryrefslogtreecommitdiff
path: root/compiler/src
diff options
context:
space:
mode:
authorpacien2019-12-29 13:53:28 +0100
committerpacien2019-12-29 13:53:28 +0100
commit430ab983587c525004d2aa0dc8e7707312c7ab60 (patch)
tree78ba8c88a195d06028b546b78fcad6d4382a4c0a /compiler/src
parent119d837edce4d4c109539b6722fab162ab29c0b0 (diff)
downloadldgallery-430ab983587c525004d2aa0dc8e7707312c7ab60.tar.gz
compiler: handle empty sidecar files
GitHub: closes #1
Diffstat (limited to 'compiler/src')
-rw-r--r--compiler/src/Input.hs10
1 files changed, 9 insertions, 1 deletions
diff --git a/compiler/src/Input.hs b/compiler/src/Input.hs
index 64c1933..c90db5c 100644
--- a/compiler/src/Input.hs
+++ b/compiler/src/Input.hs
@@ -69,13 +69,21 @@ data Sidecar = Sidecar
69 , tags :: Maybe [String] 69 , tags :: Maybe [String]
70 } deriving (Generic, FromJSON, Show) 70 } deriving (Generic, FromJSON, Show)
71 71
72emptySidecar :: Sidecar
73emptySidecar = Sidecar
74 { title = Nothing
75 , date = Nothing
76 , description = Nothing
77 , tags = Nothing }
78
72 79
73readInputTree :: AnchoredFSNode -> IO InputTree 80readInputTree :: AnchoredFSNode -> IO InputTree
74readInputTree (AnchoredFSNode anchor root@Dir{}) = mkDirNode root 81readInputTree (AnchoredFSNode anchor root@Dir{}) = mkDirNode root
75 where 82 where
76 mkInputNode :: FSNode -> IO (Maybe InputTree) 83 mkInputNode :: FSNode -> IO (Maybe InputTree)
77 mkInputNode (File path@(filename:pathto)) | ".yaml" `isExtensionOf` filename = 84 mkInputNode (File path@(filename:pathto)) | ".yaml" `isExtensionOf` filename =
78 decodeYamlFile (localPath $ anchor /> path) 85 (decodeYamlFile (localPath $ anchor /> path) :: IO (Maybe Sidecar))
86 >>= return . maybe emptySidecar id
79 >>= return . InputFile ((dropExtension filename):pathto) 87 >>= return . InputFile ((dropExtension filename):pathto)
80 >>= return . Just 88 >>= return . Just
81 mkInputNode File{} = return Nothing 89 mkInputNode File{} = return Nothing