diff options
author | zeroinformatique | 2021-07-03 00:48:53 +0200 |
---|---|---|
committer | GitHub | 2021-07-03 00:48:53 +0200 |
commit | b6605e2c4ee73ac8b994624098344db5e44ac07d (patch) | |
tree | 5ed06cc5ecdabe070f6fdb9bc4f9a8a3b435cbe6 | |
parent | 08ac32103fb5f8cca1861267dfd07a7c0d2faf62 (diff) | |
parent | 1f0377c1b4c2959c73fe4e368673f057ef369917 (diff) | |
download | ldgallery-b6605e2c4ee73ac8b994624098344db5e44ac07d.tar.gz |
Merge pull request #302 from ldgallery/oz-types-normalization
viewer: types normalization
34 files changed, 274 insertions, 234 deletions
diff --git a/viewer/src/@types/ItemType.ts b/viewer/src/@types/ItemType.ts index 31a395b..9974d4e 100644 --- a/viewer/src/@types/ItemType.ts +++ b/viewer/src/@types/ItemType.ts | |||
@@ -1,4 +1,21 @@ | |||
1 | // TODO: Convert all ambiant types related to LdGallery to modules | 1 | /* ldgallery - A static generator which turns a collection of tagged |
2 | -- pictures into a searchable web gallery. | ||
3 | -- | ||
4 | -- Copyright (C) 2019-2021 Guillaume FOUET | ||
5 | -- | ||
6 | -- This program is free software: you can redistribute it and/or modify | ||
7 | -- it under the terms of the GNU Affero General Public License as | ||
8 | -- published by the Free Software Foundation, either version 3 of the | ||
9 | -- License, or (at your option) any later version. | ||
10 | -- | ||
11 | -- This program is distributed in the hope that it will be useful, | ||
12 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | -- GNU Affero General Public License for more details. | ||
15 | -- | ||
16 | -- You should have received a copy of the GNU Affero General Public License | ||
17 | -- along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
18 | */ | ||
2 | 19 | ||
3 | export enum ItemType { | 20 | export enum ItemType { |
4 | OTHER = "other", | 21 | OTHER = "other", |
diff --git a/viewer/src/@types/gallery.d.ts b/viewer/src/@types/gallery.d.ts index e9b80e6..d9e7534 100644 --- a/viewer/src/@types/gallery.d.ts +++ b/viewer/src/@types/gallery.d.ts | |||
@@ -17,98 +17,99 @@ | |||
17 | -- along with this program. If not, see <https://www.gnu.org/licenses/>. | 17 | -- along with this program. If not, see <https://www.gnu.org/licenses/>. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | declare namespace Gallery { | 20 | import { ItemType } from "./ItemType"; |
21 | type ItemSortStr = "title_asc" | "date_asc" | "date_desc"; | ||
22 | 21 | ||
23 | interface Config { | 22 | export type ItemSortStr = "title_asc" | "date_asc" | "date_desc"; |
24 | galleryRoot: string; | ||
25 | galleryIndex?: string; | ||
26 | initialItemSort?: ItemSortStr; | ||
27 | initialTagDisplayLimit?: number; | ||
28 | } | ||
29 | 23 | ||
30 | interface GalleryProperties { | 24 | export interface Config { |
31 | galleryTitle: string; | 25 | galleryRoot: string; |
32 | tagCategories: RawTag[]; | 26 | galleryIndex?: string; |
33 | } | 27 | initialItemSort?: ItemSortStr; |
34 | interface Index { | 28 | initialTagDisplayLimit?: number; |
35 | properties: GalleryProperties; | 29 | } |
36 | tree: Directory; | 30 | |
37 | } | 31 | export interface Properties { |
32 | galleryTitle: string; | ||
33 | tagCategories: RawTag[]; | ||
34 | } | ||
35 | export interface Index { | ||
36 | properties: Properties; | ||
37 | tree: DirectoryItem; | ||
38 | } | ||
39 | |||
40 | export interface OtherItem extends Item { | ||
41 | properties: OtherProperties; | ||
42 | } | ||
43 | export interface PictureItem extends Item { | ||
44 | properties: PictureProperties; | ||
45 | } | ||
46 | export interface PlainTextItem extends Item { | ||
47 | properties: PlainTextProperties; | ||
48 | } | ||
49 | export interface PDFItem extends Item { | ||
50 | properties: PDFProperties; | ||
51 | } | ||
52 | export interface VideoItem extends Item { | ||
53 | properties: VideoProperties; | ||
54 | } | ||
55 | export interface AudioItem extends Item { | ||
56 | properties: AudioProperties; | ||
57 | } | ||
58 | export interface DirectoryItem extends Item { | ||
59 | properties: DirectoryProperties; | ||
60 | } | ||
61 | export interface Item { | ||
62 | title: string; | ||
63 | datetime: string; | ||
64 | description: string; | ||
65 | tags: RawTag[]; | ||
66 | path: string; | ||
67 | thumbnail?: Thumbnail; | ||
68 | properties: | ||
69 | | OtherProperties | ||
70 | | PictureProperties | ||
71 | | PlainTextProperties | ||
72 | | PDFProperties | ||
73 | | VideoProperties | ||
74 | | AudioProperties | ||
75 | | DirectoryProperties; | ||
76 | } | ||
77 | export interface Resolution { | ||
78 | width: number; | ||
79 | height: number; | ||
80 | } | ||
81 | export interface OtherProperties { | ||
82 | type: ItemType.OTHER; | ||
83 | resource: string; | ||
84 | } | ||
85 | export interface PictureProperties { | ||
86 | type: ItemType.PICTURE; | ||
87 | resource: string; | ||
88 | resolution: Resolution; | ||
89 | } | ||
90 | export interface PlainTextProperties { | ||
91 | type: ItemType.PLAINTEXT; | ||
92 | resource: string; | ||
93 | } | ||
94 | export interface PDFProperties { | ||
95 | type: ItemType.PDF; | ||
96 | resource: string; | ||
97 | } | ||
98 | export interface VideoProperties { | ||
99 | type: ItemType.VIDEO; | ||
100 | resource: string; | ||
101 | } | ||
102 | export interface AudioProperties { | ||
103 | type: ItemType.AUDIO; | ||
104 | resource: string; | ||
105 | } | ||
106 | export interface DirectoryProperties { | ||
107 | type: ItemType.DIRECTORY; | ||
108 | items: Item[]; | ||
109 | } | ||
38 | 110 | ||
39 | interface Other extends Item { | 111 | export interface Thumbnail { |
40 | properties: OtherProperties; | 112 | resource: string; |
41 | } | 113 | resolution: Resolution; |
42 | interface Picture extends Item { | ||
43 | properties: PictureProperties; | ||
44 | } | ||
45 | interface PlainText extends Item { | ||
46 | properties: PlainTextProperties; | ||
47 | } | ||
48 | interface PDF extends Item { | ||
49 | properties: PDFProperties; | ||
50 | } | ||
51 | interface Video extends Item { | ||
52 | properties: VideoProperties; | ||
53 | } | ||
54 | interface Audio extends Item { | ||
55 | properties: AudioProperties; | ||
56 | } | ||
57 | interface Directory extends Item { | ||
58 | properties: DirectoryProperties; | ||
59 | } | ||
60 | interface Item { | ||
61 | title: string; | ||
62 | datetime: string; | ||
63 | description: string; | ||
64 | tags: RawTag[]; | ||
65 | path: string; | ||
66 | thumbnail?: Thumbnail; | ||
67 | properties: | ||
68 | | OtherProperties | ||
69 | | PictureProperties | ||
70 | | PlainTextProperties | ||
71 | | PDFProperties | ||
72 | | VideoProperties | ||
73 | | AudioProperties | ||
74 | | DirectoryProperties; | ||
75 | } | ||
76 | interface Resolution { | ||
77 | width: number; | ||
78 | height: number; | ||
79 | } |