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/initializers | |
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/initializers')
-rw-r--r-- | server/initializers/config.ts | 3 | ||||
-rw-r--r-- | server/initializers/constants.ts | 17 |
2 files changed, 18 insertions, 2 deletions
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 = { | |||
68 | CAPTIONS_DIR: buildPath(config.get<string>('storage.captions')), | 68 | CAPTIONS_DIR: buildPath(config.get<string>('storage.captions')), |
69 | TORRENTS_DIR: buildPath(config.get<string>('storage.torrents')), | 69 | TORRENTS_DIR: buildPath(config.get<string>('storage.torrents')), |
70 | CACHE_DIR: buildPath(config.get<string>('storage.cache')), | 70 | CACHE_DIR: buildPath(config.get<string>('storage.cache')), |
71 | PLUGINS_DIR: buildPath(config.get<string>('storage.plugins')) | 71 | PLUGINS_DIR: buildPath(config.get<string>('storage.plugins')), |
72 | CLIENT_OVERRIDES_DIR: buildPath(config.get<string>('storage.client_overrides')) | ||
72 | }, | 73 | }, |
73 | WEBSERVER: { | 74 | WEBSERVER: { |
74 | SCHEME: config.get<boolean>('webserver.https') === true ? 'https' : 'http', | 75 | SCHEME: config.get<boolean>('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 @@ | |||
1 | import { join } from 'path' | 1 | import { join } from 'path' |
2 | import { randomBytes } from 'crypto' | ||
2 | import { JobType, VideoRateType, VideoResolution, VideoState } from '../../shared/models' | 3 | import { JobType, VideoRateType, VideoResolution, VideoState } from '../../shared/models' |
3 | import { ActivityPubActorType } from '../../shared/models/activitypub' | 4 | import { ActivityPubActorType } from '../../shared/models/activitypub' |
4 | import { FollowState } from '../../shared/models/actors' | 5 | import { FollowState } from '../../shared/models/actors' |
@@ -710,6 +711,14 @@ registerConfigChangedHandler(() => { | |||
710 | 711 | ||
711 | // --------------------------------------------------------------------------- | 712 | // --------------------------------------------------------------------------- |
712 | 713 | ||
714 | const FILES_CONTENT_HASH = { | ||
715 | MANIFEST: generateContentHash(), | ||
716 | FAVICON: generateContentHash(), | ||
717 | LOGO: generateContentHash() | ||
718 | } | ||
719 | |||
720 | // --------------------------------------------------------------------------- | ||
721 | |||
713 | export { | 722 | export { |
714 | WEBSERVER, | 723 | WEBSERVER, |
715 | API_VERSION, | 724 | API_VERSION, |
@@ -792,8 +801,10 @@ export { | |||
792 | VIDEO_PLAYLIST_PRIVACIES, | 801 | VIDEO_PLAYLIST_PRIVACIES, |
793 | PLUGIN_EXTERNAL_AUTH_TOKEN_LIFETIME, | 802 | PLUGIN_EXTERNAL_AUTH_TOKEN_LIFETIME, |
794 | ASSETS_PATH, | 803 | ASSETS_PATH, |
804 | FILES_CONTENT_HASH, | ||
795 | loadLanguages, | 805 | loadLanguages, |
796 | buildLanguages | 806 | buildLanguages, |
807 | generateContentHash | ||
797 | } | 808 | } |
798 | 809 | ||
799 | // --------------------------------------------------------------------------- | 810 | // --------------------------------------------------------------------------- |
@@ -895,3 +906,7 @@ function buildLanguages () { | |||
895 | 906 | ||
896 | return languages | 907 | return languages |
897 | } | 908 | } |
909 | |||
910 | function generateContentHash () { | ||
911 | return randomBytes(20).toString('hex') | ||
912 | } | ||