Add dynamic branding

This commit is contained in:
2026-01-18 20:55:27 +00:00
parent 3bdf66cb98
commit 9b2b15c570
3 changed files with 16 additions and 3 deletions

View File

@@ -6,6 +6,7 @@ import threading
import logging import logging
import xml.etree.ElementTree as ET import xml.etree.ElementTree as ET
from os import path from os import path
from urllib.parse import urlsplit
from re import match from re import match
import json import json
from requests import post from requests import post
@@ -58,6 +59,18 @@ class DiscordLogger(logging.Handler):
discord_logger = DiscordLogger(environ['DISCORD_ERR_HOOK']) discord_logger = DiscordLogger(environ['DISCORD_ERR_HOOK'])
app.logger.addHandler(discord_logger) app.logger.addHandler(discord_logger)
@app.context_processor
def inject_branding() -> dict:
''' Modify branding depending on the URL being used '''
req_domain = urlsplit(request.base_url).netloc.lower()
match req_domain:
case 'jakecharman.co.uk':
brand = 'Jake Charman'
case _:
brand = req_domain
return {'branding': brand}
@app.route('/') @app.route('/')
def index() -> str: def index() -> str:
''' Load the homepage ''' ''' Load the homepage '''

View File

@@ -1,5 +1,5 @@
<footer> <footer>
<p>&copy <span id="cr-year"></span> Jake Charman. This site uses cookies.</p> <p>&copy <span id="cr-year"></span> {{branding}}. This site uses cookies.</p>
</footer> </footer>
</body> </body>
</html> </html>

View File

@@ -3,7 +3,7 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Personal website of Jake Charman. A technology professional based in the UK."> <meta name="description" content="Personal website of Jake Charman. A technology professional based in the UK.">
<title>{{ page_title }}Jake Charman</title> <title>{{ page_title }}{{branding}}</title>
<link href="https://fonts.googleapis.com/css2?family=Orbitron:wght@400..900&family=Tourney:ital,wght@0,100..900;1,100..900&display=swap" rel="stylesheet"> <link href="https://fonts.googleapis.com/css2?family=Orbitron:wght@400..900&family=Tourney:ital,wght@0,100..900;1,100..900&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans:ital,wght@0,100..900;1,100..900&family=Orbitron:wght@400..900&family=Tourney:ital,wght@0,100..900;1,100..900&display=swap" rel="stylesheet"> <link href="https://fonts.googleapis.com/css2?family=Noto+Sans:ital,wght@0,100..900;1,100..900&family=Orbitron:wght@400..900&family=Tourney:ital,wght@0,100..900;1,100..900&display=swap" rel="stylesheet">
<link rel="stylesheet" href="/static/style/mobile.css" /> <link rel="stylesheet" href="/static/style/mobile.css" />
@@ -33,7 +33,7 @@
</nav> </nav>
<div id="logo-container"> <div id="logo-container">
<div id="logo"> <div id="logo">
<a href='/'><h1>Jake Charman</h1></a> <a href='/'><h1>{{branding|upper}}</h1></a>
</div> </div>
</div> </div>
</header> </header>