Skip to content

Commit 11fffd4

Browse files
committed
moving supported formats to the config #561 #97
1 parent e345da5 commit 11fffd4

File tree

7 files changed

+99
-32
lines changed

7 files changed

+99
-32
lines changed

angular.json

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
},
7171
"architect": {
7272
"build": {
73-
"builder": "@angular-devkit/build-angular:browser",
73+
"builder": "@angular-builders/custom-webpack:browser",
7474
"options": {
7575
"localize": true,
7676
"aot": true,
@@ -103,7 +103,11 @@
103103
"scripts": [
104104
"node_modules/marked/marked.min.js"
105105
],
106-
"i18nMissingTranslation": "warning"
106+
"i18nMissingTranslation": "warning",
107+
"customWebpackConfig": {
108+
"path": "./angular.webpack.js",
109+
"replaceDuplicatePlugins": true
110+
}
107111
},
108112
"configurations": {
109113
"dev": {
@@ -147,7 +151,7 @@
147151
}
148152
},
149153
"serve": {
150-
"builder": "@angular-devkit/build-angular:dev-server",
154+
"builder": "@angular-builders/custom-webpack:dev-server",
151155
"options": {
152156
"browserTarget": "pigallery2:build"
153157
},
@@ -158,13 +162,13 @@
158162
}
159163
},
160164
"extract-i18n": {
161-
"builder": "@angular-devkit/build-angular:extract-i18n",
165+
"builder": "@angular-builders/custom-webpack:extract-i18n",
162166
"options": {
163167
"browserTarget": "pigallery2:build"
164168
}
165169
},
166170
"test": {
167-
"builder": "@angular-devkit/build-angular:karma",
171+
"builder": "@angular-builders/custom-webpack:karma",
168172
"options": {
169173
"main": "src/frontend/test.ts",
170174
"karmaConfig": "./karma.conf.js",
@@ -190,7 +194,11 @@
190194
"input": "node_modules/leaflet/dist/images/",
191195
"output": "./assets/"
192196
}
193-
]
197+
],
198+
"customWebpackConfig": {
199+
"path": "./angular.webpack.js",
200+
"replaceDuplicatePlugins": true
201+
}
194202
}
195203
},
196204
"lint": {

angular.webpack.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// eslint-disable-next-line @typescript-eslint/no-var-requires,no-undef
2+
const webpack = require('webpack');
3+
4+
/**
5+
* Custom angular webpack configuration
6+
*/
7+
module.exports = (config, options) => {
8+
config.plugins = [
9+
...config.plugins,
10+
new webpack.IgnorePlugin({
11+
resourceRegExp: /config\/private\/Config/,
12+
})
13+
];
14+
15+
return config;
16+
}

package-lock.json

Lines changed: 34 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
"typeorm": "0.3.4"
5656
},
5757
"devDependencies": {
58-
"@angular-devkit/build-angular": "13.3.1",
58+
"@angular-builders/custom-webpack": "13.1.0",
5959
"@angular-devkit/build-optimizer": "0.1302.1",
6060
"@angular-eslint/builder": "13.1.0",
6161
"@angular-eslint/eslint-plugin": "13.1.0",

src/common/SupportedFormats.ts

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,26 @@
1+
import {ClientClass} from './config/public/Config';
2+
3+
let Config: ClientClass;
4+
5+
if (typeof window !== 'undefined') {
6+
// eslint-disable-next-line @typescript-eslint/no-var-requires
7+
Config = require('./config/public/Config').Config;
8+
} else {
9+
// eslint-disable-next-line @typescript-eslint/no-var-requires
10+
Config = require('./config/private/Config').Config;
11+
}
12+
113
export const SupportedFormats = {
2-
Photos: ['gif', 'jpeg', 'jpg', 'jpe', 'png', 'webp', 'svg', 'heic'],
14+
Photos: Config.Client.Media.Photo.supportedFormats,
315
// Browser supported video formats
416
// Read more: https://www.w3schools.com/html/html5_video.asp
5-
Videos: ['mp4', 'webm', 'ogv', 'ogg'],
6-
MetaFiles: ['gpx', 'pg2conf', 'md'],
17+
Videos: Config.Client.Media.Video.supportedFormats,
18+
MetaFiles: Config.Client.MetaFile.supportedFormats,
719
// These formats need to be transcoded (with the build-in ffmpeg support)
820
TranscodeNeed: {
921
// based on libvips, all supported formats for sharp: https://github.com/libvips/libvips
1022
Photos: [] as string[],
11-
Videos: [
12-
'avi',
13-
'mkv',
14-
'mov',
15-
'wmv',
16-
'flv',
17-
'mts',
18-
'm2ts',
19-
'mpg',
20-
'3gp',
21-
'm4v',
22-
'mpeg',
23-
'vob',
24-
'divx',
25-
'xvid',
26-
'ts',
27-
],
23+
Videos: Config.Client.Media.Video.supportedFormatsWithTranscoding,
2824
},
2925
// --------------------------------------------
3026
// Below this, it is autogenerated, DO NOT EDIT

src/common/config/public/ClientConfig.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,16 @@ export class ClientOtherConfig {
170170
export class ClientVideoConfig {
171171
@ConfigProperty()
172172
enabled: boolean = true;
173+
@ConfigProperty({
174+
arrayType: 'string',
175+
description: 'Video formats that are supported after transcoding (with the build-in ffmpeg support)'
176+
})
177+
supportedFormatsWithTranscoding: string[] = ['avi', 'mkv', 'mov', 'wmv', 'flv', 'mts', 'm2ts', 'mpg', '3gp', 'm4v', 'mpeg', 'vob', 'divx', 'xvid', 'ts'];
178+
// Browser supported video formats
179+
// Read more: https://www.w3schools.com/html/html5_video.asp
180+
@ConfigProperty({arrayType: 'string', description: 'Video formats that are supported also without transcoding'})
181+
supportedFormats: string[] = ['mp4', 'webm', 'ogv', 'ogg'];
182+
173183
}
174184

175185
@SubConfigClass()
@@ -187,6 +197,8 @@ export class ClientPhotoConfig {
187197
'Enables loading the full resolution image on zoom in the ligthbox (preview).',
188198
})
189199
loadFullImageOnZoom: boolean = true;
200+
@ConfigProperty({arrayType: 'string'})
201+
supportedFormats: string[] = ['gif', 'jpeg', 'jpg', 'jpe', 'png', 'webp', 'svg'];
190202
}
191203

192204
@SubConfigClass()
@@ -226,6 +238,8 @@ export class ClientMetaFileConfig {
226238
'Reads *.pg2conf files (You can use it for custom sorting and save search (albums)).',
227239
})
228240
pg2conf: boolean = true;
241+
@ConfigProperty({arrayType: 'string'})
242+
supportedFormats: string[] = ['gpx', 'pg2conf', 'md'];
229243
}
230244

231245
@SubConfigClass()

src/common/entities/MediaDTO.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { DirectoryPathDTO } from './DirectoryDTO';
2-
import { PhotoDTO } from './PhotoDTO';
3-
import { FileDTO } from './FileDTO';
4-
import { SupportedFormats } from '../SupportedFormats';
1+
import {DirectoryPathDTO} from './DirectoryDTO';
2+
import {PhotoDTO} from './PhotoDTO';
3+
import {FileDTO} from './FileDTO';
4+
import {SupportedFormats} from '../SupportedFormats';
55

66
export interface MediaDTO extends FileDTO {
77
id: number;

0 commit comments

Comments
 (0)