mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-04 02:09:37 +02:00
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>
This commit is contained in:
parent
27647da17f
commit
caf2aaf4f9
15 changed files with 114 additions and 9 deletions
|
@ -1,6 +1,6 @@
|
|||
import * as express from 'express'
|
||||
import { buildFileLocale, getDefaultLocale, is18nLocale, POSSIBLE_LOCALES } from '../../shared/models/i18n/i18n'
|
||||
import { CUSTOM_HTML_TAG_COMMENTS, EMBED_SIZE, PLUGIN_GLOBAL_CSS_PATH, WEBSERVER } from '../initializers/constants'
|
||||
import { CUSTOM_HTML_TAG_COMMENTS, EMBED_SIZE, PLUGIN_GLOBAL_CSS_PATH, WEBSERVER, FILES_CONTENT_HASH } from '../initializers/constants'
|
||||
import { join } from 'path'
|
||||
import { escapeHTML, sha256 } from '../helpers/core-utils'
|
||||
import { VideoModel } from '../models/video/video'
|
||||
|
@ -101,6 +101,9 @@ export class ClientHtml {
|
|||
let html = buffer.toString()
|
||||
|
||||
if (paramLang) html = ClientHtml.addHtmlLang(html, paramLang)
|
||||
html = ClientHtml.addManifestContentHash(html)
|
||||
html = ClientHtml.addFaviconContentHash(html)
|
||||
html = ClientHtml.addLogoContentHash(html)
|
||||
html = ClientHtml.addCustomCSS(html)
|
||||
html = await ClientHtml.addAsyncPluginCSS(html)
|
||||
|
||||
|
@ -136,6 +139,18 @@ export class ClientHtml {
|
|||
return htmlStringPage.replace('<html>', `<html lang="${paramLang}">`)
|
||||
}
|
||||
|
||||
private static addManifestContentHash (htmlStringPage: string) {
|
||||
return htmlStringPage.replace('[manifestContentHash]', FILES_CONTENT_HASH.MANIFEST)
|
||||
}
|
||||
|
||||
private static addFaviconContentHash(htmlStringPage: string) {
|
||||
return htmlStringPage.replace('[faviconContentHash]', FILES_CONTENT_HASH.FAVICON)
|
||||
}
|
||||
|
||||
private static addLogoContentHash(htmlStringPage: string) {
|
||||
return htmlStringPage.replace('[logoContentHash]', FILES_CONTENT_HASH.LOGO)
|
||||
}
|
||||
|
||||
private static addTitleTag (htmlStringPage: string, title?: string) {
|
||||
let text = title || CONFIG.INSTANCE.NAME
|
||||
if (title) text += ` - ${CONFIG.INSTANCE.NAME}`
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue