From 04d5cb917f4288c26a308dfda4ba788d77fda8fd Mon Sep 17 00:00:00 2001 From: pacien Date: Wed, 13 May 2020 00:18:16 +0200 Subject: compiler: add plain text file format support through simple copy --- compiler/src/Processors.hs | 7 +++++-- compiler/src/Resource.hs | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'compiler') diff --git a/compiler/src/Processors.hs b/compiler/src/Processors.hs index 02db325..ca8a74c 100644 --- a/compiler/src/Processors.hs +++ b/compiler/src/Processors.hs @@ -47,8 +47,8 @@ data ProcessingException = ProcessingException FilePath String deriving Show instance Exception ProcessingException --- TODO: handle video, music, text... -data Format = PictureFormat | Unknown +-- TODO: handle video, music, markdown, pdf... +data Format = PictureFormat | PlainTextFormat | Unknown formatFromPath :: Path -> Format formatFromPath = @@ -66,6 +66,8 @@ formatFromPath = ".tiff" -> PictureFormat ".hdr" -> PictureFormat ".gif" -> PictureFormat + ".txt" -> PlainTextFormat + ".md" -> PlainTextFormat -- TODO: handle markdown separately _ -> Unknown @@ -170,6 +172,7 @@ itemFileProcessor maxResolution cached inputBase outputBase resClass inputRes = processorFor :: Format -> Maybe Resolution -> (FileProcessor, ItemDescriber) processorFor PictureFormat (Just maxRes) = (resizePictureUpTo maxRes, getPictureProps) processorFor PictureFormat Nothing = (copyFileProcessor, getPictureProps) + processorFor PlainTextFormat _ = (copyFileProcessor, const $ return . PlainText) -- TODO: handle video reencoding and others? processorFor Unknown _ = (copyFileProcessor, const $ return . Other) diff --git a/compiler/src/Resource.hs b/compiler/src/Resource.hs index e134468..5c175f1 100644 --- a/compiler/src/Resource.hs +++ b/compiler/src/Resource.hs @@ -75,6 +75,7 @@ data GalleryItemProps = | Picture { resource :: Resource , resolution :: Resolution } + | PlainText { resource :: Resource } | Other { resource :: Resource } deriving (Generic, Show) -- cgit v1.2.3