aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpacien2020-05-19 21:06:16 +0200
committerNotkea2020-05-22 01:02:18 +0200
commit516ee7c5599f2c90a636fd9301806bef67830046 (patch)
tree50cc7369f8a0edf6160dfe5aca8e5bf4676fde42
parenta2e06f0a217b12d92cecdad77c20de88037f9912 (diff)
downloadldgallery-516ee7c5599f2c90a636fd9301806bef67830046.tar.gz
compiler: add audio and video extensions
-rw-r--r--compiler/src/Processors.hs24
-rw-r--r--compiler/src/Resource.hs2
-rw-r--r--viewer/src/@types/gallery.d.ts24
3 files changed, 46 insertions, 4 deletions
diff --git a/compiler/src/Processors.hs b/compiler/src/Processors.hs
index 2988f83..0efbf6d 100644
--- a/compiler/src/Processors.hs
+++ b/compiler/src/Processors.hs
@@ -47,8 +47,13 @@ data ProcessingException = ProcessingException FilePath String deriving Show
47instance Exception ProcessingException 47instance Exception ProcessingException
48 48
49 49
50-- TODO: handle video, music, markdown... 50data Format =
51data Format = PictureFormat | PlainTextFormat | PortableDocumentFormat | Unknown 51 PictureFormat
52 | PlainTextFormat
53 | PortableDocumentFormat
54 | VideoFormat
55 | AudioFormat
56 | Unknown
52 57
53formatFromPath :: Path -> Format 58formatFromPath :: Path -> Format
54formatFromPath = 59formatFromPath =
@@ -69,6 +74,19 @@ formatFromPath =
69 ".txt" -> PlainTextFormat 74 ".txt" -> PlainTextFormat
70 ".md" -> PlainTextFormat -- TODO: handle markdown separately 75 ".md" -> PlainTextFormat -- TODO: handle markdown separately
71 ".pdf" -> PortableDocumentFormat 76 ".pdf" -> PortableDocumentFormat
77 ".wav" -> AudioFormat
78 ".oga" -> AudioFormat
79 ".ogg" -> AudioFormat
80 ".spx" -> AudioFormat
81 ".opus" -> AudioFormat
82 ".flac" -> AudioFormat
83 ".m4a" -> AudioFormat
84 ".mp3" -> AudioFormat
85 ".ogv" -> VideoFormat
86 ".ogx" -> VideoFormat
87 ".webm" -> VideoFormat
88 ".mkv" -> VideoFormat
89 ".mp4" -> VideoFormat
72 _ -> Unknown 90 _ -> Unknown
73 91
74 92
@@ -175,6 +193,8 @@ itemFileProcessor maxResolution cached inputBase outputBase resClass inputRes =
175 processorFor PictureFormat Nothing = (copyFileProcessor, getPictureProps) 193 processorFor PictureFormat Nothing = (copyFileProcessor, getPictureProps)
176 processorFor PlainTextFormat _ = (copyFileProcessor, const $ return . PlainText) 194 processorFor PlainTextFormat _ = (copyFileProcessor, const $ return . PlainText)
177 processorFor PortableDocumentFormat _ = (copyFileProcessor, const $ return . PDF) 195 processorFor PortableDocumentFormat _ = (copyFileProcessor, const $ return . PDF)
196 processorFor VideoFormat _ = (copyFileProcessor, const $ return . Video)
197 processorFor AudioFormat _ = (copyFileProcessor, const $ return . Audio)
178 -- TODO: handle video reencoding and others? 198 -- TODO: handle video reencoding and others?
179 processorFor Unknown _ = (copyFileProcessor, const $ return . Other) 199 processorFor Unknown _ = (copyFileProcessor, const $ return . Other)
180 200
diff --git a/compiler/src/Resource.hs b/compiler/src/Resource.hs
index 129a817..c08677d 100644
--- a/compiler/src/Resource.hs
+++ b/compiler/src/Resource.hs
@@ -77,6 +77,8 @@ data GalleryItemProps =
77 , resolution :: Resolution } 77 , resolution :: Resolution }
78 | PlainText { resource :: Resource } 78 | PlainText { resource :: Resource }
79 | PDF { resource :: Resource } 79 | PDF { resource :: Resource }
80 | Video { resource :: Resource }
81 | Audio { resource :: Resource }
80 | Other { resource :: Resource } 82 | Other { resource :: Resource }
81 deriving (Generic, Show) 83 deriving (Generic, Show)
82 84
diff --git a/viewer/src/@types/gallery.d.ts b/viewer/src/@types/gallery.d.ts
index 7345ef9..2407f98 100644
--- a/viewer/src/@types/gallery.d.ts
+++ b/viewer/src/@types/gallery.d.ts
@@ -43,6 +43,12 @@ declare namespace Gallery {
43 interface PDF extends Item { 43 interface PDF extends Item {
44 properties: PDFProperties, 44 properties: PDFProperties,
45 } 45 }
46 interface Video extends Item {
47 properties: VideoProperties,
48 }
49 interface Audio extends Item {
50 properties: AudioProperties,
51 }
46 interface Directory extends Item { 52 interface Directory extends Item {
47 properties: DirectoryProperties, 53 properties: DirectoryProperties,
48 } 54 }
@@ -53,7 +59,13 @@ declare namespace Gallery {
53 tags: RawTag[], 59 tags: RawTag[],
54 path: string, 60 path: string,
55 thumbnail?: Thumbnail 61 thumbnail?: Thumbnail
56 properties: OtherProperties | PictureProperties | PlainTextProperties | PDFProperties | DirectoryProperties, 62 properties: OtherProperties
63 | PictureProperties
64 | PlainTextProperties
65 | PDFProperties
66 | VideoProperties
67 | AudioProperties
68 | DirectoryProperties,
57 } 69 }
58 interface Resolution { 70 interface Resolution {
59 width: number, 71 width: number,
@@ -76,6 +88,14 @@ declare namespace Gallery {
76 type: "pdf", 88 type: "pdf",
77 resource: string, 89 resource: string,
78 } 90 }
91 interface VideoProperties {
92 type: "video",
93 resource: string,
94 }
95 interface AudioProperties {
96 type: "audio",
97 resource: string,
98 }
79 interface DirectoryProperties { 99 interface DirectoryProperties {
80 type: "directory", 100 type: "directory",
81 items: Item[] 101 items: Item[]
@@ -85,5 +105,5 @@ declare namespace Gallery {
85 resolution: Resolution 105 resolution: Resolution
86 } 106 }
87 type RawTag = string; 107 type RawTag = string;
88 type ItemType = "other" | "picture" | "plaintext" | "pdf" | "directory"; 108 type ItemType = "other" | "picture" | "plaintext" | "pdf" | "video" | "audio" | "directory";
89} 109}