aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/themes.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-07-10 14:06:19 +0200
committerChocobozzz <chocobozzz@cpy.re>2019-07-24 10:58:16 +0200
commitffb321bedca46d6987c7b31dd58e5dea96ea2ea2 (patch)
tree019f0427c1860ae0b00694c43f1be8d5fe1aa995 /server/controllers/themes.ts
parent7cd4d2ba10106c10602c86f74f55743ded588896 (diff)
downloadPeerTube-ffb321bedca46d6987c7b31dd58e5dea96ea2ea2.tar.gz
PeerTube-ffb321bedca46d6987c7b31dd58e5dea96ea2ea2.tar.zst
PeerTube-ffb321bedca46d6987c7b31dd58e5dea96ea2ea2.zip
WIP plugins: load theme on client side
Diffstat (limited to 'server/controllers/themes.ts')
-rw-r--r--server/controllers/themes.ts10
1 files changed, 6 insertions, 4 deletions
diff --git a/server/controllers/themes.ts b/server/controllers/themes.ts
index 20e7062d0..104c285ad 100644
--- a/server/controllers/themes.ts
+++ b/server/controllers/themes.ts
@@ -1,13 +1,11 @@
1import * as express from 'express' 1import * as express from 'express'
2import { PLUGIN_GLOBAL_CSS_PATH } from '../initializers/constants'
3import { join } from 'path' 2import { join } from 'path'
4import { RegisteredPlugin } from '../lib/plugins/plugin-manager' 3import { RegisteredPlugin } from '../lib/plugins/plugin-manager'
5import { servePluginStaticDirectoryValidator } from '../middlewares/validators/plugins'
6import { serveThemeCSSValidator } from '../middlewares/validators/themes' 4import { serveThemeCSSValidator } from '../middlewares/validators/themes'
7 5
8const themesRouter = express.Router() 6const themesRouter = express.Router()
9 7
10themesRouter.get('/:themeName/:themeVersion/css/:staticEndpoint', 8themesRouter.get('/:themeName/:themeVersion/css/:staticEndpoint(*)',
11 serveThemeCSSValidator, 9 serveThemeCSSValidator,
12 serveThemeCSSDirectory 10 serveThemeCSSDirectory
13) 11)
@@ -24,5 +22,9 @@ function serveThemeCSSDirectory (req: express.Request, res: express.Response) {
24 const plugin: RegisteredPlugin = res.locals.registeredPlugin 22 const plugin: RegisteredPlugin = res.locals.registeredPlugin
25 const staticEndpoint = req.params.staticEndpoint 23 const staticEndpoint = req.params.staticEndpoint
26 24
27 return express.static(join(plugin.path, staticEndpoint), { fallthrough: false }) 25 if (plugin.css.includes(staticEndpoint) === false) {
26 return res.sendStatus(404)
27 }
28
29 return res.sendFile(join(plugin.path, staticEndpoint))
28} 30}