diff options
author | Kim <1877318+kimsible@users.noreply.github.com> | 2020-07-10 10:20:11 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-10 10:20:11 +0200 |
commit | caf2aaf4f9d38ad441a5562c3b8720f8779d6f78 (patch) | |
tree | 2a93cbfd2aee6089fd334f28dcb47c18a368a6fd /server/lib | |
parent | 27647da17fe53ff24ed27ef8618bc244c0be6b26 (diff) | |
download | PeerTube-caf2aaf4f9d38ad441a5562c3b8720f8779d6f78.tar.gz PeerTube-caf2aaf4f9d38ad441a5562c3b8720f8779d6f78.tar.zst PeerTube-caf2aaf4f9d38ad441a5562c3b8720f8779d6f78.zip |
Add ability to override client assets : logo - favicon - PWA icons - PWA manifest name and description (#2897)
* Add client-overrides storage to config
* Add static-serve for client overrides
* Move backgroun-image logo from bundle to css tag for runtime content hash
* Add dynamic JSON manifest
* Add content hash for manifest, favicon and logo
Co-authored-by: kimsible <kimsible@users.noreply.github.com>
Diffstat (limited to 'server/lib')
-rw-r--r-- | server/lib/client-html.ts | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/server/lib/client-html.ts b/server/lib/client-html.ts index 3e6da2898..5996f3c70 100644 --- a/server/lib/client-html.ts +++ b/server/lib/client-html.ts | |||
@@ -1,6 +1,6 @@ | |||
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, PLUGIN_GLOBAL_CSS_PATH, WEBSERVER } from '../initializers/constants' | 3 | import { CUSTOM_HTML_TAG_COMMENTS, EMBED_SIZE, PLUGIN_GLOBAL_CSS_PATH, WEBSERVER, FILES_CONTENT_HASH } from '../initializers/constants' |
4 | import { join } from 'path' | 4 | import { join } from 'path' |
5 | import { escapeHTML, sha256 } 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' |
@@ -101,6 +101,9 @@ export class ClientHtml { | |||
101 | let html = buffer.toString() | 101 | let html = buffer.toString() |
102 | 102 | ||
103 | if (paramLang) html = ClientHtml.addHtmlLang(html, paramLang) | 103 | if (paramLang) html = ClientHtml.addHtmlLang(html, paramLang) |
104 | html = ClientHtml.addManifestContentHash(html) | ||
105 | html = ClientHtml.addFaviconContentHash(html) | ||
106 | html = ClientHtml.addLogoContentHash(html) | ||
104 | html = ClientHtml.addCustomCSS(html) | 107 | html = ClientHtml.addCustomCSS(html) |
105 | html = await ClientHtml.addAsyncPluginCSS(html) | 108 | html = await ClientHtml.addAsyncPluginCSS(html) |
106 | 109 | ||
@@ -136,6 +139,18 @@ export class ClientHtml { | |||
136 | return htmlStringPage.replace('<html>', `<html lang="${paramLang}">`) | 139 | return htmlStringPage.replace('<html>', `<html lang="${paramLang}">`) |
137 | } | 140 | } |
138 | 141 | ||
142 | private static addManifestContentHash (htmlStringPage: string) { | ||
143 | return htmlStringPage.replace('[manifestContentHash]', FILES_CONTENT_HASH.MANIFEST) | ||
144 | } | ||
145 | |||
146 | private static addFaviconContentHash(htmlStringPage: string) { | ||
147 | return htmlStringPage.replace('[faviconContentHash]', FILES_CONTENT_HASH.FAVICON) | ||
148 | } | ||
149 | |||
150 | private static addLogoContentHash(htmlStringPage: string) { | ||
151 | return htmlStringPage.replace('[logoContentHash]', FILES_CONTENT_HASH.LOGO) | ||
152 | } | ||
153 | |||
139 | private static addTitleTag (htmlStringPage: string, title?: string) { | 154 | private static addTitleTag (htmlStringPage: string, title?: string) { |
140 | let text = title || CONFIG.INSTANCE.NAME | 155 | let text = title || CONFIG.INSTANCE.NAME |
141 | if (title) text += ` - ${CONFIG.INSTANCE.NAME}` | 156 | if (title) text += ` - ${CONFIG.INSTANCE.NAME}` |