aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib
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/lib
parent7cd4d2ba10106c10602c86f74f55743ded588896 (diff)
downloadPeerTube-ffb321bedca46d6987c7b31dd58e5dea96ea2ea2.tar.gz
PeerTube-ffb321bedca46d6987c7b31dd58e5dea96ea2ea2.tar.zst
PeerTube-ffb321bedca46d6987c7b31dd58e5dea96ea2ea2.zip
WIP plugins: load theme on client side
Diffstat (limited to 'server/lib')
-rw-r--r--server/lib/client-html.ts9
-rw-r--r--server/lib/plugins/theme-utils.ts10
2 files changed, 13 insertions, 6 deletions
diff --git a/server/lib/client-html.ts b/server/lib/client-html.ts
index 516827a05..ccc963514 100644
--- a/server/lib/client-html.ts
+++ b/server/lib/client-html.ts
@@ -92,6 +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 96
96 ClientHtml.htmlCache[ path ] = html 97 ClientHtml.htmlCache[ path ] = html
97 98
@@ -138,11 +139,17 @@ export class ClientHtml {
138 } 139 }
139 140
140 private static addCustomCSS (htmlStringPage: string) { 141 private static addCustomCSS (htmlStringPage: string) {
141 const styleTag = '<style class="custom-css-style">' + CONFIG.INSTANCE.CUSTOMIZATIONS.CSS + '</style>' 142 const styleTag = `<style class="custom-css-style">${CONFIG.INSTANCE.CUSTOMIZATIONS.CSS}</style>`
142 143
143 return htmlStringPage.replace(CUSTOM_HTML_TAG_COMMENTS.CUSTOM_CSS, styleTag) 144 return htmlStringPage.replace(CUSTOM_HTML_TAG_COMMENTS.CUSTOM_CSS, styleTag)
144 } 145 }
145 146
147 private static addPluginCSS (htmlStringPage: string) {
148 const linkTag = `<link rel="stylesheet" href="/plugins/global.css" />`
149
150 return htmlStringPage.replace('</head>', linkTag + '</head>')
151 }
152
146 private static addVideoOpenGraphAndOEmbedTags (htmlStringPage: string, video: VideoModel) { 153 private static addVideoOpenGraphAndOEmbedTags (htmlStringPage: string, video: VideoModel) {
147 const previewUrl = WEBSERVER.URL + video.getPreviewStaticPath() 154 const previewUrl = WEBSERVER.URL + video.getPreviewStaticPath()
148 const videoUrl = WEBSERVER.URL + video.getWatchStaticPath() 155 const videoUrl = WEBSERVER.URL + video.getWatchStaticPath()
diff --git a/server/lib/plugins/theme-utils.ts b/server/lib/plugins/theme-utils.ts
index 066339e65..76c671f1c 100644
--- a/server/lib/plugins/theme-utils.ts
+++ b/server/lib/plugins/theme-utils.ts
@@ -1,18 +1,18 @@
1import { DEFAULT_THEME } from '../../initializers/constants' 1import { DEFAULT_THEME_NAME, DEFAULT_USER_THEME_NAME } from '../../initializers/constants'
2import { PluginManager } from './plugin-manager' 2import { PluginManager } from './plugin-manager'
3import { CONFIG } from '../../initializers/config' 3import { CONFIG } from '../../initializers/config'
4 4
5function getThemeOrDefault (name: string) { 5function getThemeOrDefault (name: string, defaultTheme: string) {
6 if (isThemeRegistered(name)) return name 6 if (isThemeRegistered(name)) return name
7 7
8 // Fallback to admin default theme 8 // Fallback to admin default theme
9 if (name !== CONFIG.THEME.DEFAULT) return getThemeOrDefault(CONFIG.THEME.DEFAULT) 9 if (name !== CONFIG.THEME.DEFAULT) return getThemeOrDefault(CONFIG.THEME.DEFAULT, DEFAULT_THEME_NAME)
10 10
11 return DEFAULT_THEME 11 return defaultTheme
12} 12}
13 13
14function isThemeRegistered (name: string) { 14function isThemeRegistered (name: string) {
15 if (name === DEFAULT_THEME) return true 15 if (name === DEFAULT_THEME_NAME || name === DEFAULT_USER_THEME_NAME) return true
16 16
17 return !!PluginManager.Instance.getRegisteredThemes() 17 return !!PluginManager.Instance.getRegisteredThemes()
18 .find(r => r.name === name) 18 .find(r => r.name === name)