From caf2aaf4f9d38ad441a5562c3b8720f8779d6f78 Mon Sep 17 00:00:00 2001 From: Kim <1877318+kimsible@users.noreply.github.com> Date: Fri, 10 Jul 2020 10:20:11 +0200 Subject: 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 --- server/initializers/config.ts | 3 ++- server/initializers/constants.ts | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) (limited to 'server/initializers') diff --git a/server/initializers/config.ts b/server/initializers/config.ts index 48e2cbc1a..32bd3bbe2 100644 --- a/server/initializers/config.ts +++ b/server/initializers/config.ts @@ -68,7 +68,8 @@ const CONFIG = { CAPTIONS_DIR: buildPath(config.get('storage.captions')), TORRENTS_DIR: buildPath(config.get('storage.torrents')), CACHE_DIR: buildPath(config.get('storage.cache')), - PLUGINS_DIR: buildPath(config.get('storage.plugins')) + PLUGINS_DIR: buildPath(config.get('storage.plugins')), + CLIENT_OVERRIDES_DIR: buildPath(config.get('storage.client_overrides')) }, WEBSERVER: { SCHEME: config.get('webserver.https') === true ? 'https' : 'http', diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index 9a262fd4b..e730e3c84 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts @@ -1,4 +1,5 @@ import { join } from 'path' +import { randomBytes } from 'crypto' import { JobType, VideoRateType, VideoResolution, VideoState } from '../../shared/models' import { ActivityPubActorType } from '../../shared/models/activitypub' import { FollowState } from '../../shared/models/actors' @@ -710,6 +711,14 @@ registerConfigChangedHandler(() => { // --------------------------------------------------------------------------- +const FILES_CONTENT_HASH = { + MANIFEST: generateContentHash(), + FAVICON: generateContentHash(), + LOGO: generateContentHash() +} + +// --------------------------------------------------------------------------- + export { WEBSERVER, API_VERSION, @@ -792,8 +801,10 @@ export { VIDEO_PLAYLIST_PRIVACIES, PLUGIN_EXTERNAL_AUTH_TOKEN_LIFETIME, ASSETS_PATH, + FILES_CONTENT_HASH, loadLanguages, - buildLanguages + buildLanguages, + generateContentHash } // --------------------------------------------------------------------------- @@ -895,3 +906,7 @@ function buildLanguages () { return languages } + +function generateContentHash () { + return randomBytes(20).toString('hex') +} -- cgit v1.2.3