aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compiler/src/Processors.hs7
-rw-r--r--compiler/src/Resource.hs1
-rw-r--r--viewer/src/@types/gallery.d.ts11
3 files changed, 15 insertions, 4 deletions
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
47instance Exception ProcessingException 47instance Exception ProcessingException
48 48
49 49
50-- TODO: handle video, music, text... 50-- TODO: handle video, music, markdown, pdf...
51data Format = PictureFormat | Unknown 51data Format = PictureFormat | PlainTextFormat | Unknown
52 52
53formatFromPath :: Path -> Format 53formatFromPath :: Path -> Format
54formatFromPath = 54formatFromPath =
@@ -66,6 +66,8 @@ formatFromPath =
66 ".tiff" -> PictureFormat 66 ".tiff" -> PictureFormat
67 ".hdr" -> PictureFormat 67 ".hdr" -> PictureFormat
68 ".gif" -> PictureFormat 68 ".gif" -> PictureFormat
69 ".txt" -> PlainTextFormat
70 ".md" -> PlainTextFormat -- TODO: handle markdown separately
69 _ -> Unknown 71 _ -> Unknown
70 72
71 73
@@ -170,6 +172,7 @@ itemFileProcessor maxResolution cached inputBase outputBase resClass inputRes =
170 processorFor :: Format -> Maybe Resolution -> (FileProcessor, ItemDescriber) 172 processorFor :: Format -> Maybe Resolution -> (FileProcessor, ItemDescriber)
171 processorFor PictureFormat (Just maxRes) = (resizePictureUpTo maxRes, getPictureProps) 173 processorFor PictureFormat (Just maxRes) = (resizePictureUpTo maxRes, getPictureProps)
172 processorFor PictureFormat Nothing = (copyFileProcessor, getPictureProps) 174 processorFor PictureFormat Nothing = (copyFileProcessor, getPictureProps)
175 processorFor PlainTextFormat _ = (copyFileProcessor, const $ return . PlainText)
173 -- TODO: handle video reencoding and others? 176 -- TODO: handle video reencoding and others?
174 processorFor Unknown _ = (copyFileProcessor, const $ return . Other) 177 processorFor Unknown _ = (copyFileProcessor, const $ return . Other)
175 178
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 =
75 | Picture 75 | Picture
76 { resource :: Resource 76 { resource :: Resource
77 , resolution :: Resolution } 77 , resolution :: Resolution }
78 | PlainText { resource :: Resource }
78 | Other { resource :: Resource } 79 | Other { resource :: Resource }
79 deriving (Generic, Show) 80 deriving (Generic, Show)
80 81
diff --git a/viewer/src/@types/gallery.d.ts b/viewer/src/@types/gallery.d.ts
index 3246894..04df1bb 100644
--- a/viewer/src/@types/gallery.d.ts
+++ b/viewer/src/@types/gallery.d.ts
@@ -37,6 +37,9 @@ declare namespace Gallery {
37 interface Picture extends Item { 37 interface Picture extends Item {
38 properties: PictureProperties, 38 properties: PictureProperties,
39 } 39 }
40 interface PlainText extends Item {
41 properties: PlainTextProperties,
42 }
40 interface Directory extends Item { 43 interface Directory extends Item {
41 properties: DirectoryProperties, 44 properties: DirectoryProperties,
42 } 45 }
@@ -47,7 +50,7 @@ declare namespace Gallery {
47 tags: RawTag[], 50 tags: RawTag[],
48 path: string, 51 path: string,
49 thumbnail?: Thumbnail 52 thumbnail?: Thumbnail
50 properties: OtherProperties | PictureProperties | DirectoryProperties, 53 properties: OtherProperties | PictureProperties | PlainTextProperties | DirectoryProperties,
51 } 54 }
52 interface Resolution { 55 interface Resolution {
53 width: number, 56 width: number,
@@ -62,6 +65,10 @@ declare namespace Gallery {
62 resource: string, 65 resource: string,
63 resolution: Resolution 66 resolution: Resolution
64 } 67 }
68 interface PlainTextProperties {
69 type: "plaintext",
70 resource: string,
71 }
65 interface DirectoryProperties { 72 interface DirectoryProperties {
66 type: "directory", 73 type: "directory",
67 items: Item[] 74 items: Item[]
@@ -71,5 +78,5 @@ declare namespace Gallery {
71 resolution: Resolution 78 resolution: Resolution
72 } 79 }
73 type RawTag = string; 80 type RawTag = string;
74 type ItemType = "other" | "picture" | "directory"; 81 type ItemType = "other" | "picture" | "plaintext" | "directory";
75} 82}