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/controllers | |
parent | 8d76959e11ab7172040853fa4fadaf8d53e6aa12 (diff) | |
download | PeerTube-7cd4d2ba10106c10602c86f74f55743ded588896.tar.gz PeerTube-7cd4d2ba10106c10602c86f74f55743ded588896.tar.zst PeerTube-7cd4d2ba10106c10602c86f74f55743ded588896.zip |
WIP plugins: add theme support
Diffstat (limited to 'server/controllers')
-rw-r--r-- | server/controllers/api/config.ts | 43 | ||||
-rw-r--r-- | server/controllers/api/users/me.ts | 1 |
2 files changed, 29 insertions, 15 deletions
diff --git a/server/controllers/api/config.ts b/server/controllers/api/config.ts index 8563b7437..088234074 100644 --- a/server/controllers/api/config.ts +++ b/server/controllers/api/config.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { snakeCase } from 'lodash' | 2 | import { snakeCase } from 'lodash' |
3 | import { ServerConfig, ServerConfigPlugin, UserRight } from '../../../shared' | 3 | import { ServerConfig, UserRight } from '../../../shared' |
4 | import { About } from '../../../shared/models/server/about.model' | 4 | import { About } from '../../../shared/models/server/about.model' |
5 | import { CustomConfig } from '../../../shared/models/server/custom-config.model' | 5 | import { CustomConfig } from '../../../shared/models/server/custom-config.model' |
6 | import { isSignupAllowed, isSignupAllowedForCurrentIP } from '../../helpers/signup' | 6 | import { isSignupAllowed, isSignupAllowedForCurrentIP } from '../../helpers/signup' |
@@ -16,7 +16,7 @@ import { isNumeric } from 'validator' | |||
16 | import { objectConverter } from '../../helpers/core-utils' | 16 | import { objectConverter } from '../../helpers/core-utils' |
17 | import { CONFIG, reloadConfig } from '../../initializers/config' | 17 | import { CONFIG, reloadConfig } from '../../initializers/config' |
18 | import { PluginManager } from '../../lib/plugins/plugin-manager' | 18 | import { PluginManager } from '../../lib/plugins/plugin-manager' |
19 | import { PluginType } from '../../../shared/models/plugins/plugin.type' | 19 | import { getThemeOrDefault } from '../../lib/plugins/theme-utils' |
20 | 20 | ||
21 | const packageJSON = require('../../../../package.json') | 21 | const packageJSON = require('../../../../package.json') |
22 | const configRouter = express.Router() | 22 | const configRouter = express.Router() |
@@ -56,19 +56,23 @@ async function getConfig (req: express.Request, res: express.Response) { | |||
56 | .filter(key => CONFIG.TRANSCODING.ENABLED && CONFIG.TRANSCODING.RESOLUTIONS[key] === true) | 56 | .filter(key => CONFIG.TRANSCODING.ENABLED && CONFIG.TRANSCODING.RESOLUTIONS[key] === true) |
57 | .map(r => parseInt(r, 10)) | 57 | .map(r => parseInt(r, 10)) |
58 | 58 | ||
59 | const plugins: ServerConfigPlugin[] = [] | ||
60 | const registeredPlugins = PluginManager.Instance.getRegisteredPlugins() | 59 | const registeredPlugins = PluginManager.Instance.getRegisteredPlugins() |
61 | for (const pluginName of Object.keys(registeredPlugins)) { | 60 | .map(p => ({ |
62 | const plugin = registeredPlugins[ pluginName ] | 61 | name: p.name, |
63 | if (plugin.type !== PluginType.PLUGIN) continue | 62 | version: p.version, |
64 | 63 | description: p.description, | |
65 | plugins.push({ | 64 | clientScripts: p.clientScripts |
66 | name: plugin.name, | 65 | })) |
67 | version: plugin.version, | 66 | |
68 | description: plugin.description, | 67 | const registeredThemes = PluginManager.Instance.getRegisteredThemes() |
69 | clientScripts: plugin.clientScripts | 68 | .map(t => ({ |
70 | }) | 69 | name: t.name, |
71 | } | 70 | version: t.version, |
71 | description: t.description, | ||
72 | clientScripts: t.clientScripts | ||
73 | })) | ||
74 | |||
75 | const defaultTheme = getThemeOrDefault(CONFIG.THEME.DEFAULT) | ||
72 | 76 | ||
73 | const json: ServerConfig = { | 77 | const json: ServerConfig = { |
74 | instance: { | 78 | instance: { |
@@ -82,7 +86,13 @@ async function getConfig (req: express.Request, res: express.Response) { | |||
82 | css: CONFIG.INSTANCE.CUSTOMIZATIONS.CSS | 86 | css: CONFIG.INSTANCE.CUSTOMIZATIONS.CSS |
83 | } | 87 | } |
84 | }, | 88 | }, |
85 | plugins, | 89 | plugin: { |
90 | registered: registeredPlugins | ||
91 | }, | ||
92 | theme: { | ||
93 | registered: registeredThemes, | ||
94 | default: defaultTheme | ||
95 | }, | ||
86 | email: { | 96 | email: { |
87 | enabled: Emailer.isEnabled() | 97 | enabled: Emailer.isEnabled() |
88 | }, | 98 | }, |
@@ -240,6 +250,9 @@ function customConfig (): CustomConfig { | |||
240 | javascript: CONFIG.INSTANCE.CUSTOMIZATIONS.JAVASCRIPT | 250 | javascript: CONFIG.INSTANCE.CUSTOMIZATIONS.JAVASCRIPT |
241 | } | 251 | } |
242 | }, | 252 | }, |
253 | theme: { | ||
254 | default: CONFIG.THEME.DEFAULT | ||
255 | }, | ||
243 | services: { | 256 | services: { |
244 | twitter: { | 257 | twitter: { |
245 | username: CONFIG.SERVICES.TWITTER.USERNAME, | 258 | username: CONFIG.SERVICES.TWITTER.USERNAME, |
diff --git a/server/controllers/api/users/me.ts b/server/controllers/api/users/me.ts index a078334fe..e7ed3de64 100644 --- a/server/controllers/api/users/me.ts +++ b/server/controllers/api/users/me.ts | |||
@@ -183,6 +183,7 @@ async function updateMe (req: express.Request, res: express.Response) { | |||
183 | if (body.autoPlayVideo !== undefined) user.autoPlayVideo = body.autoPlayVideo | 183 | if (body.autoPlayVideo !== undefined) user.autoPlayVideo = body.autoPlayVideo |
184 | if (body.videosHistoryEnabled !== undefined) user.videosHistoryEnabled = body.videosHistoryEnabled | 184 | if (body.videosHistoryEnabled !== undefined) user.videosHistoryEnabled = body.videosHistoryEnabled |
185 | if (body.videoLanguages !== undefined) user.videoLanguages = body.videoLanguages | 185 | if (body.videoLanguages !== undefined) user.videoLanguages = body.videoLanguages |
186 | if (body.theme !== undefined) user.theme = body.theme | ||
186 | 187 | ||
187 | if (body.email !== undefined) { | 188 | if (body.email !== undefined) { |
188 | if (CONFIG.SIGNUP.REQUIRES_EMAIL_VERIFICATION) { | 189 | if (CONFIG.SIGNUP.REQUIRES_EMAIL_VERIFICATION) { |