feat: allow portal logo override (#1391)

This commit is contained in:
Markos Gogoulos 2025-09-24 16:26:45 +03:00 committed by GitHub
parent c4c5ecf06a
commit 1c1af489f1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 27 additions and 6 deletions

View File

@ -105,6 +105,16 @@ USE_L10N = True
USE_TZ = True
SITE_ID = 1
# these are the logos by default. SVG gets a priority
# which means it will be used if available
# if you want to override them, set the new paths here
# and place the files on the static/images folder
PORTAL_LOGO_DARK_SVG = "/static/images/logo_dark.svg"
PORTAL_LOGO_DARK_PNG = "/static/images/logo_dark.png"
PORTAL_LOGO_LIGHT_SVG = "/static/images/logo_light.svg"
PORTAL_LOGO_LIGHT_PNG = "/static/images/logo_dark.png"
# protection agains anonymous users
# per ip address limit, for actions as like/dislike/report
TIME_TO_ACTION_ANONYMOUS = 10 * 60

View File

@ -240,7 +240,12 @@ Docker Compose installation: edit `deploy/docker/local_settings.py`, make a chan
### 5.1 Change portal logo
Set a new svg file for the white theme (`static/images/logo_dark.svg`) or the dark theme (`static/images/logo_light.svg`)
Find the default svg files for the white theme on `static/images/logo_dark.svg` and for the dark theme on `static/images/logo_light.svg`
You can specify new svg paths to override by editing the `PORTAL_LOGO_DARK_SVG` and `PORTAL_LOGO_LIGHT_SVG` variables in `settings.py`.
You can also use custom pngs, by setting the variables `PORTAL_LOGO_DARK_PNG` and `PORTAL_LOGO_LIGHT_PNG` in `settings.py`. The svg files have priority over png files, so if both are set, svg files will be used.
In any case, make sure the files are placed on the static/images folder.
### 5.2 Set global portal title

View File

@ -12,6 +12,12 @@ def stuff(request):
ret["FRONTEND_HOST"] = request.build_absolute_uri('/').rstrip('/')
ret["DEFAULT_THEME"] = settings.DEFAULT_THEME
ret["PORTAL_NAME"] = settings.PORTAL_NAME
ret["PORTAL_LOGO_DARK_SVG"] = settings.PORTAL_LOGO_DARK_SVG
ret["PORTAL_LOGO_DARK_PNG"] = settings.PORTAL_LOGO_DARK_PNG
ret["PORTAL_LOGO_LIGHT_SVG"] = settings.PORTAL_LOGO_LIGHT_SVG
ret["PORTAL_LOGO_LIGHT_PNG"] = settings.PORTAL_LOGO_LIGHT_PNG
ret["PORTAL_DESCRIPTION"] = settings.PORTAL_DESCRIPTION
ret["LOAD_FROM_CDN"] = settings.LOAD_FROM_CDN
ret["CAN_LOGIN"] = settings.LOGIN_ALLOWED

View File

@ -4,19 +4,19 @@ MediaCMS.site = {
url: '{{FRONTEND_HOST}}',
api: '{{FRONTEND_HOST}}/api/v1',
theme: {
mode: '{{DEFAULT_THEME}}',
mode: '{{DEFAULT_THEME}}',
switch: {
position: 'sidebar', // Valid values: 'header', 'sidebar'.
},
},
logo:{
lightMode:{
img: "/static/images/logo_dark.png",
svg: "/static/images/logo_dark.svg",
img: "{{PORTAL_LOGO_DARK_PNG}}",
svg: "{{PORTAL_LOGO_DARK_SVG}}",
},
darkMode:{
img: "/static/images/logo_light.png",
svg: "/static/images/logo_light.svg",
img: "{{PORTAL_LOGO_LIGHT_PNG}}",
svg: "{{PORTAL_LOGO_LIGHT_SVG}}",
},
},
pages: {