aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpacien2020-05-18 20:05:14 +0200
committerNotkea2020-05-22 01:02:18 +0200
commite9e46a3b3392ab435f7414729592b2b5af4071b6 (patch)
treea00d532b5f9708776c2555b8011acbfa2365f9f8
parent8063119d3ee2182a595b2e53ee2bbc557a8a56c3 (diff)
downloadldgallery-e9e46a3b3392ab435f7414729592b2b5af4071b6.tar.gz
compiler: add pdf resource type
-rw-r--r--compiler/src/Processors.hs6
-rw-r--r--compiler/src/Resource.hs1
-rw-r--r--viewer/src/@types/gallery.d.ts11
3 files changed, 14 insertions, 4 deletions
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
47instance Exception ProcessingException 47instance Exception ProcessingException
48 48
49 49
50-- TODO: handle video, music, markdown, pdf... 50-- TODO: handle video, music, markdown...
51data Format = PictureFormat | PlainTextFormat | Unknown 51data Format = PictureFormat | PlainTextFormat | PortableDocumentFormat | Unknown
52 52
53formatFromPath :: Path -> Format 53formatFromPath :: Path -> Format
54formatFromPath = 54formatFromPath =
@@ -68,6 +68,7 @@ formatFromPath =
68 ".gif" -> PictureFormat 68 ".gif" -> PictureFormat
69 ".txt" -> PlainTextFormat 69 ".txt" -> PlainTextFormat
70 ".md" -> PlainTextFormat -- TODO: handle markdown separately 70 ".md" -> PlainTextFormat -- TODO: handle markdown separately
71 ".pdf" -> PortableDocumentFormat
71 _ -> Unknown 72 _ -> Unknown
72 73
73 74
@@ -173,6 +174,7 @@ itemFileProcessor maxResolution cached inputBase outputBase resClass inputRes =
173 processorFor PictureFormat (Just maxRes) = (resizePictureUpTo maxRes, getPictureProps) 174 processorFor PictureFormat (Just maxRes) = (resizePictureUpTo maxRes, getPictureProps)
174 processorFor PictureFormat Nothing = (copyFileProcessor, getPictureProps) 175 processorFor PictureFormat Nothing = (copyFileProcessor, getPictureProps)
175 processorFor PlainTextFormat _ = (copyFileProcessor, const $ return . PlainText) 176 processorFor PlainTextFormat _ = (copyFileProcessor, const $ return . PlainText)
177 processorFor PortableDocumentFormat _ = (copyFileProcessor, const $ return . PDF)
176 -- TODO: handle video reencoding and others? 178 -- TODO: handle video reencoding and others?
177 processorFor Unknown _ = (copyFileProcessor, const $ return . Other) 179 processorFor Unknown _ = (copyFileProcessor, const $ return . Other)
178 180
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 =
76 { resource :: Resource 76 { resource :: Resource
77 , resolution :: Resolution } 77 , resolution :: Resolution }
78 | PlainText { resource :: Resource } 78 | PlainText { resource :: Resource }
79 | PDF { resource :: Resource }
79 | Other { resource :: Resource } 80 | Other { resource :: Resource }
80 deriving (Generic, Show) 81 deriving (Generic, Show)
81 82
diff --git a/viewer/src/@types/gallery.d.ts b/viewer/src/@types/gallery.d.ts
index 04df1bb..7345ef9 100644
--- a/viewer/src/@types/gallery.d.ts
+++ b/viewer/src/@types/gallery.d.ts
@@ -40,6 +40,9 @@ declare namespace Gallery {
40 interface PlainText extends Item { 40 interface PlainText extends Item {
41 properties: PlainTextProperties, 41 properties: PlainTextProperties,
42 } 42 }
43 interface PDF extends Item {
44 properties: PDFProperties,
45 }
43 interface Directory extends Item { 46 interface Directory extends Item {
44 properties: DirectoryProperties, 47 properties: DirectoryProperties,
45 } 48 }
@@ -50,7 +53,7 @@ declare namespace Gallery {
50 tags: RawTag[], 53 tags: RawTag[],
51 path: string, 54 path: string,
52 thumbnail?: Thumbnail 55 thumbnail?: Thumbnail
53 properties: OtherProperties | PictureProperties | PlainTextProperties | DirectoryProperties, 56 properties: OtherProperties | PictureProperties | PlainTextProperties | PDFProperties | DirectoryProperties,
54 } 57 }
55 interface Resolution { 58 interface Resolution {
56 width: number, 59 width: number,
@@ -69,6 +72,10 @@ declare namespace Gallery {
69 type: "plaintext", 72 type: "plaintext",
70 resource: string, 73 resource: string,
71 } 74 }
75 interface PDFProperties {
76 type: "pdf",
77 resource: string,
78 }
72 interface DirectoryProperties { 79 interface DirectoryProperties {
73 type: "directory", 80 type: "directory",
74 items: Item[] 81 items: Item[]
@@ -78,5 +85,5 @@ declare namespace Gallery {
78 resolution: Resolution 85 resolution: Resolution
79 } 86 }
80 type RawTag = string; 87 type RawTag = string;
81 type ItemType = "other" | "picture" | "plaintext" | "directory"; 88 type ItemType = "other" | "picture" | "plaintext" | "pdf" | "directory";
82} 89}