Compare commits

2 Commits

Author SHA1 Message Date
smueller
9f42cc77cc Enhance UI and functionality for admin dashboard and user management
- Update `_base_context` to include `active_nav` for dynamic navigation highlighting.
- Revamp `base.html` to improve header layout and navigation links for better user experience.
- Redesign `dashboard.html` to include statistics for new and edited articles, enhancing visibility of content changes.
- Improve `users.html` layout for user management, adding detailed user roles and status indicators.
- Update CSS styles for a cohesive design across the application, introducing new color variables and layout adjustments.
2026-07-03 13:44:57 +02:00
smueller
df4424fdf9 Enhance newsletter HTML generation and UI components
- Introduce helper functions `_outlook_font` and `_outlook_link` for better formatting in Outlook-compatible HTML.
- Update `create_outlook_html` to utilize new font and link functions, improving the overall appearance of the newsletter.
- Modify CSS to add styles for a new copy dialog overlay and related components.
- Refactor JavaScript to improve copy functionality and add a dialog for copying HTML content.
- Update dashboard template to enhance user instructions for copying and downloading HTML content.
2026-07-03 13:17:11 +02:00
8 changed files with 1383 additions and 434 deletions

View File

@@ -93,10 +93,15 @@ def _bootstrap_admin() -> None:
def _base_context(request: Request, user: User, db: Session) -> dict: def _base_context(request: Request, user: User, db: Session) -> dict:
path = request.url.path
active_nav = "dashboard"
if path.startswith("/admin/users"):
active_nav = "users"
return { return {
"user": user, "user": user,
"csrf_token": request.cookies.get(CSRF_COOKIE_NAME) or ensure_csrf_cookie(request), "csrf_token": request.cookies.get(CSRF_COOKIE_NAME) or ensure_csrf_cookie(request),
"smtp": get_smtp_settings(db), "smtp": get_smtp_settings(db),
"active_nav": active_nav,
} }

View File

