mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-06 03:50:26 +02:00
WIP plugins: load theme on client side
This commit is contained in:
parent
7cd4d2ba10
commit
ffb321bedc
19 changed files with 194 additions and 91 deletions
|
@ -4,7 +4,7 @@ import { ServerConfig, UserRight } from '../../../shared'
|
|||
import { About } from '../../../shared/models/server/about.model'
|
||||
import { CustomConfig } from '../../../shared/models/server/custom-config.model'
|
||||
import { isSignupAllowed, isSignupAllowedForCurrentIP } from '../../helpers/signup'
|
||||
import { CONSTRAINTS_FIELDS } from '../../initializers/constants'
|
||||
import { CONSTRAINTS_FIELDS, DEFAULT_THEME_NAME } from '../../initializers/constants'
|
||||
import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../middlewares'
|
||||
import { customConfigUpdateValidator } from '../../middlewares/validators/config'
|
||||
import { ClientHtml } from '../../lib/client-html'
|
||||
|
@ -69,10 +69,11 @@ async function getConfig (req: express.Request, res: express.Response) {
|
|||
name: t.name,
|
||||
version: t.version,
|
||||
description: t.description,
|
||||
css: t.css,
|
||||
clientScripts: t.clientScripts
|
||||
}))
|
||||
|
||||
const defaultTheme = getThemeOrDefault(CONFIG.THEME.DEFAULT)
|
||||
const defaultTheme = getThemeOrDefault(CONFIG.THEME.DEFAULT, DEFAULT_THEME_NAME)
|
||||
|
||||
const json: ServerConfig = {
|
||||
instance: {
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
import * as express from 'express'
|
||||
import { PLUGIN_GLOBAL_CSS_PATH } from '../initializers/constants'
|
||||
import { join } from 'path'
|
||||
import { RegisteredPlugin } from '../lib/plugins/plugin-manager'
|
||||
import { servePluginStaticDirectoryValidator } from '../middlewares/validators/plugins'
|
||||
import { serveThemeCSSValidator } from '../middlewares/validators/themes'
|
||||
|
||||
const themesRouter = express.Router()
|
||||
|
||||
themesRouter.get('/:themeName/:themeVersion/css/:staticEndpoint',
|
||||
themesRouter.get('/:themeName/:themeVersion/css/:staticEndpoint(*)',
|
||||
serveThemeCSSValidator,
|
||||
serveThemeCSSDirectory
|
||||
)
|
||||
|
@ -24,5 +22,9 @@ function serveThemeCSSDirectory (req: express.Request, res: express.Response) {
|
|||
const plugin: RegisteredPlugin = res.locals.registeredPlugin
|
||||
const staticEndpoint = req.params.staticEndpoint
|
||||
|
||||
return express.static(join(plugin.path, staticEndpoint), { fallthrough: false })
|
||||
if (plugin.css.includes(staticEndpoint) === false) {
|
||||
return res.sendStatus(404)
|
||||
}
|
||||
|
||||
return res.sendFile(join(plugin.path, staticEndpoint))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue