From e9e46a3b3392ab435f7414729592b2b5af4071b6 Mon Sep 17 00:00:00 2001 From: pacien Date: Mon, 18 May 2020 20:05:14 +0200 Subject: compiler: add pdf resource type --- compiler/src/Processors.hs | 6 ++++-- compiler/src/Resource.hs | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'compiler') diff --git a/compiler/src/Processors.hs b/compiler/src/Processors.hs index ca8a74c..2988f83 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, markdown, pdf... -data Format = PictureFormat | PlainTextFormat | Unknown +-- TODO: handle video, music, markdown... +data Format = PictureFormat | PlainTextFormat | PortableDocumentFormat | Unknown formatFromPath :: Path -> Format formatFromPath = @@ -68,6 +68,7 @@ formatFromPath = ".gif" -> PictureFormat ".txt" -> PlainTextFormat ".md" -> PlainTextFormat -- TODO: handle markdown separately + ".pdf" -> PortableDocumentFormat _ -> Unknown @@ -173,6 +174,7 @@ itemFileProcessor maxResolution cached inputBase outputBase resClass inputRes = processorFor PictureFormat (Just maxRes) = (resizePictureUpTo maxRes, getPictureProps) processorFor PictureFormat Nothing = (copyFileProcessor, getPictureProps) processorFor PlainTextFormat _ = (copyFileProcessor, const $ return . PlainText) + processorFor PortableDocumentFormat _ = (copyFileProcessor, const $ return . PDF) -- 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 5c175f1..129a817 100644 --- a/compiler/src/Resource.hs +++ b/compiler/src/Resource.hs @@ -76,6 +76,7 @@ data GalleryItemProps = { resource :: Resource , resolution :: Resolution } | PlainText { resource :: Resource } + | PDF { resource :: Resource } | Other { resource :: Resource } deriving (Generic, Show) -- cgit v1.2.3