Use URL-based logos, env-based WebGUI title, apstrom.ca link, update README
This commit is contained in:
+16
-7
@@ -64,11 +64,19 @@ def _load_css(path: str) -> str:
|
||||
return f.read()
|
||||
|
||||
|
||||
def _logo1_inline_html() -> str:
|
||||
def _email_logo_html() -> str:
|
||||
"""
|
||||
Return an inline <img> tag for logo1.png as base64.
|
||||
Falls back to empty string if not found.
|
||||
Return logo HTML for emails.
|
||||
|
||||
Priority:
|
||||
1) EMAIL_LOGO_URL (direct URL to logo image)
|
||||
2) EMAIL_LOGO_PATH (local file; embedded as base64)
|
||||
3) empty string if neither is set.
|
||||
"""
|
||||
logo_url = os.getenv("EMAIL_LOGO_URL")
|
||||
if logo_url:
|
||||
return f'<img src="{logo_url}" alt="Logo" style="max-width:180px; display:block; margin:0 auto 10px auto;"/>'
|
||||
|
||||
logo_path = os.getenv("EMAIL_LOGO_PATH", "/app/src/misc/logo1.png")
|
||||
if not os.path.exists(logo_path):
|
||||
return ""
|
||||
@@ -76,7 +84,7 @@ def _logo1_inline_html() -> str:
|
||||
try:
|
||||
with open(logo_path, "rb") as f:
|
||||
b64 = base64.b64encode(f.read()).decode("utf-8")
|
||||
return f'<img src="data:image/png;base64,{b64}" alt="A.P.Strom" style="max-width:180px; display:block; margin:0 auto 10px auto;"/>'
|
||||
return f'<img src="data:image/png;base64,{b64}" alt="Logo" style="max-width:180px; display:block; margin:0 auto 10px auto;"/>'
|
||||
except Exception:
|
||||
return ""
|
||||
|
||||
@@ -90,14 +98,15 @@ def build_template_context(**runtime_kwargs: Any) -> Dict[str, Any]:
|
||||
Environment variables:
|
||||
- EMAIL_CONTACT_ADDRESS: value for {contact_email}
|
||||
- EMAIL_CSS_PATH: path to mail_style.css (optional; we inline it)
|
||||
- EMAIL_LOGO_PATH: path to logo1.png (default: /app/src/misc/logo1.png)
|
||||
- EMAIL_LOGO_URL: URL for email logo (preferred)
|
||||
- EMAIL_LOGO_PATH: fallback local path for email logo
|
||||
"""
|
||||
# Load and inline mail_style.css for consistent email styling
|
||||
css_path = os.getenv("EMAIL_CSS_PATH", "/app/src/misc/mail_style.css")
|
||||
css_text = _load_css(css_path)
|
||||
|
||||
# Build inline logo HTML
|
||||
logo_html = _logo1_inline_html()
|
||||
# Build logo HTML (URL or local fallback)
|
||||
logo_html = _email_logo_html()
|
||||
|
||||
ctx: Dict[str, Any] = {
|
||||
"contact_email": os.getenv("EMAIL_CONTACT_ADDRESS", "support@example.com"),
|
||||
|
||||
Reference in New Issue
Block a user