diff options
author | Chocobozzz <me@florianbigard.com> | 2019-07-09 11:45:19 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2019-07-24 10:58:16 +0200 |
commit | 7cd4d2ba10106c10602c86f74f55743ded588896 (patch) | |
tree | 81f0dd7a7ef763511158d1035f3e09e09d5dcd2c /server/helpers/custom-validators/plugins.ts | |
parent | 8d76959e11ab7172040853fa4fadaf8d53e6aa12 (diff) | |
download | PeerTube-7cd4d2ba10106c10602c86f74f55743ded588896.tar.gz PeerTube-7cd4d2ba10106c10602c86f74f55743ded588896.tar.zst PeerTube-7cd4d2ba10106c10602c86f74f55743ded588896.zip |
WIP plugins: add theme support
Diffstat (limited to 'server/helpers/custom-validators/plugins.ts')
-rw-r--r-- | server/helpers/custom-validators/plugins.ts | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/server/helpers/custom-validators/plugins.ts b/server/helpers/custom-validators/plugins.ts index 2fcdc581f..4ab5f9ce8 100644 --- a/server/helpers/custom-validators/plugins.ts +++ b/server/helpers/custom-validators/plugins.ts | |||
@@ -4,6 +4,7 @@ import { PluginType } from '../../../shared/models/plugins/plugin.type' | |||
4 | import { CONSTRAINTS_FIELDS } from '../../initializers/constants' | 4 | import { CONSTRAINTS_FIELDS } from '../../initializers/constants' |
5 | import { PluginPackageJson } from '../../../shared/models/plugins/plugin-package-json.model' | 5 | import { PluginPackageJson } from '../../../shared/models/plugins/plugin-package-json.model' |
6 | import { isUrlValid } from './activitypub/misc' | 6 | import { isUrlValid } from './activitypub/misc' |
7 | import { isThemeRegistered } from '../../lib/plugins/theme-utils' | ||
7 | 8 | ||
8 | const PLUGINS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.PLUGINS | 9 | const PLUGINS_CONSTRAINTS_FIELDS = CONSTRAINTS_FIELDS.PLUGINS |
9 | 10 | ||
@@ -61,6 +62,10 @@ function isCSSPathsValid (css: any[]) { | |||
61 | return isArray(css) && css.every(c => isSafePath(c)) | 62 | return isArray(css) && css.every(c => isSafePath(c)) |
62 | } | 63 | } |
63 | 64 | ||
65 | function isThemeValid (name: string) { | ||
66 | return isPluginNameValid(name) && isThemeRegistered(name) | ||
67 | } | ||
68 | |||
64 | function isPackageJSONValid (packageJSON: PluginPackageJson, pluginType: PluginType) { | 69 | function isPackageJSONValid (packageJSON: PluginPackageJson, pluginType: PluginType) { |
65 | return isNpmPluginNameValid(packageJSON.name) && | 70 | return isNpmPluginNameValid(packageJSON.name) && |
66 | isPluginDescriptionValid(packageJSON.description) && | 71 | isPluginDescriptionValid(packageJSON.description) && |
@@ -82,6 +87,7 @@ function isLibraryCodeValid (library: any) { | |||
82 | export { | 87 | export { |
83 | isPluginTypeValid, | 88 | isPluginTypeValid, |
84 | isPackageJSONValid, | 89 | isPackageJSONValid, |
90 | isThemeValid, | ||
85 | isPluginVersionValid, | 91 | isPluginVersionValid, |
86 | isPluginNameValid, | 92 | isPluginNameValid, |
87 | isPluginDescriptionValid, | 93 | isPluginDescriptionValid, |