@@ -10,17 +10,24 @@ LINE = "=" * 78
SUBLINE = "-" * 78 SUBLINE = "-" * 78
FONT = "Arial, Helvetica, sans-serif" FONT = "Arial, Helvetica, sans-serif"
# Thomas-Krenn.AG Corporate Design (Orange + Anthrazit)
COLOR_TK_ORANGE = "#ED6B06"
COLOR_TK_ORANGE_DARK = "#C95605"
COLOR_TK_ORANGE_LIGHT = "#FFF4ED"
COLOR_TK_GRAY_DARK = "#4A4A4A"
COLOR_TK_GRAY = "#6B6B6B"
COLOR_TK_GRAY_LIGHT = "#F5F5F5"
COLOR_TEXT = "#1A1A1A" COLOR_TEXT = "#1A1A1A"
COLOR_MUTED = "#5C6670" COLOR_MUTED = COLOR_TK_GRAY
COLOR_HEADING = "#003366" COLOR_HEADING = COLOR_TK_GRAY_DARK
COLOR_LINK = "#0055A4" COLOR_LINK = COLOR_TK_ORANGE
COLOR_BORDER = "#D7DEE8" COLOR_BORDER = "#E0E0E0"
COLOR_BG = "#EEF2F7" COLOR_BG = COLOR_TK_GRAY_LIGHT
COLOR_WHITE = "#FFFFFF" COLOR_WHITE = "#FFFFFF"
COLOR_ACCENT_NEW = "#1F7A4D" COLOR_ACCENT_NEW = COLOR_TK_ORANGE
COLOR_ACCENT_NEW_BG = "#E8F6EE" COLOR_ACCENT_NEW_BG = COLOR_TK_ORANGE_LIGHT
COLOR_ACCENT_EDIT = "#0055A4" COLOR_ACCENT_EDIT = COLOR_TK_GRAY_DARK
COLOR_ACCENT_EDIT_BG = "#E8F1FA" COLOR_ACCENT_EDIT_BG = "#EEEEEE"
class DisplayOptions(TypedDict): class DisplayOptions(TypedDict):
@@ -204,18 +211,18 @@ def create_html(
<td align="center" style="padding:28px 16px;font-family:{FONT};"> <td align="center" style="padding:28px 16px;font-family:{FONT};">
<table role="presentation" width="680" cellpadding="0" cellspacing="0" border="0" style="width:680px;max-width:680px;background:{COLOR_WHITE};border:1px solid {COLOR_BORDER};font-family:{FONT};"> <table role="presentation" width="680" cellpadding="0" cellspacing="0" border="0" style="width:680px;max-width:680px;background:{COLOR_WHITE};border:1px solid {COLOR_BORDER};font-family:{FONT};">
<tr> <tr>
<td style="height:5px;background:{COLOR_LINK};font-size:0;line-height:0;">&nbsp;</td> <td style="height:5px;background:{COLOR_TK_ORANGE};font-size:0;line-height:0;">&nbsp;</td>
</tr> </tr>
<tr> <tr>
<td style="background:{COLOR_HEADING};padding:30px 36px 28px;font-family:{FONT};"> <td style="background:{COLOR_TK_GRAY_DARK};padding:30px 36px 28px;font-family:{FONT};">
<p style="margin:0;font-family:{FONT};font-size:11px;line-height:16px;letter-spacing:1.2px;text-transform:uppercase;color:#A9C6E8;">Interner Newsletter</p> <p style="margin:0;font-family:{FONT};font-size:11px;line-height:16px;letter-spacing:1.2px;text-transform:uppercase;color:{COLOR_TK_ORANGE};">Interner Newsletter</p>
<h1 style="margin:10px 0 0;font-family:{FONT};font-size:28px;line-height:34px;font-weight:bold;color:{COLOR_WHITE};">Thomas-Krenn Wiki Update</h1> <h1 style="margin:10px 0 0;font-family:{FONT};font-size:28px;line-height:34px;font-weight:bold;color:{COLOR_WHITE};">Thomas-Krenn Wiki Update</h1>
<p style="margin:10px 0 0;font-family:{FONT};font-size:14px;line-height:21px;color:#D9E8F8;">{escape(ORG_NAME)}</p> <p style="margin:10px 0 0;font-family:{FONT};font-size:14px;line-height:21px;color:#CCCCCC;">{escape(ORG_NAME)}</p>
</td> </td>
</tr> </tr>
<tr> <tr>
<td style="padding:28px 36px 0;font-family:{FONT};"> <td style="padding:28px 36px 0;font-family:{FONT};">
<table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" style="background:{COLOR_BG};border-left:4px solid {COLOR_LINK};font-family:{FONT};"> <table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" style="background:{COLOR_TK_ORANGE_LIGHT};border-left:4px solid {COLOR_TK_ORANGE};font-family:{FONT};">
<tr> <tr>
<td style="padding:18px 20px;font-family:{FONT};font-size:15px;line-height:24px;color:{COLOR_TEXT};"> <td style="padding:18px 20px;font-family:{FONT};font-size:15px;line-height:24px;color:{COLOR_TEXT};">
<p style="margin:0 0 10px;font-family:{FONT};font-size:15px;line-height:24px;">Liebe Kolleginnen und Kollegen,</p> <p style="margin:0 0 10px;font-family:{FONT};font-size:15px;line-height:24px;">Liebe Kolleginnen und Kollegen,</p>
@@ -237,7 +244,7 @@ def create_html(
{summary} {summary}
<table role="presentation" cellpadding="0" cellspacing="0" border="0" align="center" style="margin:32px auto 0;font-family:{FONT};"> <table role="presentation" cellpadding="0" cellspacing="0" border="0" align="center" style="margin:32px auto 0;font-family:{FONT};">
<tr> <tr>
<td align="center" style="background:{COLOR_HEADING};padding:14px 28px;font-family:{FONT};"> <td align="center" style="background:{COLOR_TK_ORANGE};padding:14px 28px;font-family:{FONT};">
<a href="{WIKI_HOME_URL}" style="font-family:{FONT};font-size:14px;line-height:20px;font-weight:bold;color:{COLOR_WHITE};text-decoration:none;">Zum Thomas-Krenn-Wiki &rarr;</a> <a href="{WIKI_HOME_URL}" style="font-family:{FONT};font-size:14px;line-height:20px;font-weight:bold;color:{COLOR_WHITE};text-decoration:none;">Zum Thomas-Krenn-Wiki &rarr;</a>
</td> </td>
</tr> </tr>
@@ -258,11 +265,67 @@ def create_html(
OUTLOOK_FONT = "Arial, sans-serif" OUTLOOK_FONT = "Arial, sans-serif"
OUTLOOK_TEXT = "#000000" OUTLOOK_TEXT = COLOR_TEXT
OUTLOOK_MUTED = "#666666" OUTLOOK_MUTED = COLOR_TK_GRAY
OUTLOOK_LINK = "#0563C1" OUTLOOK_LINK = COLOR_TK_ORANGE
OUTLOOK_HEADING = "#003366" OUTLOOK_HEADING = COLOR_TK_GRAY_DARK
OUTLOOK_BORDER = "#DDDDDD" OUTLOOK_BORDER = COLOR_BORDER
OUTLOOK_WHITE = COLOR_WHITE
OUTLOOK_ORANGE = COLOR_TK_ORANGE
OUTLOOK_GRAY_DARK = COLOR_TK_GRAY_DARK
def _outlook_td_attrs(
bg: str = OUTLOOK_WHITE,
*,
colspan: int | None = None,
width: str | None = None,
valign: str | None = None,
extra_style: str = "",
) -> str:
"""Tabellen-Zelle mit Outlook-Dunkelmodus-Schutz (data-ogsb/data-ogsc)."""
parts = [
f'bgcolor="{bg}"',
f'style="background-color:{bg} !important;color:{OUTLOOK_TEXT} !important;{extra_style}"',
f'data-ogsb="{bg}"',
]
if colspan:
parts.insert(0, f'colspan="{colspan}"')
if width:
parts.append(f'width="{width}"')
if valign:
parts.append(f'valign="{valign}"')
return " ".join(parts)
def _outlook_font(
text: str,
*,
color: str = OUTLOOK_TEXT,
size: str = "2",
bold: bool = False,
) -> str:
inner = escape(text)
if bold:
inner = f"<b>{inner}</b>"
return (
f'<span style="color:{color} !important;" data-ogsc="{color}">'
f'<font face="Arial" color="{color}" size="{size}">{inner}</font>'
f"</span>"
)
def _outlook_link(title: str, url: str, *, bold: bool = True) -> str:
weight = "<b>" if bold else ""
weight_end = "</b>" if bold else ""
return (
f'<a href="{escape(url)}" '
f'style="color:{OUTLOOK_LINK} !important;text-decoration:none !important;mso-style-priority:100 !important;">'
f'<span style="color:{OUTLOOK_LINK} !important;" data-ogsc="{OUTLOOK_LINK}">'
f'<font face="Arial" color="{OUTLOOK_LINK}" size="2">'
f"{weight}{escape(title)}{weight_end}"
f"</font></span></a>"
)
def create_outlook_html( def create_outlook_html(
@@ -271,44 +334,48 @@ def create_outlook_html(
display: DisplayOptions | None = None, display: DisplayOptions | None = None,
category: str = "", category: str = "",
) -> str: ) -> str:
"""Vereinfachtes HTML für Outlook/Word nur Tabellen und Inline-Styles.""" """Word/Outlook-kompatibles HTML mit font-Tags und bgcolor (überlebt Einfügen in Outlook)."""
display = display or DEFAULT_DISPLAY display = display or DEFAULT_DISPLAY
new_articles, edited_articles = split_articles_by_type(articles) new_articles, edited_articles = split_articles_by_type(articles)
period_start, period_end = _period_range(days) period_start, period_end = _period_range(days)
created_at = datetime.now().strftime("%d.%m.%Y %H:%M") created_at = datetime.now().strftime("%d.%m.%Y %H:%M")
intro = escape(_intro_sentence(period_start, period_end)) intro = _intro_sentence(period_start, period_end)
subject = escape(create_subject(days, category)) subject = escape(create_subject(days, category))
if not new_articles and not edited_articles: if not new_articles and not edited_articles:
body_rows = f"""<tr> body_rows = f"""<tr>
<td style="padding:12px 0;font-family:{OUTLOOK_FONT};font-size:11pt;color:{OUTLOOK_MUTED};"> <td {_outlook_td_attrs(colspan=2, extra_style="padding:12px 0;")}>
Im gewählten Zeitraum wurden keine passenden Wiki-Änderungen gefunden. {_outlook_font("Im gewählten Zeitraum wurden keine passenden Wiki-Änderungen gefunden.", color=OUTLOOK_MUTED)}
</td> </td>
</tr>""" </tr>"""
else: else:
body_rows = "\n".join( body_rows = "\n".join(
[ [
_outlook_section("Neue Artikel", new_articles, display, "Keine neuen Artikel im Zeitraum."), _outlook_section("Neue Artikel", new_articles, display, "Keine neuen Artikel im Zeitraum.", kind="new"),
_outlook_section( _outlook_section(
"Bearbeitete Artikel", "Bearbeitete Artikel",
edited_articles, edited_articles,
display, display,
"Keine bearbeiteten Artikel im Zeitraum.", "Keine bearbeiteten Artikel im Zeitraum.",
kind="edited",
), ),
] ]
) )
category_block = "" category_block = ""
if category.strip(): if category.strip():
category_block = f"""<p style="margin:0 0 8px;font-family:{OUTLOOK_FONT};font-size:10pt;color:{OUTLOOK_MUTED};"> category_block = (
<strong style="font-family:{OUTLOOK_FONT};color:{OUTLOOK_HEADING};">Filter:</strong> Kategorie {escape(category.strip())} f'<p style="margin:0 0 10px;">'
</p>""" f'{_outlook_font("Filter: ", color=OUTLOOK_HEADING, bold=True)}'
f'{_outlook_font(f"Kategorie {category.strip()}", color=OUTLOOK_MUTED, size="1")}'
f"</p>"
)
total = len(new_articles) + len(edited_articles) total = len(new_articles) + len(edited_articles)
summary_row = f"""<tr> summary_row = f"""<tr>
<td style="padding:16px 0 0;font-family:{OUTLOOK_FONT};font-size:10pt;color:{OUTLOOK_MUTED};border-top:1px solid {OUTLOOK_BORDER};"> <td {_outlook_td_attrs(colspan=2, extra_style=f"padding:16px 0 0;border-top:1px solid {OUTLOOK_BORDER};")}>
<strong style="font-family:{OUTLOOK_FONT};color:{OUTLOOK_HEADING};">Zusammenfassung:</strong> {_outlook_font("Zusammenfassung: ", color=OUTLOOK_HEADING, bold=True, size="1")}
{len(new_articles)} neu &middot; {len(edited_articles)} bearbeitet &middot; {total} gesamt {_outlook_font(f"{len(new_articles)} neu · {len(edited_articles)} bearbeitet · {total} gesamt", color=OUTLOOK_MUTED, size="1")}
</td> </td>
</tr>""" </tr>"""
@@ -318,48 +385,56 @@ def create_outlook_html(
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="ProgId" content="Word.Document"> <meta name="ProgId" content="Word.Document">
<meta name="Generator" content="Microsoft Word 15"> <meta name="Generator" content="Microsoft Word 15">
<meta name="color-scheme" content="light dark">
<meta name="supported-color-schemes" content="light dark">
<title>{subject}</title> <title>{subject}</title>
<!--[if gte mso 9]>
<xml>
<w:WordDocument>
<w:View>Print</w:View>
<w:Zoom>100</w:Zoom>
<w:DoNotOptimizeForBrowser/>
</w:WordDocument>
</xml>
<![endif]-->
<!--[if mso]> <!--[if mso]>
<style type="text/css"> <style type="text/css">
body, table, td, p, a, span, strong {{ font-family: Arial, sans-serif !important; }} body, table, td, p, font, span, strong {{ font-family: Arial, sans-serif !important; }}
a, span.MsoHyperlink, span.MsoHyperlinkFollowed {{
color: {OUTLOOK_LINK} !important;
text-decoration: none !important;
}}
</style> </style>
<![endif]--> <![endif]-->
<style type="text/css">
:root {{ color-scheme: light dark; supported-color-schemes: light dark; }}
body {{ background-color: {OUTLOOK_WHITE} !important; color: {OUTLOOK_TEXT} !important; }}
a, a:link, a:visited, a:hover, a:active {{
color: {OUTLOOK_LINK} !important;
text-decoration: none !important;
}}
</style>
</head> </head>
<body style="margin:0;padding:16px;font-family:{OUTLOOK_FONT};font-size:11pt;color:{OUTLOOK_TEXT};background:#FFFFFF;"> <body bgcolor="{OUTLOOK_WHITE}" style="margin:0;padding:16px;background-color:{OUTLOOK_WHITE} !important;color:{OUTLOOK_TEXT} !important;" data-ogsb="{OUTLOOK_WHITE}">
<table width="600" cellpadding="0" cellspacing="0" border="0" align="center" style="width:600px;font-family:{OUTLOOK_FONT};font-size:11pt;color:{OUTLOOK_TEXT};background:#FFFFFF;"> <table width="600" cellpadding="0" cellspacing="0" border="0" align="center" bgcolor="{OUTLOOK_WHITE}" style="width:600px;background-color:{OUTLOOK_WHITE} !important;" data-ogsb="{OUTLOOK_WHITE}">
<tr> <tr>
<td style="padding:16px 20px;background:{OUTLOOK_HEADING};font-family:{OUTLOOK_FONT};"> <td {_outlook_td_attrs(bg=OUTLOOK_ORANGE, extra_style="height:5px;font-size:0;line-height:0;")}>&nbsp;</td>
<p style="margin:0;font-family:{OUTLOOK_FONT};font-size:9pt;color:#A9C6E8;text-transform:uppercase;letter-spacing:1px;">Interner Newsletter</p> </tr>
<p style="margin:6px 0 0;font-family:{OUTLOOK_FONT};font-size:18pt;font-weight:bold;color:#FFFFFF;">Thomas-Krenn Wiki Update</p> <tr>
<p style="margin:4px 0 0;font-family:{OUTLOOK_FONT};font-size:11pt;color:#D9E8F8;">{escape(ORG_NAME)}</p> <td {_outlook_td_attrs(bg=OUTLOOK_GRAY_DARK, extra_style="padding:16px 20px;")}>
{_outlook_font("Interner Newsletter", color=OUTLOOK_ORANGE, size="1")}<br>
{_outlook_font("Thomas-Krenn Wiki Update", color=OUTLOOK_WHITE, size="5", bold=True)}<br>
{_outlook_font(ORG_NAME, color="#CCCCCC", size="2")}
</td> </td>
</tr> </tr>
<tr> <tr>
<td style="padding:20px;font-family:{OUTLOOK_FONT};font-size:11pt;color:{OUTLOOK_TEXT};"> <td {_outlook_td_attrs(extra_style="padding:20px;")}>
<p style="margin:0 0 8px;font-family:{OUTLOOK_FONT};font-size:11pt;color:{OUTLOOK_TEXT};">Liebe Kolleginnen und Kollegen,</p> <p style="margin:0 0 8px;">{_outlook_font("Liebe Kolleginnen und Kollegen,")}</p>
<p style="margin:0 0 12px;font-family:{OUTLOOK_FONT};font-size:11pt;color:{OUTLOOK_TEXT};">{intro}</p> <p style="margin:0 0 12px;">{_outlook_font(intro)}</p>
<p style="margin:0 0 16px;font-family:{OUTLOOK_FONT};font-size:9pt;color:{OUTLOOK_MUTED};">Erstellt am: {created_at}</p> <p style="margin:0 0 16px;">{_outlook_font(f"Erstellt am: {created_at}", color=OUTLOOK_MUTED, size="1")}</p>
{category_block} {category_block}
<table width="100%" cellpadding="0" cellspacing="0" border="0" style="font-family:{OUTLOOK_FONT};font-size:11pt;color:{OUTLOOK_TEXT};"> <table width="100%" cellpadding="0" cellspacing="0" border="0" bgcolor="{OUTLOOK_WHITE}" style="background-color:{OUTLOOK_WHITE} !important;" data-ogsb="{OUTLOOK_WHITE}">
{body_rows} {body_rows}
{summary_row} {summary_row}
<tr> <tr>
<td style="padding:20px 0 0;font-family:{OUTLOOK_FONT};font-size:11pt;"> <td {_outlook_td_attrs(colspan=2, extra_style="padding:20px 0 0;")}>
<a href="{WIKI_HOME_URL}" style="font-family:{OUTLOOK_FONT};font-size:11pt;font-weight:bold;color:{OUTLOOK_LINK};">Zum Thomas-Krenn-Wiki &rarr;</a> {_outlook_link("Zum Thomas-Krenn-Wiki ", WIKI_HOME_URL)}
</td> </td>
</tr> </tr>
<tr> <tr>
<td style="padding:16px 0 0;font-family:{OUTLOOK_FONT};font-size:9pt;color:{OUTLOOK_MUTED};border-top:1px solid {OUTLOOK_BORDER};"> <td {_outlook_td_attrs(colspan=2, extra_style=f"padding:16px 0 0;border-top:1px solid {OUTLOOK_BORDER};")}>
Automatisch erstellter interner Newsletter &middot; Nur für den Gebrauch bei {escape(ORG_NAME)} {_outlook_font(f"Automatisch erstellter interner Newsletter · Nur für den Gebrauch bei {ORG_NAME}", color=OUTLOOK_MUTED, size="1")}
</td> </td>
</tr> </tr>
</table> </table>
@@ -385,20 +460,19 @@ def _outlook_meta_line(item: dict[str, Any], display: DisplayOptions) -> str:
def _outlook_article_rows(items: list[dict[str, Any]], display: DisplayOptions) -> str: def _outlook_article_rows(items: list[dict[str, Any]], display: DisplayOptions) -> str:
rows: list[str] = [] rows: list[str] = []
for idx, item in enumerate(items, 1): for idx, item in enumerate(items, 1):
title = escape(item.get("title", "Ohne Titel")) title = item.get("title", "Ohne Titel")
url = escape(_article_url(item.get("title", ""))) url = _article_url(item.get("title", ""))
meta = _outlook_meta_line(item, display) meta = _outlook_meta_line(item, display)
meta_html = "" meta_html = ""
if meta: if meta:
meta_html = ( meta_html = f"<br>{_outlook_font(meta, color=OUTLOOK_MUTED, size='1')}"
f'<br><span style="font-family:{OUTLOOK_FONT};font-size:9pt;color:{OUTLOOK_MUTED};">'
f"{escape(meta)}</span>"
)
rows.append( rows.append(
f"""<tr> f"""<tr>
<td width="28" valign="top" style="padding:6px 8px 10px 0;border-bottom:1px solid {OUTLOOK_BORDER};font-family:{OUTLOOK_FONT};font-size:11pt;color:{OUTLOOK_TEXT};">{idx}.</td> <td {_outlook_td_attrs(width="28", valign="top", extra_style=f"padding:8px 8px 10px 0;border-bottom:1px solid {OUTLOOK_BORDER};")}>
<td valign="top" style="padding:6px 0 10px;border-bottom:1px solid {OUTLOOK_BORDER};font-family:{OUTLOOK_FONT};font-size:11pt;color:{OUTLOOK_TEXT};"> {_outlook_font(f"{idx}.")}
<a href="{url}" style="font-family:{OUTLOOK_FONT};font-size:11pt;color:{OUTLOOK_LINK};">{title}</a>{meta_html} </td>
<td {_outlook_td_attrs(valign="top", extra_style=f"padding:8px 0 10px;border-bottom:1px solid {OUTLOOK_BORDER};")}>
{_outlook_link(title, url)}{meta_html}
</td> </td>
</tr>""" </tr>"""
) )
@@ -410,15 +484,19 @@ def _outlook_section(
items: list[dict[str, Any]], items: list[dict[str, Any]],
display: DisplayOptions, display: DisplayOptions,
empty_text: str, empty_text: str,
kind: str = "edited",
) -> str: ) -> str:
accent = OUTLOOK_ORANGE if kind == "new" else OUTLOOK_GRAY_DARK
header = f"""<tr> header = f"""<tr>
<td colspan="2" style="padding:18px 0 6px;font-family:{OUTLOOK_FONT};font-size:13pt;font-weight:bold;color:{OUTLOOK_HEADING};border-bottom:2px solid {OUTLOOK_HEADING};"> <td {_outlook_td_attrs(colspan=2, extra_style=f"padding:18px 0 8px;border-bottom:2px solid {accent};")}>
{escape(heading)} ({len(items)}) {_outlook_font(f"{heading} ({len(items)})", color=accent, size="3", bold=True)}
</td> </td>
</tr>""" </tr>"""
if not items: if not items:
return header + f"""<tr> return header + f"""<tr>
<td colspan="2" style="padding:8px 0;font-family:{OUTLOOK_FONT};font-size:11pt;color:{OUTLOOK_MUTED};font-style:italic;">{escape(empty_text)}</td> <td {_outlook_td_attrs(colspan=2, extra_style="padding:8px 0;")}>
{_outlook_font(empty_text, color=OUTLOOK_MUTED)}
</td>
</tr>""" </tr>"""
return header + _outlook_article_rows(items, display) return header + _outlook_article_rows(items, display)
@@ -573,7 +651,7 @@ def _html_item_row(idx: int, item: dict[str, Any], display: DisplayOptions, acce
<tr> <tr>
<td style="width:26px;vertical-align:top;font-family:{FONT};font-size:13px;line-height:20px;font-weight:bold;color:{accent};">{idx}.</td> <td style="width:26px;vertical-align:top;font-family:{FONT};font-size:13px;line-height:20px;font-weight:bold;color:{accent};">{idx}.</td>
<td style="vertical-align:top;font-family:{FONT};"> <td style="vertical-align:top;font-family:{FONT};">
<a href="{url}" style="font-family:{FONT};font-size:15px;line-height:22px;font-weight:bold;color:{COLOR_LINK};text-decoration:underline;">{title}</a> <a href="{url}" style="font-family:{FONT};font-size:15px;line-height:22px;font-weight:bold;color:{COLOR_LINK};text-decoration:none;">{title}</a>
{meta_html} {meta_html}
</td> </td>
</tr> </tr>

View File

@@ -1,26 +1,659 @@
:root {
--tk-orange: #ED6B06;
--tk-orange-dark: #C95605;
--tk-orange-light: #FFF4ED;
--tk-gray-dark: #4A4A4A;
--tk-gray: #6B6B6B;
--tk-gray-light: #F5F5F5;
--tk-border: #E0E0E0;
--tk-text: #1A1A1A;
--tk-white: #FFFFFF;
--tk-success: #027A48;
--tk-success-bg: #ECFDF3;
--tk-error: #B42318;
--tk-error-bg: #FEF3F2;
--tk-warning: #B54708;
--tk-warning-bg: #FFFAEB;
--shadow-sm: 0 1px 3px rgba(74, 74, 74, 0.08);
--shadow-md: 0 4px 16px rgba(74, 74, 74, 0.1);
--radius: 8px;
--radius-lg: 12px;
}
* { box-sizing: border-box; } * { box-sizing: border-box; }
body { margin: 0; font-family: Arial, sans-serif; background: #f5f7fb; color: #1f2430; }
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.5rem; background: #0c2c5a; color: #fff; } body {
.container { max-width: 1100px; margin: 1rem auto; padding: 0 1rem; } margin: 0;
.card { background: #fff; border: 1px solid #dde3ef; border-radius: 8px; padding: 1rem; margin-bottom: 1rem; } font-family: Arial, Helvetica, sans-serif;
.narrow { max-width: 420px; margin: 2rem auto; } background: var(--tk-gray-light);
.form-grid { display: grid; gap: 0.75rem; } color: var(--tk-text);
label { display: grid; gap: 0.3rem; font-weight: 600; } line-height: 1.5;
input, button, textarea { font: inherit; padding: 0.55rem; } min-height: 100vh;
}
a { color: var(--tk-orange); text-decoration: none; }
a:hover { color: var(--tk-orange-dark); text-decoration: underline; }
/* ── Header ── */
.topbar {
display: flex;
justify-content: space-between;
align-items: center;
gap: 1rem;
padding: 0.85rem 1.5rem;
background: var(--tk-gray-dark);
color: var(--tk-white);
border-bottom: 4px solid var(--tk-orange);
}
.topbar-brand {
display: flex;
align-items: center;
gap: 0.75rem;
min-width: 0;
}
.topbar-logo {
width: 36px;
height: 36px;
background: var(--tk-orange);
border-radius: 6px;
display: flex;
align-items: center;
justify-content: center;
font-weight: bold;
font-size: 1.1rem;
flex-shrink: 0;
}
.topbar h1 {
margin: 0;
font-size: 1.05rem;
font-weight: 700;
line-height: 1.2;
}
.topbar-sub {
margin: 0;
font-size: 0.78rem;
color: #BBBBBB;
font-weight: normal;
}
.topbar-actions {
display: flex;
align-items: center;
gap: 0.75rem;
flex-wrap: wrap;
}
.topbar-nav {
display: flex;
gap: 0.25rem;
}
.topbar-nav a {
color: #DDDDDD;
padding: 0.35rem 0.65rem;
border-radius: 4px;
font-size: 0.88rem;
text-decoration: none;
}
.topbar-nav a:hover,
.topbar-nav a.active {
background: rgba(255, 255, 255, 0.1);
color: var(--tk-white);
text-decoration: none;
}
.user-chip {
display: flex;
align-items: center;
gap: 0.5rem;
font-size: 0.85rem;
color: #CCCCCC;
}
.topbar .btn-logout {
background: transparent;
border: 1px solid rgba(255, 255, 255, 0.35);
color: var(--tk-white);
padding: 0.35rem 0.75rem;
font-size: 0.85rem;
}
.topbar .btn-logout:hover {
background: rgba(255, 255, 255, 0.1);
border-color: rgba(255, 255, 255, 0.5);
}
/* ── Layout ── */
.container {
max-width: 1140px;
margin: 0 auto;
padding: 1.5rem 1rem 2.5rem;
}
.page-header {
margin-bottom: 1.5rem;
}
.page-header h2 {
margin: 0 0 0.35rem;
font-size: 1.65rem;
color: var(--tk-gray-dark);
}
.page-lead {
margin: 0;
color: var(--tk-gray);
font-size: 0.95rem;
}
.stats-row {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
gap: 1rem;
margin-bottom: 1.5rem;
}
.stat-card {
background: var(--tk-white);
border: 1px solid var(--tk-border);
border-radius: var(--radius);
padding: 1rem 1.15rem;
box-shadow: var(--shadow-sm);
}
.stat-card.accent-new { border-left: 4px solid var(--tk-orange); }
.stat-card.accent-edit { border-left: 4px solid var(--tk-gray-dark); }
.stat-card.accent-total { border-left: 4px solid var(--tk-gray); }
.stat-value {
font-size: 2rem;
font-weight: 700;
line-height: 1.1;
color: var(--tk-gray-dark);
}
.stat-card.accent-new .stat-value { color: var(--tk-orange); }
.stat-label {
margin-top: 0.25rem;
font-size: 0.85rem;
color: var(--tk-gray);
}
.layout-2col {
display: grid;
grid-template-columns: 1fr 280px;
gap: 1rem;
align-items: start;
}
@media (max-width: 900px) {
.layout-2col { grid-template-columns: 1fr; }
.topbar { flex-wrap: wrap; }
}
/* ── Cards ── */
.card {
background: var(--tk-white);
border: 1px solid var(--tk-border);
border-radius: var(--radius-lg);
padding: 1.25rem 1.35rem;
margin-bottom: 1rem;
box-shadow: var(--shadow-sm);
}
.card-header {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 1rem;
margin-bottom: 1rem;
padding-bottom: 0.85rem;
border-bottom: 1px solid var(--tk-border);
}
.card-header h2,
.card-header h3,
.card > h2,
.card > h3 {
margin: 0;
color: var(--tk-gray-dark);
font-size: 1.1rem;
}
.card > h2 { font-size: 1.2rem; margin-bottom: 1rem; }
.card-desc {
margin: 0.35rem 0 0;
font-size: 0.88rem;
color: var(--tk-gray);
font-weight: normal;
}
.card-accent-orange { border-top: 3px solid var(--tk-orange); }
.card-accent-gray { border-top: 3px solid var(--tk-gray-dark); }
.sidebar-card {
background: var(--tk-orange-light);
border: 1px solid #F5D5BC;
border-radius: var(--radius);
padding: 1rem;
margin-bottom: 0.75rem;
font-size: 0.88rem;
}
.sidebar-card h4 {
margin: 0 0 0.5rem;
font-size: 0.9rem;
color: var(--tk-gray-dark);
}
.sidebar-card ul {
margin: 0;
padding-left: 1.1rem;
color: var(--tk-gray);
}
.sidebar-card li { margin-bottom: 0.3rem; }
.narrow { max-width: 420px; margin: 3rem auto; }
/* ── Forms ── */
.form-grid { display: grid; gap: 0.85rem; }
.form-row {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 0.85rem;
}
@media (max-width: 600px) {
.form-row { grid-template-columns: 1fr; }
}
label {
display: grid;
gap: 0.35rem;
font-weight: 600;
font-size: 0.88rem;
color: var(--tk-gray-dark);
}
input, select, textarea, button {
font: inherit;
}
input, select, textarea {
padding: 0.6rem 0.75rem;
border: 1px solid var(--tk-border);
border-radius: 6px;
background: var(--tk-white);
color: var(--tk-text);
transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
outline: none;
border-color: var(--tk-orange);
box-shadow: 0 0 0 3px rgba(237, 107, 6, 0.15);
}
textarea { width: 100%; resize: vertical; } textarea { width: 100%; resize: vertical; }
button { width: fit-content; background: #1b5dbf; color: #fff; border: 0; border-radius: 4px; cursor: pointer; }
.btn-secondary { background: #334155; } .checkbox {
.copy-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; margin-bottom: 0.75rem; } display: flex;
.copy-status { font-size: 0.92rem; color: #64748b; } align-items: center;
.copy-status.success { color: #027a48; } gap: 0.5rem;
.copy-status.error { color: #b42318; } font-weight: 500;
.newsletter-preview-frame { width: 100%; min-height: 720px; border: 1px solid #D7DEE8; border-radius: 6px; background: #EEF2F7; box-shadow: 0 2px 8px rgba(0, 51, 102, 0.08); } cursor: pointer;
.card h3 { color: #003366; margin-top: 0; } }
.checkbox input[type="checkbox"] {
width: 1rem;
height: 1rem;
accent-color: var(--tk-orange);
cursor: pointer;
}
.display-options {
border: 1px solid var(--tk-border);
border-radius: var(--radius);
padding: 0.85rem 1rem;
display: grid;
gap: 0.5rem;
background: var(--tk-gray-light);
}
.display-options legend {
font-weight: 600;
padding: 0 0.35rem;
color: var(--tk-gray-dark);
font-size: 0.88rem;
}
/* ── Buttons ── */
button {
width: fit-content;
background: var(--tk-orange);
color: var(--tk-white);
border: 0;
border-radius: 6px;
cursor: pointer;
padding: 0.6rem 1.1rem;
font-weight: 600;
font-size: 0.9rem;
transition: background 0.15s, transform 0.1s;
}
button:hover { background: var(--tk-orange-dark); }
button:active { transform: scale(0.98); }
.btn-primary {
background: var(--tk-orange);
padding: 0.7rem 1.4rem;
font-size: 0.95rem;
}
.btn-block { width: 100%; }
.btn-secondary {
background: var(--tk-gray-dark);
}
.btn-secondary:hover { background: #3A3A3A; }
.btn-outline {
background: transparent;
border: 1px solid var(--tk-border);
color: var(--tk-gray-dark);
}
.btn-outline:hover {
background: var(--tk-gray-light);
border-color: var(--tk-gray);
}
.btn-group {
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
align-items: center;
}
/* ── Badges ── */
.badge {
display: inline-block;
padding: 0.2rem 0.55rem;
border-radius: 999px;
font-size: 0.75rem;
font-weight: 600;
text-transform: uppercase;
letter-spacing: 0.03em;
}
.badge-admin { background: var(--tk-orange-light); color: var(--tk-orange-dark); }
.badge-editor { background: #EEEEEE; color: var(--tk-gray-dark); }
.badge-reader { background: var(--tk-gray-light); color: var(--tk-gray); }
.badge-sent { background: var(--tk-success-bg); color: var(--tk-success); }
.badge-failed { background: var(--tk-error-bg); color: var(--tk-error); }
.badge-skipped { background: var(--tk-warning-bg); color: var(--tk-warning); }
.count-badge {
display: inline-flex;
align-items: center;
justify-content: center;
min-width: 1.6rem;
padding: 0.15rem 0.5rem;
background: var(--tk-gray-light);
border: 1px solid var(--tk-border);
border-radius: 999px;
font-size: 0.82rem;
font-weight: 600;
color: var(--tk-gray-dark);
}
.count-badge.orange {
background: var(--tk-orange-light);
border-color: #F5D5BC;
color: var(--tk-orange-dark);
}
/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table {
width: 100%;
border-collapse: collapse;
font-size: 0.9rem;
}
th {
background: var(--tk-gray-light);
color: var(--tk-gray-dark);
font-weight: 600;
font-size: 0.82rem;
text-transform: uppercase;
letter-spacing: 0.04em;
padding: 0.65rem 0.75rem;
text-align: left;
border-bottom: 2px solid var(--tk-border);
}
td {
padding: 0.65rem 0.75rem;
border-bottom: 1px solid var(--tk-border);
vertical-align: top;
}
tbody tr:hover { background: #FAFAFA; }
.empty-row td {
color: var(--tk-gray);
font-style: italic;
text-align: center;
padding: 1.5rem;
}
/* ── Preview & Copy ── */
.copy-actions {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 0.5rem;
margin-bottom: 1rem;
padding: 0.85rem;
background: var(--tk-gray-light);
border-radius: var(--radius);
border: 1px solid var(--tk-border);
}
.copy-status {
font-size: 0.88rem;
color: var(--tk-gray);
flex: 1 1 100%;
margin-top: 0.25rem;
}
@media (min-width: 700px) {
.copy-status { flex: 1 1 auto; margin-top: 0; margin-left: 0.5rem; }
}
.copy-status.success { color: var(--tk-success); }
.copy-status.error { color: var(--tk-error); }
.newsletter-preview-frame {
width: 100%;
min-height: 640px;
border: 1px solid var(--tk-border);
border-radius: var(--radius);
background: var(--tk-gray-light);
box-shadow: var(--shadow-md);
}
.textarea-actions {
display: flex;
gap: 0.5rem;
flex-wrap: wrap;
margin-bottom: 0.75rem;
}
.readonly-output {
font-family: Consolas, "Courier New", monospace;
font-size: 0.82rem;
line-height: 1.45;
background: var(--tk-gray-light);
}
.hidden-source { display: none; } .hidden-source { display: none; }
table { width: 100%; border-collapse: collapse; }
th, td { border-bottom: 1px solid #e6ebf4; text-align: left; padding: 0.55rem; vertical-align: top; } /* ── Collapsible ── */
.checkbox { display: flex; align-items: center; gap: 0.45rem; font-weight: 500; } details.card-details {
.display-options { border: 1px solid #dde3ef; border-radius: 6px; padding: 0.75rem; display: grid; gap: 0.45rem; } background: var(--tk-white);
.display-options legend { font-weight: 600; padding: 0 0.25rem; } border: 1px solid var(--tk-border);
.error { color: #b42318; background: #fef3f2; border: 1px solid #fecdca; padding: 0.6rem; border-radius: 4px; margin: 0 0 0.75rem; } border-radius: var(--radius-lg);
.hint { color: #64748b; font-size: 0.92rem; margin: 0 0 0.6rem; } margin-bottom: 1rem;
box-shadow: var(--shadow-sm);
}
details.card-details > summary {
padding: 1rem 1.35rem;
cursor: pointer;
font-weight: 600;
color: var(--tk-gray-dark);
list-style: none;
display: flex;
align-items: center;
justify-content: space-between;
user-select: none;
}
details.card-details > summary::-webkit-details-marker { display: none; }
details.card-details > summary::after {
content: "▸";
color: var(--tk-gray);
transition: transform 0.2s;
}
details.card-details[open] > summary::after {
transform: rotate(90deg);
}
details.card-details > summary:hover { background: var(--tk-gray-light); }
details.card-details .details-body {
padding: 0 1.35rem 1.25rem;
border-top: 1px solid var(--tk-border);
}
/* ── Alerts ── */
.error, .alert-error {
color: var(--tk-error);
background: var(--tk-error-bg);
border: 1px solid #FECDCA;
padding: 0.75rem 1rem;
border-radius: var(--radius);
margin: 0 0 0.85rem;
font-size: 0.9rem;
}
.hint {
color: var(--tk-gray);
font-size: 0.88rem;
margin: 0 0 0.75rem;
line-height: 1.5;
}
/* ── Login ── */
body.login-page {
display: flex;
flex-direction: column;
min-height: 100vh;
}
body.login-page .topbar { flex-shrink: 0; }
body.login-page .container {
flex: 1;
display: flex;
align-items: center;
justify-content: center;
padding: 2rem 1rem;
}
.login-card {
width: 100%;
max-width: 400px;
border-top: 4px solid var(--tk-orange);
}
.login-card h2 {
margin: 0 0 0.35rem;
color: var(--tk-gray-dark);
}
.login-subtitle {
margin: 0 0 1.25rem;
color: var(--tk-gray);
font-size: 0.9rem;
}
/* ── Copy dialog ── */
.copy-dialog-overlay {
position: fixed;
inset: 0;
z-index: 1000;
background: rgba(26, 26, 26, 0.55);
display: flex;
align-items: center;
justify-content: center;
padding: 1rem;
}
.copy-dialog {
width: min(900px, 100%);
max-height: 90vh;
background: var(--tk-white);
border-radius: var(--radius-lg);
padding: 1.25rem 1.5rem;
box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2);
border-top: 4px solid var(--tk-orange);
display: grid;
gap: 0.85rem;
}
.copy-dialog h4 { margin: 0; color: var(--tk-gray-dark); }
.copy-dialog-hint { margin: 0; color: var(--tk-gray); }
.copy-dialog-textarea {
width: 100%;
min-height: 320px;
font-family: Consolas, "Courier New", monospace;
font-size: 0.85rem;
line-height: 1.4;
border: 1px solid var(--tk-border);
border-radius: 6px;
padding: 0.75rem;
resize: vertical;
}
.copy-dialog-actions {
display: flex;
gap: 0.5rem;
flex-wrap: wrap;
}
/* ── Footer ── */
.site-footer {
text-align: center;
padding: 1rem;
font-size: 0.8rem;
color: var(--tk-gray);
border-top: 1px solid var(--tk-border);
background: var(--tk-white);
}

View File

@@ -8,8 +8,7 @@ function setCopyStatus(message, isError) {
function getNewsletterHtml() { function getNewsletterHtml() {
const htmlSource = document.getElementById("newsletter-html-source"); const htmlSource = document.getElementById("newsletter-html-source");
const htmlDisplay = document.getElementById("newsletter-html-display"); const htmlDisplay = document.getElementById("newsletter-html-display");
const value = htmlSource?.value.trim() || htmlDisplay?.value.trim() || ""; return htmlSource?.value.trim() || htmlDisplay?.value.trim() || "";
return value;
} }
function getNewsletterOutlookHtml() { function getNewsletterOutlookHtml() {
@@ -24,6 +23,10 @@ function getNewsletterPlain() {
return plainSource ? plainSource.value : ""; return plainSource ? plainSource.value : "";
} }
function byteLength(text) {
return new TextEncoder().encode(text).length;
}
function wrapCfHtml(html) { function wrapCfHtml(html) {
const fragmentStart = "<!--StartFragment-->"; const fragmentStart = "<!--StartFragment-->";
const fragmentEnd = "<!--EndFragment-->"; const fragmentEnd = "<!--EndFragment-->";
@@ -32,15 +35,20 @@ function wrapCfHtml(html) {
const documentHtml = `<html><body>${fragmentStart}${inner}${fragmentEnd}</body></html>`; const documentHtml = `<html><body>${fragmentStart}${inner}${fragmentEnd}</body></html>`;
const pad = (value) => String(value).padStart(10, "0"); const pad = (value) => String(value).padStart(10, "0");
const headerPlaceholder = "StartHTML:0000000000\r\nEndHTML:0000000000\r\nStartFragment:0000000000\r\nEndFragment:0000000000\r\n"; const headerTemplate =
const prefix = `Version:0.9\r\n${headerPlaceholder}`; "Version:0.9\r\n" +
const startHtml = prefix.length; "StartHTML:0000000000\r\n" +
const endHtml = startHtml + documentHtml.length; "EndHTML:0000000000\r\n" +
const startFragment = startHtml + documentHtml.indexOf(fragmentStart) + fragmentStart.length; "StartFragment:0000000000\r\n" +
const endFragment = startHtml + documentHtml.indexOf(fragmentEnd); "EndFragment:0000000000\r\n";
const startHtml = byteLength(headerTemplate);
const endHtml = startHtml + byteLength(documentHtml);
const startFragment = startHtml + byteLength(documentHtml.slice(0, documentHtml.indexOf(fragmentStart) + fragmentStart.length));
const endFragment = startHtml + byteLength(documentHtml.slice(0, documentHtml.indexOf(fragmentEnd)));
return ( return (
`Version:0.9\r\n` + "Version:0.9\r\n" +
`StartHTML:${pad(startHtml)}\r\n` + `StartHTML:${pad(startHtml)}\r\n` +
`EndHTML:${pad(endHtml)}\r\n` + `EndHTML:${pad(endHtml)}\r\n` +
`StartFragment:${pad(startFragment)}\r\n` + `StartFragment:${pad(startFragment)}\r\n` +
@@ -49,26 +57,33 @@ function wrapCfHtml(html) {
); );
} }
function copyFromTextarea(textarea) { function selectTextarea(textarea) {
if (!textarea || !textarea.value) return false; if (!textarea || !textarea.value) return false;
textarea.scrollIntoView({ behavior: "smooth", block: "center" });
const previousActive = document.activeElement;
textarea.removeAttribute("readonly");
textarea.focus({ preventScroll: true }); textarea.focus({ preventScroll: true });
textarea.select(); textarea.select();
textarea.setSelectionRange(0, textarea.value.length); textarea.setSelectionRange(0, textarea.value.length);
return true;
}
function copyFromTextarea(textarea) {
if (!textarea || !textarea.value) return false;
const wasReadonly = textarea.hasAttribute("readonly");
if (wasReadonly) textarea.removeAttribute("readonly");
selectTextarea(textarea);
let ok = false; let ok = false;
try { try {
ok = document.execCommand("copy"); ok = document.execCommand("copy");
} catch (err) { } catch (err) {
console.warn("execCommand copy from textarea failed.", err); console.warn("execCommand copy from textarea failed.", err);
ok = false; }
} finally {
textarea.setAttribute("readonly", ""); if (wasReadonly) textarea.setAttribute("readonly", "");
if (previousActive && typeof previousActive.focus === "function") { if (!ok) {
previousActive.focus({ preventScroll: true }); selectTextarea(textarea);
}
} }
return ok; return ok;
} }
@@ -92,47 +107,118 @@ function copyTextWithFallback(text) {
const textarea = document.createElement("textarea"); const textarea = document.createElement("textarea");
textarea.value = text; textarea.value = text;
textarea.setAttribute("aria-hidden", "true"); textarea.setAttribute("aria-hidden", "true");
textarea.style.position = "fixed"; textarea.style.cssText = "position:fixed;top:0;left:0;width:2px;height:2px;opacity:0;border:none;padding:0;";
textarea.style.top = "0";
textarea.style.left = "0";
textarea.style.width = "2px";
textarea.style.height = "2px";
textarea.style.padding = "0";
textarea.style.border = "none";
textarea.style.outline = "none";
textarea.style.boxShadow = "none";
textarea.style.background = "transparent";
document.body.appendChild(textarea); document.body.appendChild(textarea);
let ok = false; let ok = false;
try { try {
textarea.focus({ preventScroll: true }); selectTextarea(textarea);
textarea.select();
textarea.setSelectionRange(0, text.length);
ok = document.execCommand("copy"); ok = document.execCommand("copy");
} catch (err) { } catch (err) {
console.warn("execCommand copy from temporary textarea failed.", err); console.warn("execCommand copy from temporary textarea failed.", err);
ok = false;
} finally { } finally {
document.body.removeChild(textarea); document.body.removeChild(textarea);
} }
return ok; return ok;
} }
let copyDialogKeyHandler = null;
function closeCopyDialog() {
const overlay = document.getElementById("copy-dialog-overlay");
if (overlay) overlay.remove();
if (copyDialogKeyHandler) {
document.removeEventListener("keydown", copyDialogKeyHandler);
copyDialogKeyHandler = null;
}
}
function showCopyDialog(text, title) {
closeCopyDialog();
const overlay = document.createElement("div");
overlay.id = "copy-dialog-overlay";
overlay.className = "copy-dialog-overlay";
overlay.innerHTML = `
<div class="copy-dialog" role="dialog" aria-modal="true" aria-labelledby="copy-dialog-title">
<h4 id="copy-dialog-title">${title}</h4>
<p class="copy-dialog-hint">Der Text ist markiert. Jetzt <strong>Strg+C</strong> drücken (Mac: <strong>Cmd+C</strong>).</p>
<textarea class="copy-dialog-textarea" spellcheck="false"></textarea>
<div class="copy-dialog-actions">
<button type="button" class="btn-secondary" id="copy-dialog-select-btn">Alles markieren</button>
<button type="button" class="btn-secondary" id="copy-dialog-close-btn">Schließen</button>
</div>
</div>
`;
document.body.appendChild(overlay);
const textarea = overlay.querySelector(".copy-dialog-textarea");
textarea.value = text;
selectTextarea(textarea);
let copied = false;
try {
copied = document.execCommand("copy");
} catch (err) {
console.warn("execCommand copy in dialog failed.", err);
}
if (copied) {
setCopyStatus("HTML-Quelltext kopiert.");
} else {
setCopyStatus("Bitte im Fenster Strg+C drücken.", true);
}
overlay.querySelector("#copy-dialog-close-btn").addEventListener("click", closeCopyDialog);
overlay.querySelector("#copy-dialog-select-btn").addEventListener("click", () => selectTextarea(textarea));
overlay.addEventListener("click", (event) => {
if (event.target === overlay) closeCopyDialog();
});
copyDialogKeyHandler = (event) => {
if (event.key === "Escape") closeCopyDialog();
};
document.addEventListener("keydown", copyDialogKeyHandler);
}
function copyViaIframe(html) {
const iframe = document.createElement("iframe");
iframe.setAttribute("aria-hidden", "true");
iframe.style.cssText = "position:fixed;width:700px;height:500px;left:-9999px;top:0;border:none;";
document.body.appendChild(iframe);
const doc = iframe.contentWindow.document;
doc.open();
doc.write(html);
doc.close();
const range = doc.createRange();
range.selectNodeContents(doc.body);
const selection = iframe.contentWindow.getSelection();
selection.removeAllRanges();
selection.addRange(range);
let ok = false;
try {
ok = doc.execCommand("copy");
} catch (err) {
console.warn("execCommand copy via iframe failed.", err);
} finally {
selection.removeAllRanges();
document.body.removeChild(iframe);
}
return ok;
}
function copyHtmlWithFallback(html) { function copyHtmlWithFallback(html) {
if (copyViaIframe(html)) return true;
const container = document.createElement("div"); const container = document.createElement("div");
container.innerHTML = html; container.innerHTML = html;
container.contentEditable = "true"; container.contentEditable = "true";
container.setAttribute("aria-hidden", "true"); container.setAttribute("aria-hidden", "true");
container.style.position = "fixed"; container.style.cssText =
container.style.left = "0"; "position:fixed;left:0;top:0;width:700px;max-height:1px;overflow:hidden;opacity:0;pointer-events:none;background:#FFFFFF;";
container.style.top = "0";
container.style.width = "600px";
container.style.height = "1px";
container.style.overflow = "hidden";
container.style.opacity = "0";
container.style.pointerEvents = "none";
container.style.background = "#FFFFFF";
document.body.appendChild(container); document.body.appendChild(container);
const range = document.createRange(); const range = document.createRange();
@@ -146,36 +232,13 @@ function copyHtmlWithFallback(html) {
ok = document.execCommand("copy"); ok = document.execCommand("copy");
} catch (err) { } catch (err) {
console.warn("execCommand HTML copy failed.", err); console.warn("execCommand HTML copy failed.", err);
ok = false;
} finally { } finally {
selection.removeAllRanges(); selection.removeAllRanges();
document.body.removeChild(container); document.body.removeChild(container);
} }
if (!ok) {
ok = copyTextWithFallback(wrapCfHtml(html));
}
return ok; return ok;
} }
async function copyText(text) {
if (!text) return false;
if (copyTextWithFallback(text)) {
return true;
}
if (navigator.clipboard && window.isSecureContext) {
try {
await navigator.clipboard.writeText(text);
return true;
} catch (err) {
console.warn("Clipboard API text copy failed.", err);
}
}
return false;
}
async function copyForOutlook() { async function copyForOutlook() {
const html = getNewsletterOutlookHtml(); const html = getNewsletterOutlookHtml();
const plain = getNewsletterPlain(); const plain = getNewsletterPlain();
@@ -185,7 +248,7 @@ async function copyForOutlook() {
} }
if (copyHtmlWithFallback(html)) { if (copyHtmlWithFallback(html)) {
setCopyStatus("Newsletter für Outlook kopiert. Mit Strg+V einfügen (ggf. „Format beibehalten“)."); setCopyStatus("Newsletter kopiert. In Outlook: Strg+V, dann ggf. Rechtsklick → „Format beibehalten“.");
return; return;
} }
@@ -198,55 +261,24 @@ async function copyForOutlook() {
"text/plain": new Blob([plain], { type: "text/plain" }), "text/plain": new Blob([plain], { type: "text/plain" }),
}), }),
]); ]);
setCopyStatus("Newsletter für Outlook kopiert. Mit Strg+V einfügen (ggf. „Format beibehalten“)."); setCopyStatus("Newsletter kopiert. In Outlook: Strg+V, dann ggf. Rechtsklick → „Format beibehalten“.");
return; return;
} catch (err) { } catch (err) {
console.warn("Clipboard API HTML copy failed.", err); console.warn("Clipboard API HTML copy failed.", err);
} }
} }
setCopyStatus("Kopieren fehlgeschlagen. Bitte „HTML herunterladen“ verwenden.", true); setCopyStatus("Bitte „Im Browser öffnen“ nutzen und dort Strg+A → Strg+C.", true);
} }
async function copyHtmlSource() { function copyHtmlSource() {
const html = getNewsletterHtml(); const html = getNewsletterHtml();
if (!html) { if (!html) {
setCopyStatus("Bitte zuerst einen Newsletter generieren.", true); setCopyStatus("Bitte zuerst einen Newsletter generieren.", true);
return; return;
} }
const displayArea = document.getElementById("newsletter-html-display"); showCopyDialog(html, "HTML-Quelltext kopieren");
const sourceArea = document.getElementById("newsletter-html-source");
const textarea = displayArea?.value ? displayArea : sourceArea;
if (textarea && copyFromTextarea(textarea)) {
setCopyStatus("HTML-Quelltext kopiert.");
return;
}
if (copyTextWithFallback(html)) {
setCopyStatus("HTML-Quelltext kopiert.");
return;
}
if (navigator.clipboard && window.isSecureContext) {
try {
await navigator.clipboard.writeText(html);
setCopyStatus("HTML-Quelltext kopiert.");
return;
} catch (err) {
console.warn("Clipboard API HTML source copy failed.", err);
}
}
if (textarea) {
textarea.focus({ preventScroll: true });
textarea.select();
}
setCopyStatus(
"Automatisches Kopieren nicht möglich. HTML-Feld unten ist markiert bitte Strg+C drücken.",
true
);
} }
function downloadHtml() { function downloadHtml() {
@@ -256,9 +288,23 @@ function downloadHtml() {
return; return;
} }
const stamp = new Date().toISOString().slice(0, 10); downloadFile(html, `wiki-newsletter-${new Date().toISOString().slice(0, 10)}.html`, "text/html;charset=utf-8");
const filename = `wiki-newsletter-${stamp}.html`; setCopyStatus("Outlook-HTML heruntergeladen.");
const blob = new Blob([html], { type: "text/html;charset=utf-8" }); }
function downloadHtmlSource() {
const html = getNewsletterHtml();
if (!html) {
setCopyStatus("Bitte zuerst einen Newsletter generieren.", true);
return;
}
downloadFile(html, `wiki-newsletter-source-${new Date().toISOString().slice(0, 10)}.html`, "text/html;charset=utf-8");
setCopyStatus("HTML-Quelltext heruntergeladen.");
}
function downloadFile(content, filename, mimeType) {
const blob = new Blob([content], { type: mimeType });
const url = URL.createObjectURL(blob); const url = URL.createObjectURL(blob);
const link = document.createElement("a"); const link = document.createElement("a");
link.href = url; link.href = url;
@@ -267,7 +313,26 @@ function downloadHtml() {
link.click(); link.click();
document.body.removeChild(link); document.body.removeChild(link);
URL.revokeObjectURL(url); URL.revokeObjectURL(url);
setCopyStatus(`HTML gespeichert als ${filename}. Datei in Outlook öffnen oder Inhalt kopieren.`); }
function openOutlookInBrowser() {
const html = getNewsletterOutlookHtml();
if (!html) {
setCopyStatus("Bitte zuerst einen Newsletter generieren.", true);
return;
}
const popup = window.open("", "_blank");
if (!popup) {
setCopyStatus("Pop-up blockiert. Bitte Pop-ups erlauben oder „HTML herunterladen“ nutzen.", true);
return;
}
popup.document.open();
popup.document.write(html);
popup.document.close();
popup.document.title = "Wiki-Newsletter zum Kopieren";
setCopyStatus("Newsletter im Browser geöffnet: Strg+A → Strg+C, dann in Outlook einfügen.");
} }
document.addEventListener("DOMContentLoaded", () => { document.addEventListener("DOMContentLoaded", () => {
@@ -279,7 +344,14 @@ document.addEventListener("DOMContentLoaded", () => {
frame.srcdoc = previewHtml; frame.srcdoc = previewHtml;
} }
const htmlDisplay = document.getElementById("newsletter-html-display");
htmlDisplay?.addEventListener("focus", () => selectTextarea(htmlDisplay));
htmlDisplay?.addEventListener("click", () => selectTextarea(htmlDisplay));
document.getElementById("copy-outlook-btn")?.addEventListener("click", copyForOutlook); document.getElementById("copy-outlook-btn")?.addEventListener("click", copyForOutlook);
document.getElementById("open-outlook-btn")?.addEventListener("click", openOutlookInBrowser);
document.getElementById("copy-html-source-btn")?.addEventListener("click", copyHtmlSource); document.getElementById("copy-html-source-btn")?.addEventListener("click", copyHtmlSource);
document.getElementById("copy-html-source-btn-2")?.addEventListener("click", copyHtmlSource);
document.getElementById("download-html-btn")?.addEventListener("click", downloadHtml); document.getElementById("download-html-btn")?.addEventListener("click", downloadHtml);
document.getElementById("download-html-source-btn")?.addEventListener("click", downloadHtmlSource);
}); });

View File

@@ -3,22 +3,43 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{ title if title else "TK Wiki Newsletter Admin" }}</title> <title>{% block title %}{{ title if title else "Wiki Newsletter Admin" }}{% endblock %} · Thomas-Krenn.AG</title>
<link rel="stylesheet" href="/static/css/main.css"> <link rel="stylesheet" href="/static/css/main.css?v=3">
</head> </head>
<body> <body class="{% block body_class %}{% endblock %}">
<header class="topbar"> <header class="topbar">
<h1>TK Wiki Newsletter Admin</h1> <div class="topbar-brand">
<div class="topbar-logo" aria-hidden="true">TK</div>
<div>
<h1>Wiki Newsletter Admin</h1>
<p class="topbar-sub">Thomas-Krenn.AG · Intern</p>
</div>
</div>
{% if user %} {% if user %}
<form method="post" action="/logout"> <div class="topbar-actions">
<input type="hidden" name="csrf_token" value="{{ csrf_token }}"> <nav class="topbar-nav" aria-label="Hauptnavigation">
<button type="submit">Logout</button> <a href="/dashboard" class="{% if active_nav == 'dashboard' %}active{% endif %}">Dashboard</a>
</form> {% if user.role == "admin" %}
<a href="/admin/users" class="{% if active_nav == 'users' %}active{% endif %}">Benutzer</a>
{% endif %}
</nav>
<div class="user-chip">
<span>{{ user.full_name }}</span>
<span class="badge badge-{{ user.role }}">{{ user.role }}</span>
</div>
<form method="post" action="/logout">
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
<button type="submit" class="btn-logout">Abmelden</button>
</form>
</div>
{% endif %} {% endif %}
</header> </header>
<main class="container"> <main class="container">
{% block content %}{% endblock %} {% block content %}{% endblock %}
</main> </main>
<footer class="site-footer">
Thomas-Krenn.AG · Interner Wiki-Newsletter · Nur für den internen Gebrauch
</footer>
{% block scripts %}{% endblock %} {% block scripts %}{% endblock %}
</body> </body>
</html> </html>

View File

@@ -1,199 +1,301 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block title %}Dashboard{% endblock %}
{% block content %} {% block content %}
<section class="card">
<h2>Newsletter erstellen</h2>
<form method="post" action="/dashboard" class="form-grid">
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
<label>Zeitraum (Tage)
<input type="number" name="days" min="1" max="90" value="{{ filters.days }}">
</label>
<label>Kategorie (optional)
<input type="text" name="category" value="{{ filters.category }}">
</label>
<label class="checkbox">
<input type="checkbox" name="only_edited" value="true" {% if filters.only_edited %}checked{% endif %}>
Nur bearbeitete Artikel (keine neu erstellten)
</label>
<fieldset class="display-options">
<legend>Anzeige im Output</legend>
<label class="checkbox">
<input type="checkbox" name="show_date" value="true" {% if filters.display.show_date %}checked{% endif %}>
Datum anzeigen
</label>
<label class="checkbox">
<input type="checkbox" name="show_user" value="true" {% if filters.display.show_user %}checked{% endif %}>
Benutzer anzeigen
</label>
<label class="checkbox">
<input type="checkbox" name="show_category" value="true" {% if filters.display.show_category %}checked{% endif %}>
Kategorie anzeigen
</label>
</fieldset>
{% if user.role in ["admin", "editor"] %}
<button type="submit">Newsletter generieren</button>
{% endif %}
</form>
{% if user.role == "admin" %}
<p><a href="/admin/users">Zur Benutzerverwaltung</a></p>
{% endif %}
{% if wiki_error %}
<p class="error">{{ wiki_error }}</p>
{% endif %}
</section>
{% if user.role in ["admin", "editor"] %} <div class="page-header">
<section class="card"> <h2>Wiki Newsletter</h2>
<h3>Optionaler SMTP-Versand</h3> <p class="page-lead">Wiki-Änderungen filtern, Newsletter generieren und für Outlook aufbereiten.</p>
<form method="post" action="/newsletter/send-now" class="form-grid"> </div>
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
<input type="hidden" name="days" value="{{ filters.days }}">
<input type="hidden" name="category" value="{{ filters.category }}">
<input type="hidden" name="only_edited" value="{{ 'true' if filters.only_edited else 'false' }}">
<input type="hidden" name="show_date" value="{{ 'true' if filters.display.show_date else 'false' }}">
<input type="hidden" name="show_user" value="{{ 'true' if filters.display.show_user else 'false' }}">
<input type="hidden" name="show_category" value="{{ 'true' if filters.display.show_category else 'false' }}">
<button type="submit">Newsletter jetzt senden</button>
</form>
</section>
{% endif %}
{% if user.role == "admin" %} <div class="stats-row">
<section class="card"> <div class="stat-card accent-new">
<h3>SMTP-Konfiguration (optional)</h3> <div class="stat-value">{{ articles_new|length }}</div>
<form method="post" action="/admin/smtp" class="form-grid"> <div class="stat-label">Neue Artikel</div>
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
<label class="checkbox">
<input type="checkbox" name="enabled" value="true" {% if smtp.enabled == "true" %}checked{% endif %}>
SMTP Versand aktivieren
</label>
<label>SMTP Host
<input type="text" name="host" value="{{ smtp.host }}">
</label>
<label>SMTP Port
<input type="number" name="port" value="{{ smtp.port }}">
</label>
<label>Benutzername
<input type="text" name="username" value="{{ smtp.username }}">
</label>
<label>Passwort
<input type="password" name="password" value="{{ smtp.password }}">
</label>
<label>Absender E-Mail
<input type="email" name="from_email" value="{{ smtp.from_email }}">
</label>
<label class="checkbox">
<input type="checkbox" name="use_tls" value="true" {% if smtp.use_tls == "true" %}checked{% endif %}>
STARTTLS verwenden
</label>
<label>Verteilerliste (Komma-separiert)
<textarea rows="3" name="recipients">{{ smtp.recipients }}</textarea>
</label>
<label>Geplanter täglicher Versand (HH:MM)
<input type="time" name="schedule_time" value="{{ smtp.schedule_time }}">
</label>
<button type="submit">SMTP Einstellungen speichern</button>
</form>
</section>
{% endif %}
<section class="card">
<h3>Newsletter-Vorschau (mit Hyperlinks)</h3>
<p class="hint">Für Outlook „Für Outlook kopieren“ nutzen und mit <strong>Strg+V</strong> einfügen (Rechtsklick → „Format beibehalten“). Falls Kopieren nicht klappt (z. B. per HTTP/IP), „HTML herunterladen“ verwenden und die Datei in Outlook öffnen.</p>
<div class="copy-actions">
<button type="button" id="copy-outlook-btn" class="btn-secondary">Für Outlook kopieren</button>
<button type="button" id="copy-html-source-btn" class="btn-secondary">HTML-Quelltext kopieren</button>
<button type="button" id="download-html-btn" class="btn-secondary">HTML herunterladen</button>
<span id="copy-status" class="copy-status" aria-live="polite"></span>
</div> </div>
<iframe id="newsletter-preview-frame" class="newsletter-preview-frame" title="Newsletter Vorschau"></iframe> <div class="stat-card accent-edit">
<textarea id="newsletter-html-source" class="hidden-source" hidden readonly>{{ raw_html }}</textarea> <div class="stat-value">{{ articles_edited|length }}</div>
<textarea id="newsletter-outlook-source" class="hidden-source" hidden readonly>{{ outlook_html }}</textarea> <div class="stat-label">Bearbeitete Artikel</div>
<textarea id="newsletter-plain-source" class="hidden-source" hidden readonly>{{ plain_text }}</textarea> </div>
</section> <div class="stat-card accent-total">
<div class="stat-value">{{ articles_new|length + articles_edited|length }}</div>
<div class="stat-label">Gesamt</div>
</div>
</div>
<section class="card"> <div class="layout-2col">
<h3>Output: Nur-Text (Fallback)</h3> <div class="main-col">
<p class="hint">Enthält URLs als Text. Für klickbare Links bitte die Vorschau bzw. „Für Outlook kopieren“ verwenden.</p>
<textarea rows="16" readonly>{{ plain_text }}</textarea>
</section>
<section class="card"> <section class="card card-accent-orange">
<h3>Output: HTML-Quelltext</h3> <div class="card-header">
<p class="hint">Bei Problemen mit „Kopieren“: Textfeld markieren (Strg+A) und manuell kopieren (Strg+C).</p> <div>
<textarea id="newsletter-html-display" rows="12" readonly>{{ raw_html }}</textarea> <h3>Newsletter erstellen</h3>
</section> <p class="card-desc">Zeitraum und Filter wählen, dann generieren.</p>
</div>
</div>
<form method="post" action="/dashboard" class="form-grid">
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
<div class="form-row">
<label>Zeitraum (Tage)
<input type="number" name="days" min="1" max="90" value="{{ filters.days }}">
</label>
<label>Kategorie (optional)
<input type="text" name="category" value="{{ filters.category }}" placeholder="z. B. Linux">
</label>
</div>
<label class="checkbox">
<input type="checkbox" name="only_edited" value="true" {% if filters.only_edited %}checked{% endif %}>
Nur bearbeitete Artikel (keine neu erstellten)
</label>
<fieldset class="display-options">
<legend>Anzeige im Newsletter</legend>
<label class="checkbox">
<input type="checkbox" name="show_date" value="true" {% if filters.display.show_date %}checked{% endif %}>
Datum anzeigen
</label>
<label class="checkbox">
<input type="checkbox" name="show_user" value="true" {% if filters.display.show_user %}checked{% endif %}>
Benutzer anzeigen
</label>
<label class="checkbox">
<input type="checkbox" name="show_category" value="true" {% if filters.display.show_category %}checked{% endif %}>
Kategorie anzeigen
</label>
</fieldset>
{% if wiki_error %}
<p class="error">{{ wiki_error }}</p>
{% endif %}
{% if user.role in ["admin", "editor"] %}
<button type="submit" class="btn-primary">Newsletter generieren</button>
{% else %}
<p class="hint">Sie haben Leserechte. Bitte einen Editor oder Admin bitten, den Newsletter zu generieren.</p>
{% endif %}
</form>
</section>
<section class="card"> <section class="card card-accent-orange">
<h3>Neue Artikel ({{ articles_new|length }})</h3> <div class="card-header">
<table> <div>
<thead> <h3>Vorschau &amp; Export</h3>
<tr> <p class="card-desc">Formatierten Newsletter ansehen und für Outlook kopieren.</p>
<th>Titel</th> </div>
{% if filters.display.show_date %}<th>Zeit</th>{% endif %} </div>
{% if filters.display.show_user %}<th>Benutzer</th>{% endif %} <p class="hint"><strong>Empfohlen:</strong> „Im Browser öffnen“ → <strong>Strg+A</strong>, <strong>Strg+C</strong> → in Outlook <strong>Strg+V</strong>.</p>
{% if filters.display.show_category %}<th>Kategorien</th>{% endif %} <div class="copy-actions">
</tr> <button type="button" id="open-outlook-btn" class="btn-primary">Im Browser öffnen</button>
</thead> <button type="button" id="copy-outlook-btn" class="btn-secondary">Für Outlook kopieren</button>
<tbody> <button type="button" id="download-html-btn" class="btn-secondary">HTML herunterladen</button>
{% for item in articles_new %} <button type="button" id="copy-html-source-btn" class="btn-outline">HTML-Quelltext</button>
<tr> <span id="copy-status" class="copy-status" aria-live="polite"></span>
<td><a href="{{ wiki_article_url(item.title) }}" target="_blank" rel="noopener">{{ item.title }}</a></td> </div>
{% if filters.display.show_date %}<td>{{ item.timestamp }}</td>{% endif %} <iframe id="newsletter-preview-frame" class="newsletter-preview-frame" title="Newsletter Vorschau"></iframe>
{% if filters.display.show_user %}<td>{{ item.user }}</td>{% endif %} <textarea id="newsletter-html-source" class="hidden-source" hidden readonly>{{ raw_html }}</textarea>
{% if filters.display.show_category %}<td>{{ item.categories|join(", ") }}</td>{% endif %} <textarea id="newsletter-outlook-source" class="hidden-source" hidden readonly>{{ outlook_html }}</textarea>
</tr> <textarea id="newsletter-plain-source" class="hidden-source" hidden readonly>{{ plain_text }}</textarea>
{% else %} </section>
<tr><td colspan="4">Keine neuen Artikel im gewählten Zeitraum.</td></tr>
{% endfor %}
</tbody>
</table>
</section>
<section class="card"> <section class="card card-accent-gray">
<h3>Bearbeitete Artikel ({{ articles_edited|length }})</h3> <div class="card-header">
<table> <h3>Neue Artikel <span class="count-badge orange">{{ articles_new|length }}</span></h3>
<thead> </div>
<tr> <div class="table-wrap">
<th>Titel</th> <table>
{% if filters.display.show_date %}<th>Zeit</th>{% endif %} <thead>
{% if filters.display.show_user %}<th>Benutzer</th>{% endif %} <tr>
{% if filters.display.show_category %}<th>Kategorien</th>{% endif %} <th>Titel</th>
</tr> {% if filters.display.show_date %}<th>Zeit</th>{% endif %}
</thead> {% if filters.display.show_user %}<th>Benutzer</th>{% endif %}
<tbody> {% if filters.display.show_category %}<th>Kategorien</th>{% endif %}
{% for item in articles_edited %} </tr>
<tr> </thead>
<td><a href="{{ wiki_article_url(item.title) }}" target="_blank" rel="noopener">{{ item.title }}</a></td> <tbody>
{% if filters.display.show_date %}<td>{{ item.timestamp }}</td>{% endif %} {% for item in articles_new %}
{% if filters.display.show_user %}<td>{{ item.user }}</td>{% endif %} <tr>
{% if filters.display.show_category %}<td>{{ item.categories|join(", ") }}</td>{% endif %} <td><a href="{{ wiki_article_url(item.title) }}" target="_blank" rel="noopener">{{ item.title }}</a></td>
</tr> {% if filters.display.show_date %}<td>{{ item.timestamp }}</td>{% endif %}
{% else %} {% if filters.display.show_user %}<td>{{ item.user }}</td>{% endif %}
<tr><td colspan="4">Keine bearbeiteten Artikel im gewählten Zeitraum.</td></tr> {% if filters.display.show_category %}<td>{{ item.categories|join(", ") }}</td>{% endif %}
{% endfor %} </tr>
</tbody> {% else %}
</table> <tr class="empty-row"><td colspan="4">Keine neuen Artikel im gewählten Zeitraum.</td></tr>
</section> {% endfor %}
</tbody>
</table>
</div>
</section>
<section class="card card-accent-gray">
<div class="card-header">
<h3>Bearbeitete Artikel <span class="count-badge">{{ articles_edited|length }}</span></h3>
</div>
<div class="table-wrap">
<table>
<thead>
<tr>
<th>Titel</th>
{% if filters.display.show_date %}<th>Zeit</th>{% endif %}
{% if filters.display.show_user %}<th>Benutzer</th>{% endif %}
{% if filters.display.show_category %}<th>Kategorien</th>{% endif %}
</tr>
</thead>
<tbody>
{% for item in articles_edited %}
<tr>
<td><a href="{{ wiki_article_url(item.title) }}" target="_blank" rel="noopener">{{ item.title }}</a></td>
{% if filters.display.show_date %}<td>{{ item.timestamp }}</td>{% endif %}
{% if filters.display.show_user %}<td>{{ item.user }}</td>{% endif %}
{% if filters.display.show_category %}<td>{{ item.categories|join(", ") }}</td>{% endif %}
</tr>
{% else %}
<tr class="empty-row"><td colspan="4">Keine bearbeiteten Artikel im gewählten Zeitraum.</td></tr>
{% endfor %}
</tbody>
</table>
</div>
</section>
<details class="card-details">
<summary>Weitere Ausgabeformate</summary>
<div class="details-body">
<h4 style="margin:1rem 0 0.5rem;font-size:0.95rem;">Nur-Text (Fallback)</h4>
<p class="hint">URLs als Klartext für klickbare Links die Vorschau nutzen.</p>
<textarea class="readonly-output" rows="10" readonly>{{ plain_text }}</textarea>
<h4 style="margin:1.25rem 0 0.5rem;font-size:0.95rem;">HTML-Quelltext</h4>
<p class="hint">Öffnet ein Fenster mit markiertem Text dort <strong>Strg+C</strong> drücken.</p>
<div class="textarea-actions">
<button type="button" id="copy-html-source-btn-2" class="btn-secondary">HTML-Quelltext kopieren</button>
<button type="button" id="download-html-source-btn" class="btn-outline">Herunterladen</button>
</div>
<textarea id="newsletter-html-display" class="readonly-output" rows="8" readonly>{{ raw_html }}</textarea>
</div>
</details>
{% if user.role in ["admin", "editor"] %}
<details class="card-details">
<summary>SMTP-Versand</summary>
<div class="details-body">
<p class="hint">Newsletter direkt per E-Mail versenden (aktuell gewählte Filter).</p>
<form method="post" action="/newsletter/send-now">
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
<input type="hidden" name="days" value="{{ filters.days }}">
<input type="hidden" name="category" value="{{ filters.category }}">
<input type="hidden" name="only_edited" value="{{ 'true' if filters.only_edited else 'false' }}">
<input type="hidden" name="show_date" value="{{ 'true' if filters.display.show_date else 'false' }}">
<input type="hidden" name="show_user" value="{{ 'true' if filters.display.show_user else 'false' }}">
<input type="hidden" name="show_category" value="{{ 'true' if filters.display.show_category else 'false' }}">
<button type="submit" class="btn-secondary">Newsletter jetzt senden</button>
</form>
</div>
</details>
{% endif %}
{% if user.role == "admin" %}
<details class="card-details">
<summary>SMTP-Konfiguration</summary>
<div class="details-body">
<form method="post" action="/admin/smtp" class="form-grid">
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
<label class="checkbox">
<input type="checkbox" name="enabled" value="true" {% if smtp.enabled == "true" %}checked{% endif %}>
SMTP-Versand aktivieren
</label>
<div class="form-row">
<label>SMTP-Host
<input type="text" name="host" value="{{ smtp.host }}" placeholder="mail.example.com">
</label>
<label>SMTP-Port
<input type="number" name="port" value="{{ smtp.port }}">
</label>
</div>
<div class="form-row">
<label>Benutzername
<input type="text" name="username" value="{{ smtp.username }}">
</label>
<label>Passwort
<input type="password" name="password" value="{{ smtp.password }}">
</label>
</div>
<label>Absender E-Mail
<input type="email" name="from_email" value="{{ smtp.from_email }}">
</label>
<label class="checkbox">
<input type="checkbox" name="use_tls" value="true" {% if smtp.use_tls == "true" %}checked{% endif %}>
STARTTLS verwenden
</label>
<label>Verteilerliste (kommagetrennt)
<textarea rows="3" name="recipients" placeholder="kollege@firma.de, team@firma.de">{{ smtp.recipients }}</textarea>
</label>
<label>Geplanter täglicher Versand (HH:MM)
<input type="time" name="schedule_time" value="{{ smtp.schedule_time }}">
</label>
<button type="submit">Einstellungen speichern</button>
</form>
</div>
</details>
{% endif %}
<section class="card">
<div class="card-header">
<h3>Versandprotokoll</h3>
<span class="hint" style="margin:0;">Letzte 20 Einträge</span>
</div>
<div class="table-wrap">
<table>
<thead>
<tr><th>Zeit</th><th>Status</th><th>Betreff</th><th>Empfänger</th><th>Details</th></tr>
</thead>
<tbody>
{% for log in send_logs %}
<tr>
<td>{{ log.created_at }}</td>
<td><span class="badge badge-{{ log.status }}">{{ log.status }}</span></td>
<td>{{ log.subject }}</td>
<td>{{ log.recipients }}</td>
<td>{{ log.detail }}</td>
</tr>
{% else %}
<tr class="empty-row"><td colspan="5">Noch keine Versände protokolliert.</td></tr>
{% endfor %}
</tbody>
</table>
</div>
</section>
</div>
<aside class="sidebar-col">
<div class="sidebar-card">
<h4>Workflow</h4>
<ol style="margin:0;padding-left:1.1rem;color:var(--tk-gray);">
<li>Filter setzen</li>
<li>Newsletter generieren</li>
<li>Vorschau prüfen</li>
<li>Für Outlook exportieren</li>
</ol>
</div>
<div class="sidebar-card">
<h4>Outlook-Tipp</h4>
<ul>
<li>„Im Browser öffnen“ nutzen</li>
<li>Alles markieren (Strg+A)</li>
<li>Kopieren (Strg+C)</li>
<li>In Outlook einfügen</li>
</ul>
</div>
{% if user.role == "admin" %}
<div class="sidebar-card">
<h4>Administration</h4>
<ul>
<li><a href="/admin/users">Benutzerverwaltung</a></li>
<li>SMTP unter „SMTP-Konfiguration“</li>
</ul>
</div>
{% endif %}
</aside>
</div>
<section class="card">
<h3>Versandprotokoll (letzte 20)</h3>
<table>
<thead><tr><th>Zeit</th><th>Status</th><th>Betreff</th><th>Empfänger</th><th>Details</th></tr></thead>
<tbody>
{% for log in send_logs %}
<tr>
<td>{{ log.created_at }}</td>
<td>{{ log.status }}</td>
<td>{{ log.subject }}</td>
<td>{{ log.recipients }}</td>
<td>{{ log.detail }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</section>
{% endblock %} {% endblock %}
{% block scripts %} {% block scripts %}
<script src="/static/js/newsletter.js"></script> <script src="/static/js/newsletter.js?v=6"></script>
{% endblock %} {% endblock %}

View File

@@ -1,19 +1,22 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block title %}Anmelden{% endblock %}
{% block body_class %}login-page{% endblock %}
{% block content %} {% block content %}
<section class="card narrow"> <section class="card login-card">
<h2>Login</h2> <h2>Anmelden</h2>
<p class="login-subtitle">Thomas-Krenn Wiki Newsletter Admin</p>
{% if error_message %} {% if error_message %}
<p class="error">{{ error_message }}</p> <p class="error">{{ error_message }}</p>
{% endif %} {% endif %}
<form method="post" action="/login" class="form-grid"> <form method="post" action="/login" class="form-grid">
<input type="hidden" name="csrf_token" value="{{ csrf_token }}"> <input type="hidden" name="csrf_token" value="{{ csrf_token }}">
<label>E-Mail <label>E-Mail
<input type="email" name="email" required> <input type="email" name="email" required autocomplete="username" placeholder="name@firma.de">
</label> </label>
<label>Passwort <label>Passwort
<input type="password" name="password" required> <input type="password" name="password" required autocomplete="current-password">
</label> </label>
<button type="submit">Anmelden</button> <button type="submit" class="btn-primary btn-block">Anmelden</button>
</form> </form>
</section> </section>
{% endblock %} {% endblock %}

View File

@@ -1,43 +1,78 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block title %}Benutzerverwaltung{% endblock %}
{% block content %} {% block content %}
<section class="card">
<h2>Benutzerverwaltung</h2>
<form method="post" action="/admin/users" class="form-grid">
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
<label>E-Mail
<input type="email" name="email" required>
</label>
<label>Vollständiger Name
<input type="text" name="full_name" required>
</label>
<label>Passwort
<input type="password" name="password" required minlength="10">
</label>
<label>Rolle
<select name="role">
<option value="reader">Reader</option>
<option value="editor">Editor</option>
<option value="admin">Admin</option>
</select>
</label>
<button type="submit">Benutzer erstellen</button>
</form>
</section>
<section class="card"> <div class="page-header">
<h3>Bestehende Benutzer</h3> <h2>Benutzerverwaltung</h2>
<table> <p class="page-lead"><a href="/dashboard">← Zurück zum Dashboard</a></p>
<thead><tr><th>E-Mail</th><th>Name</th><th>Rolle</th><th>Aktiv</th></tr></thead> </div>
<tbody>
{% for u in users %} <div class="layout-2col">
<tr> <div class="main-col">
<td>{{ u.email }}</td> <section class="card card-accent-orange">
<td>{{ u.full_name }}</td> <div class="card-header">
<td>{{ u.role }}</td> <h3>Neuen Benutzer anlegen</h3>
<td>{{ "Ja" if u.is_active else "Nein" }}</td> </div>
</tr> <form method="post" action="/admin/users" class="form-grid">
{% endfor %} <input type="hidden" name="csrf_token" value="{{ csrf_token }}">
</tbody> <div class="form-row">
</table> <label>E-Mail
</section> <input type="email" name="email" required placeholder="name@firma.de">
</label>
<label>Vollständiger Name
<input type="text" name="full_name" required>
</label>
</div>
<div class="form-row">
<label>Passwort
<input type="password" name="password" required minlength="10">
</label>
<label>Rolle
<select name="role">
<option value="reader">Leser (nur ansehen)</option>
<option value="editor">Editor (generieren &amp; senden)</option>
<option value="admin">Admin (voller Zugriff)</option>
</select>
</label>
</div>
<button type="submit" class="btn-primary">Benutzer erstellen</button>
</form>
</section>
<section class="card">
<div class="card-header">
<h3>Bestehende Benutzer <span class="count-badge">{{ users|length }}</span></h3>
</div>
<div class="table-wrap">
<table>
<thead>
<tr><th>E-Mail</th><th>Name</th><th>Rolle</th><th>Status</th></tr>
</thead>
<tbody>
{% for u in users %}
<tr>
<td>{{ u.email }}</td>
<td>{{ u.full_name }}</td>
<td><span class="badge badge-{{ u.role }}">{{ u.role }}</span></td>
<td>{{ "Aktiv" if u.is_active else "Inaktiv" }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</section>
</div>
<aside class="sidebar-col">
<div class="sidebar-card">
<h4>Rollen</h4>
<ul>
<li><strong>Leser</strong> Newsletter ansehen</li>
<li><strong>Editor</strong> Generieren &amp; senden</li>
<li><strong>Admin</strong> Benutzer &amp; SMTP</li>
</ul>
</div>
</aside>
</div>
{% endblock %} {% endblock %}