mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-05 10:49:28 +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
|
@ -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