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/lib/plugins/theme-utils.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/lib/plugins/theme-utils.ts')
-rw-r--r-- | server/lib/plugins/theme-utils.ts | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/server/lib/plugins/theme-utils.ts b/server/lib/plugins/theme-utils.ts new file mode 100644 index 000000000..066339e65 --- /dev/null +++ b/server/lib/plugins/theme-utils.ts | |||
@@ -0,0 +1,24 @@ | |||
1 | import { DEFAULT_THEME } from '../../initializers/constants' | ||
2 | import { PluginManager } from './plugin-manager' | ||
3 | import { CONFIG } from '../../initializers/config' | ||
4 | |||
5 | function getThemeOrDefault (name: string) { | ||
6 | if (isThemeRegistered(name)) return name | ||
7 | |||
8 | // Fallback to admin default theme | ||
9 | if (name !== CONFIG.THEME.DEFAULT) return getThemeOrDefault(CONFIG.THEME.DEFAULT) | ||
10 | |||
11 | return DEFAULT_THEME | ||
12 | } | ||
13 | |||
14 | function isThemeRegistered (name: string) { | ||
15 | if (name === DEFAULT_THEME) return true | ||
16 | |||
17 | return !!PluginManager.Instance.getRegisteredThemes() | ||
18 | .find(r => r.name === name) | ||
19 | } | ||
20 | |||
21 | export { | ||
22 | getThemeOrDefault, | ||
23 | isThemeRegistered | ||
24 | } | ||