]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/lib/client-html.ts
Add plugin table migration table
[github/Chocobozzz/PeerTube.git] / server / lib / client-html.ts
index 217f6a437ab65f0ebdae3be6fd89dcd869a52c4c..ccc963514ac46acde0bda562ac93ff06d4895460 100644 (file)
@@ -1,6 +1,6 @@
 import * as express from 'express'
 import { buildFileLocale, getDefaultLocale, is18nLocale, POSSIBLE_LOCALES } from '../../shared/models/i18n/i18n'
-import { CONFIG, CUSTOM_HTML_TAG_COMMENTS, EMBED_SIZE } from '../initializers'
+import { CUSTOM_HTML_TAG_COMMENTS, EMBED_SIZE, WEBSERVER } from '../initializers/constants'
 import { join } from 'path'
 import { escapeHTML } from '../helpers/core-utils'
 import { VideoModel } from '../models/video/video'
@@ -11,6 +11,7 @@ import { getActivityStreamDuration } from '../models/video/video-format-utils'
 import { AccountModel } from '../models/account/account'
 import { VideoChannelModel } from '../models/video/video-channel'
 import * as Bluebird from 'bluebird'
+import { CONFIG } from '../initializers/config'
 
 export class ClientHtml {
 
@@ -91,6 +92,7 @@ export class ClientHtml {
     let html = buffer.toString()
 
     html = ClientHtml.addCustomCSS(html)
+    html = ClientHtml.addPluginCSS(html)
 
     ClientHtml.htmlCache[ path ] = html
 
@@ -106,7 +108,7 @@ export class ClientHtml {
 
       // Save locale in cookies
       res.cookie('clientLanguage', lang, {
-        secure: CONFIG.WEBSERVER.SCHEME === 'https',
+        secure: WEBSERVER.SCHEME === 'https',
         sameSite: true,
         maxAge: 1000 * 3600 * 24 * 90 // 3 months
       })
@@ -137,18 +139,24 @@ export class ClientHtml {
   }
 
   private static addCustomCSS (htmlStringPage: string) {
-    const styleTag = '<style class="custom-css-style">' + CONFIG.INSTANCE.CUSTOMIZATIONS.CSS + '</style>'
+    const styleTag = `<style class="custom-css-style">${CONFIG.INSTANCE.CUSTOMIZATIONS.CSS}</style>`
 
     return htmlStringPage.replace(CUSTOM_HTML_TAG_COMMENTS.CUSTOM_CSS, styleTag)
   }
 
+  private static addPluginCSS (htmlStringPage: string) {
+    const linkTag = `<link rel="stylesheet" href="/plugins/global.css" />`
+
+    return htmlStringPage.replace('</head>', linkTag + '</head>')
+  }
+
   private static addVideoOpenGraphAndOEmbedTags (htmlStringPage: string, video: VideoModel) {
-    const previewUrl = CONFIG.WEBSERVER.URL + video.getPreviewStaticPath()
-    const videoUrl = CONFIG.WEBSERVER.URL + video.getWatchStaticPath()
+    const previewUrl = WEBSERVER.URL + video.getPreviewStaticPath()
+    const videoUrl = WEBSERVER.URL + video.getWatchStaticPath()
 
     const videoNameEscaped = escapeHTML(video.name)
     const videoDescriptionEscaped = escapeHTML(video.description)
-    const embedUrl = CONFIG.WEBSERVER.URL + video.getEmbedStaticPath()
+    const embedUrl = WEBSERVER.URL + video.getEmbedStaticPath()
 
     const openGraphMetaTags = {
       'og:type': 'video',
@@ -180,7 +188,7 @@ export class ClientHtml {
     const oembedLinkTags = [
       {
         type: 'application/json+oembed',
-        href: CONFIG.WEBSERVER.URL + '/services/oembed?url=' + encodeURIComponent(videoUrl),
+        href: WEBSERVER.URL + '/services/oembed?url=' + encodeURIComponent(videoUrl),
         title: videoNameEscaped
       }
     ]