From 345da516fae80f24c90c2196e96393b489af2243 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 5 Jul 2019 13:54:32 +0200 Subject: WIP plugins: add ability to register plugins --- server/controllers/themes.ts | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 server/controllers/themes.ts (limited to 'server/controllers/themes.ts') diff --git a/server/controllers/themes.ts b/server/controllers/themes.ts new file mode 100644 index 000000000..20e7062d0 --- /dev/null +++ b/server/controllers/themes.ts @@ -0,0 +1,28 @@ +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', + serveThemeCSSValidator, + serveThemeCSSDirectory +) + +// --------------------------------------------------------------------------- + +export { + themesRouter +} + +// --------------------------------------------------------------------------- + +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 }) +} -- cgit v1.2.3