diff options
Diffstat (limited to 'server/lib')
-rw-r--r-- | server/lib/client-html.ts | 14 | ||||
-rw-r--r-- | server/lib/plugins/plugin-manager.ts | 3 |
2 files changed, 12 insertions, 5 deletions
diff --git a/server/lib/client-html.ts b/server/lib/client-html.ts index ccc963514..1e7897220 100644 --- a/server/lib/client-html.ts +++ b/server/lib/client-html.ts | |||
@@ -1,8 +1,8 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { buildFileLocale, getDefaultLocale, is18nLocale, POSSIBLE_LOCALES } from '../../shared/models/i18n/i18n' | 2 | import { buildFileLocale, getDefaultLocale, is18nLocale, POSSIBLE_LOCALES } from '../../shared/models/i18n/i18n' |
3 | import { CUSTOM_HTML_TAG_COMMENTS, EMBED_SIZE, WEBSERVER } from '../initializers/constants' | 3 | import { CUSTOM_HTML_TAG_COMMENTS, EMBED_SIZE, PLUGIN_GLOBAL_CSS_PATH, WEBSERVER } from '../initializers/constants' |
4 | import { join } from 'path' | 4 | import { join } from 'path' |
5 | import { escapeHTML } from '../helpers/core-utils' | 5 | import { escapeHTML, sha256 } from '../helpers/core-utils' |
6 | import { VideoModel } from '../models/video/video' | 6 | import { VideoModel } from '../models/video/video' |
7 | import * as validator from 'validator' | 7 | import * as validator from 'validator' |
8 | import { VideoPrivacy } from '../../shared/models/videos' | 8 | import { VideoPrivacy } from '../../shared/models/videos' |
@@ -92,7 +92,7 @@ export class ClientHtml { | |||
92 | let html = buffer.toString() | 92 | let html = buffer.toString() |
93 | 93 | ||
94 | html = ClientHtml.addCustomCSS(html) | 94 | html = ClientHtml.addCustomCSS(html) |
95 | html = ClientHtml.addPluginCSS(html) | 95 | html = await ClientHtml.addAsyncPluginCSS(html) |
96 | 96 | ||
97 | ClientHtml.htmlCache[ path ] = html | 97 | ClientHtml.htmlCache[ path ] = html |
98 | 98 | ||
@@ -144,8 +144,12 @@ export class ClientHtml { | |||
144 | return htmlStringPage.replace(CUSTOM_HTML_TAG_COMMENTS.CUSTOM_CSS, styleTag) | 144 | return htmlStringPage.replace(CUSTOM_HTML_TAG_COMMENTS.CUSTOM_CSS, styleTag) |
145 | } | 145 | } |
146 | 146 | ||
147 | private static addPluginCSS (htmlStringPage: string) { | 147 | private static async addAsyncPluginCSS (htmlStringPage: string) { |
148 | const linkTag = `<link rel="stylesheet" href="/plugins/global.css" />` | 148 | const globalCSSContent = await readFile(PLUGIN_GLOBAL_CSS_PATH) |
149 | if (!globalCSSContent) return htmlStringPage | ||
150 | |||
151 | const fileHash = sha256(globalCSSContent) | ||
152 | const linkTag = `<link rel="stylesheet" href="/plugins/global.css?hash=${fileHash}" />` | ||
149 | 153 | ||
150 | return htmlStringPage.replace('</head>', linkTag + '</head>') | 154 | return htmlStringPage.replace('</head>', linkTag + '</head>') |
151 | } | 155 | } |
diff --git a/server/lib/plugins/plugin-manager.ts b/server/lib/plugins/plugin-manager.ts index cfe63e50d..c0b49c7c7 100644 --- a/server/lib/plugins/plugin-manager.ts +++ b/server/lib/plugins/plugin-manager.ts | |||
@@ -17,6 +17,7 @@ import { ServerHook, ServerHookName, serverHookObject } from '../../../shared/mo | |||
17 | import { getHookType, internalRunHook } from '../../../shared/core-utils/plugins/hooks' | 17 | import { getHookType, internalRunHook } from '../../../shared/core-utils/plugins/hooks' |
18 | import { RegisterOptions } from '../../typings/plugins/register-options.model' | 18 | import { RegisterOptions } from '../../typings/plugins/register-options.model' |
19 | import { PluginLibrary } from '../../typings/plugins' | 19 | import { PluginLibrary } from '../../typings/plugins' |
20 | import { ClientHtml } from '../client-html' | ||
20 | 21 | ||
21 | export interface RegisteredPlugin { | 22 | export interface RegisteredPlugin { |
22 | npmName: string | 23 | npmName: string |
@@ -323,6 +324,8 @@ export class PluginManager implements ServerHook { | |||
323 | for (const cssPath of cssRelativePaths) { | 324 | for (const cssPath of cssRelativePaths) { |
324 | await this.concatFiles(join(pluginPath, cssPath), PLUGIN_GLOBAL_CSS_PATH) | 325 | await this.concatFiles(join(pluginPath, cssPath), PLUGIN_GLOBAL_CSS_PATH) |
325 | } | 326 | } |
327 | |||
328 | ClientHtml.invalidCache() | ||
326 | } | 329 | } |
327 | 330 | ||
328 | private concatFiles (input: string, output: string) { | 331 | private concatFiles (input: string, output: string) { |