Standortauswahl und Multi Logo und Action Button
This commit is contained in:
@@ -6,9 +6,8 @@ from openai import OpenAI
|
||||
# Customer / Willkommensseite
|
||||
# -------------------------------------------------
|
||||
|
||||
WELCOME_DIR = os.path.join(os.path.dirname(__file__), "media", "lobby")
|
||||
|
||||
os.makedirs(WELCOME_DIR, exist_ok=True)
|
||||
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
MEDIA_DIR = os.path.join(BASE_DIR, "media")
|
||||
|
||||
WELCOME_FILENAME = "welcome.html"
|
||||
|
||||
@@ -73,129 +72,82 @@ def search_customer_logo(customer_name):
|
||||
return None
|
||||
|
||||
|
||||
def generate_welcome_html(customer_name, logo_url):
|
||||
print(f"✅ Generate - Willkommensseite wird generiert für: {customer_name} mit Logo: {logo_url}")
|
||||
"""Generate a welcome page HTML with full-screen design"""
|
||||
# CANCOM SVG logo inline
|
||||
def generate_welcome_html(customer_names, logo_urls, site="stuttgart"):
|
||||
site_display = site.capitalize()
|
||||
names_str = ", ".join(customer_names) if customer_names else "Unbekannt"
|
||||
print(f"✅ Generate - Willkommensseite wird generiert für: {names_str} (site: {site})")
|
||||
site_display = site.capitalize()
|
||||
cancom_svg = '''<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xcs="https://www.xtool.com/pages/software" version="1.1" preserveAspectRatio="xMinYMin meet" width="61.682394106284505mm" height="9.909010347638684mm" viewBox="136.55880294685778 209.2954948261807 61.682394106284505 9.909010347638684" xcs:version="2.7.22"><style></style><path transform="matrix(0.158038,0,0,0.158038,133.2558,163.322122)" stroke="none" fill="currentColor" data-view-type="laser" d="M125.9,352.1h18.9L119,291.7h-16.2l-25,60.4h18.2l14.6-38.9L125.9,352.1z M323.6,322 c0,8.8-6.1,16.4-15.4,16.4c-9.1,0-15.4-7.6-15.4-16.4s6.1-16.4,15.2-16.4C317,305.6,323.6,313.4,323.6,322 M340.5,322.3 c0-17.4-13.4-31.3-32.3-31.3c-18.7,0-32.3,14.1-32.3,31.3c0,17.4,13.4,31.3,32.3,31.3C326.9,353.6,340.5,339.4,340.5,322.3 M230.4,322.5c0-8.8,6.1-16.4,14.9-16.4c3,0,5.8,0.8,8.1,2l6.6-13.4c-3-2-8.1-3.8-14.9-3.8c-18.2,0-31.6,14.1-31.6,31.3 c0,18.2,12.6,31.1,31.6,31.1c17.2,0,26-10.6,28.8-21l-13.6-5.6c-1.8,5.8-6.3,11.6-14.4,11.6C236.5,338.4,230.4,331.4,230.4,322.5 M38,322.5c0-8.8,6.1-16.4,14.9-16.4c3,0,5.8,0.8,8.1,2l6.6-13.4c-3-2-8.1-3.8-14.9-3.8c-18.4,0-31.8,14.1-31.8,31.3 c0,18.2,12.6,31.1,31.6,31.1c17.2,0,26-10.6,28.8-21l-13.6-5.6c-1.8,5.8-6.3,11.6-14.4,11.6C44,338.4,38,331.4,38,322.5 M191.8,352.1h14.4v-59.8H190v33.1l-25-33.1h-15.4v60.1h16.2v-34.1L191.8,352.1z M411.2,352.1v-59.8h-17.7l-14.4,23.2l-14.4-23.2 h-17.7v60.1h16.4V318l15.4,23.2h0.3l15.4-23.5v34.6L411.2,352.1L411.2,352.1z" fill-rule="nonzero"></path></svg>'''
|
||||
|
||||
logo_html = ""
|
||||
for i, (name, url) in enumerate(zip(customer_names, logo_urls)):
|
||||
if url:
|
||||
logo_html += f'''
|
||||
<div class="customer-logo-item">
|
||||
<img src="{url}" alt="{name}" class="customer-logo" crossorigin="anonymous">
|
||||
</div>'''
|
||||
|
||||
html_content = f"""<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Willkommen bei CANCOM</title>
|
||||
|
||||
<!-- Tabler CSS -->
|
||||
<link rel="stylesheet"
|
||||
href="https://unpkg.com/@tabler/core@1.0.0-beta20/dist/css/tabler.min.css">
|
||||
<!-- Tabler JS -->
|
||||
<script defer
|
||||
src="https://unpkg.com/@tabler/core@1.0.0-beta20/dist/js/tabler.min.js">
|
||||
</script>
|
||||
|
||||
<style>
|
||||
* {{
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}}
|
||||
* {{ margin: 0; padding: 0; box-sizing: border-box; }}
|
||||
body {{
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
overflow: hidden;
|
||||
width: 100vw; height: 100vh; overflow: hidden;
|
||||
font-family: 'Segoe UI', 'Helvetica Neue', sans-serif;
|
||||
background: linear-gradient(135deg, #87CEEB 0%, #B0E0E6 100%);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
display: flex; align-items: center; justify-content: center;
|
||||
background-image: url("/static/wallpaper.png");
|
||||
background-repeat: no-repeat;
|
||||
background-size: cover;
|
||||
background-repeat: no-repeat; background-size: cover;
|
||||
}}
|
||||
.screen {{
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-end;
|
||||
justify-content: space-between;
|
||||
width: 100%; height: 100%; position: relative;
|
||||
display: flex; flex-direction: column;
|
||||
align-items: flex-end; justify-content: space-between;
|
||||
padding: 60px;
|
||||
background-size: cover;
|
||||
background-position: center left;
|
||||
background-repeat: no-repeat;
|
||||
}}
|
||||
.logo-section {{
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-end;
|
||||
gap: 10px;
|
||||
z-index: 10;
|
||||
display: flex; flex-direction: column;
|
||||
align-items: flex-end; gap: 10px; z-index: 10;
|
||||
}}
|
||||
.cancom-logo {{
|
||||
width: 235px;
|
||||
height: auto;
|
||||
color: #DA002D;
|
||||
width: 235px; height: auto; color: #DA002D;
|
||||
object-fit: contain;
|
||||
filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.1));
|
||||
}}
|
||||
.meets {{
|
||||
font-size: 2.5rem;
|
||||
font-weight: 400;
|
||||
color: #000;
|
||||
margin-top: -8px;
|
||||
margin-bottom: 10px;
|
||||
letter-spacing: 1px;
|
||||
font-size: 2.5rem; font-weight: 400; color: #000;
|
||||
margin-top: -8px; margin-bottom: 10px; letter-spacing: 1px;
|
||||
}}
|
||||
.customer-logos {{
|
||||
display: flex; flex-direction: row;
|
||||
align-items: center; justify-content: flex-end;
|
||||
gap: 48px; max-width: 100%;
|
||||
}}
|
||||
.customer-logo-item {{
|
||||
flex: 0 0 280px;
|
||||
display: flex; align-items: center; justify-content: center;
|
||||
min-height: 100px;
|
||||
}}
|
||||
.customer-logo {{
|
||||
max-width: 300px;
|
||||
width: 100%; height: auto;
|
||||
max-height: 180px;
|
||||
width: auto;
|
||||
height: auto;
|
||||
object-fit: contain;
|
||||
filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.15));
|
||||
margin-top: 18px;
|
||||
}}
|
||||
.customer-logo {{
|
||||
max-width: 300px;
|
||||
max-height: 180px;
|
||||
width: auto;
|
||||
height: auto;
|
||||
object-fit: contain;
|
||||
filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.15));
|
||||
}}
|
||||
.content {{
|
||||
text-align: right;
|
||||
z-index: 10;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 30px;
|
||||
}}
|
||||
.headline {{
|
||||
font-size: 4.5rem;
|
||||
font-weight: 300;
|
||||
letter-spacing: 2px;
|
||||
line-height: 1.2;
|
||||
color: #000;
|
||||
text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.3);
|
||||
}}
|
||||
.headline .red {{
|
||||
color: #DA002D;
|
||||
font-weight: 700;
|
||||
}}
|
||||
.meets {{
|
||||
font-size: 2.5rem;
|
||||
font-weight: 400;
|
||||
color: #000;
|
||||
margin-bottom: 40px;
|
||||
letter-spacing: 1px;
|
||||
text-align: right; z-index: 10;
|
||||
}}
|
||||
.welcome-block {{
|
||||
font-size: 4rem;
|
||||
font-weight: 700;
|
||||
line-height: 1.3;
|
||||
color: #000;
|
||||
font-size: 4rem; font-weight: 700;
|
||||
line-height: 1.3; color: #000;
|
||||
text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.3);
|
||||
}}
|
||||
</style>
|
||||
@@ -205,13 +157,15 @@ def generate_welcome_html(customer_name, logo_url):
|
||||
<div class="logo-section">
|
||||
<div class="cancom-logo">{cancom_svg}</div>
|
||||
<div class="meets">meets</div>
|
||||
{f'<img src="{logo_url}" alt="Kundenlogo" class="customer-logo" crossorigin="anonymous">' if logo_url else ''}
|
||||
<div class="customer-logos">
|
||||
{logo_html}
|
||||
</div>
|
||||
</div>
|
||||
<div class="content">
|
||||
<div class="welcome-block">
|
||||
Herzlich <span style="color: #DA002D;">Willkommen</span><br>
|
||||
<span style="color: #DA002D;">in</span> unserer<br>
|
||||
Niederlassung <span style="color: #DA002D;">Stuttgart!</span>
|
||||
Niederlassung <span style="color: #DA002D;">{site_display}!</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -220,42 +174,51 @@ def generate_welcome_html(customer_name, logo_url):
|
||||
return html_content
|
||||
|
||||
|
||||
def save_welcome_page(customer_name, logo_url):
|
||||
def save_welcome_page(customer_names, logo_urls, site="stuttgart"):
|
||||
"""Save welcome page and return filename"""
|
||||
try:
|
||||
filepath = os.path.join(os.path.abspath(WELCOME_DIR), WELCOME_FILENAME)
|
||||
html_content = generate_welcome_html(customer_name, logo_url)
|
||||
welcome_dir = os.path.join(MEDIA_DIR, site, "lobby")
|
||||
os.makedirs(welcome_dir, exist_ok=True)
|
||||
filepath = os.path.join(os.path.abspath(welcome_dir), WELCOME_FILENAME)
|
||||
html_content = generate_welcome_html(customer_names, logo_urls, site=site)
|
||||
|
||||
with open(filepath, "w", encoding="utf-8") as f:
|
||||
f.write(html_content)
|
||||
if os.path.getsize(filepath) == 0:
|
||||
raise IOError("File not written")
|
||||
print(f"✅ Generate - Willkommensseite generiert für: {customer_name}")
|
||||
names_str = ", ".join(customer_names)
|
||||
print(f"✅ Generate - Willkommensseite generiert für: {names_str} (site: {site})")
|
||||
print(f"✅ Generate - Willkommensseite gespeichert in: {filepath}")
|
||||
print(f"✅ Generate - Willkommensseite gespeichert: {WELCOME_FILENAME}")
|
||||
return WELCOME_FILENAME
|
||||
except Exception as e:
|
||||
print(f"❌ Error saving welcome page: {e}")
|
||||
return None
|
||||
|
||||
|
||||
def add_customer_to_lobby_playlist(html_filename):
|
||||
"""Add customer welcome page to lobby playlist"""
|
||||
def add_customer_to_lobby_playlist(html_filename, site="stuttgart"):
|
||||
"""Add customer welcome page to lobby playlist for a specific site"""
|
||||
try:
|
||||
# Import here to avoid circular imports
|
||||
from app import load_config, save_config
|
||||
|
||||
config = load_config()
|
||||
screens = config.setdefault("screens", {})
|
||||
sites_cfg = config.setdefault("sites", {})
|
||||
site_cfg = sites_cfg.setdefault(site, {"screens": {}})
|
||||
screens = site_cfg.setdefault("screens", {})
|
||||
lobby = screens.setdefault("lobby", {})
|
||||
playlist = lobby.setdefault("playlist", [])
|
||||
|
||||
full_filename = f"{html_filename}"
|
||||
if full_filename in playlist:
|
||||
playlist.remove(full_filename)
|
||||
playlist[:] = [
|
||||
item for item in playlist
|
||||
if not (
|
||||
(isinstance(item, str) and item == full_filename) or
|
||||
(isinstance(item, dict) and item.get("name") == full_filename)
|
||||
)
|
||||
]
|
||||
playlist.insert(0, full_filename)
|
||||
save_config(config)
|
||||
print(f"✅ Generate - Willkommensseite in Lobby-Playliste platziert")
|
||||
print(f"✅ Generate - Willkommensseite in Lobby-Playliste platziert (site: {site})")
|
||||
return True
|
||||
except Exception as e:
|
||||
print(f"❌ Generate - Error adding to playlist: {e}")
|
||||
|
||||
Reference in New Issue
Block a user