Add news ticker at the bottom of the client

Central feed (/api/store/news on the store server: manual items via
STORE_ADMIN_TOKEN, plus the latest release and newest store design for
30 days) and a per-gateway /api/news with NEWS_TICKER, NEWS_TICKER_CENTRAL
and NEWS_TICKER_MESSAGES so self-hosters can turn it off or add their own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hu2cuPLqpuKVfd9wWFFakU
This commit is contained in:
MoepchiandClaude Opus 5.5 committed 2026-10-22 18:38:00 +00:00
1 parent aa324274a4
commit 632e77ccc8
12 files changed
+359

No files matched your search

+64
View File
@@ -2605,6 +2605,70 @@
font-size: 11px;
}
.ts-news-ticker {
flex-shrink: 0;
display: flex;
align-items: center;
gap: 0.5rem;
border-top: 1px solid var(--border-soft);
background: var(--log-bg);
color: var(--log-text);
padding: 0.15rem 0.6rem;
font-size: 11px;
}
.ts-news-label {
font-weight: 600;
flex-shrink: 0;
}
.ts-news-track {
flex: 1;
overflow: hidden;
white-space: nowrap;
}
.ts-news-scroll {
display: inline-block;
animation: ts-news-scroll linear infinite;
}
.ts-news-ticker:hover .ts-news-scroll {
animation-play-state: paused;
}
.ts-news-item {
padding-right: 3rem;
}
.ts-news-item a {
color: inherit;
}
.ts-news-close {
flex-shrink: 0;
background: none;
border: none;
color: inherit;
cursor: pointer;
padding: 0 0.2rem;
}
@keyframes ts-news-scroll {
from {
transform: translateX(0);
}
to {
transform: translateX(-50%);
}
}
@media (prefers-reduced-motion: reduce) {
.ts-news-scroll {
animation: none;
}
}
.ts-log-info {
color: var(--log-text);
}
+104
View File
@@ -188,6 +188,14 @@ const FEEDBACK_URL = import.meta.env.DEV
? `${import.meta.env.VITE_GATEWAY_URL.replace(/\/$/, "").replace(/^ws(s?):\/\//, "http$1://")}/api/feedback`
: `${window.location.protocol}//${window.location.host}/api/feedback`;
// News ticker: the instance's own gateway says whether it's on and adds its
// own messages (gateway/src/news.ts); the central feed is fetched directly,
// like the store. The demo has no gateway and only shows the central feed.
const NEWS_CONFIG_URL = DEMO_MODE ? null : FEEDBACK_URL.replace(/\/api\/feedback$/, "/api/news");
const NEWS_FEED_URL = import.meta.env.DEV
? "http://localhost:8080/api/store/news"
: import.meta.env.VITE_NEWS_URL || "https://gateway.webspeak3.de/api/store/news";
// Unlike GATEWAY_URL/FEEDBACK_URL above, the design store is NOT per-instance:
// it's a single, centrally curated catalog run on the maintainer's own VPS
// (see gateway/src/store.ts), so every build - official and self-hosted
@@ -2580,6 +2588,101 @@ function FeedbackFab({ onOpen, stacked }: { onOpen: () => void; stacked: boolean
}
/** Small donation pill, pinned to the bottom right corner. */
type NewsItem =
| { id: string; kind: "text"; text: string; url?: string }
| { id: string; kind: "release"; version: string; url: string }
| { id: string; kind: "theme"; name: string; author: string };
const NEWS_DISMISSED_STORAGE_KEY = "webspeak3.newsTicker.dismissed";
// Like the scrolling news line at the bottom of the native TS3 client.
// Dismissing hides the current set of items until a new one shows up.
function NewsTicker() {
const t = useT();
const [items, setItems] = useState<NewsItem[]>([]);
const [dismissed, setDismissed] = useState(() => {
try {
return localStorage.getItem(NEWS_DISMISSED_STORAGE_KEY) ?? "";
} catch {
return "";
}
});
useEffect(() => {
const getJson = async (url: string) => {
const res = await fetch(url);
if (!res.ok) throw new Error(String(res.status));
return res.json();
};
const load = async () => {
// A gateway older than the ticker answers 404: treat it as the default.
const config = (NEWS_CONFIG_URL ? await getJson(NEWS_CONFIG_URL).catch(() => null) : null) ?? {
enabled: true,
central: true,
items: [],
};
if (!config.enabled) return setItems([]);
const central = config.central ? ((await getJson(NEWS_FEED_URL).catch(() => null))?.items ?? []) : [];
setItems([...config.items, ...central]);
};
void load();
const timer = window.setInterval(() => void load(), 15 * 60 * 1000);
return () => window.clearInterval(timer);
}, []);
const key = items.map((i) => i.id).join(",");
if (!items.length || key === dismissed) return null;
const label = (item: NewsItem) =>
item.kind === "release"
? t("news.release", { version: item.version })
: item.kind === "theme"
? t("news.theme", { name: item.name, author: item.author })
: item.text;
const entries = items.map((item) => {
const url = item.kind === "theme" ? undefined : item.url;
return (
<span key={item.id} className="ts-news-item">
{url ? (
<a href={url} target="_blank" rel="noopener noreferrer">
{label(item)}
</a>
) : (
label(item)
)}
</span>
);
});
return (
<div className="ts-news-ticker">
<span className="ts-news-label">{t("news.label")}</span>
<div className="ts-news-track">
{/* Rendered twice so the -50% scroll loops seamlessly. */}
<div className="ts-news-scroll" style={{ animationDuration: `${Math.max(20, items.length * 12)}s` }}>
{entries}
<span aria-hidden="true">{entries}</span>
</div>
</div>
<button
className="ts-news-close"
title={t("dialog.close")}
aria-label={t("dialog.close")}
onClick={() => {
setDismissed(key);
try {
localStorage.setItem(NEWS_DISMISSED_STORAGE_KEY, key);
} catch {
// ignore
}
}}
>
✕
</button>
</div>
);
}
function DonateFab() {
const t = useT();
if (!DONATE_URL) return null;
@@ -12323,6 +12426,7 @@ function AppInner() {
);
})}
</div>
<NewsTicker />
</div>
);
}
+3
View File
@@ -42,6 +42,9 @@
"donate.title": "Podpořit WebSpeak3 na Ko-fi",
"pwa.updateAvailable": "Je k dispozici nová verze",
"pwa.reload": "Načíst znovu",
"news.label": "Novinky",
"news.release": "Vyšel WebSpeak3 {version}",
"news.theme": "Nový vzhled v obchodě: „{name}“ od {author}",
"feedback.dialog.title": "Zpětná vazba",
"feedback.dialog.intro": "Report bug or share idea to help improve WebSpeak3.",
"feedback.dialog.category": "Kategorie",
+3
View File
@@ -42,6 +42,9 @@
"donate.title": "WebSpeak3 auf Ko-fi unterstützen",
"pwa.updateAvailable": "Neue Version verfügbar",
"pwa.reload": "Neu laden",
"news.label": "News",
"news.release": "WebSpeak3 {version} ist erschienen",
"news.theme": "Neues Design im Store: „{name}“ von {author}",
"feedback.dialog.title": "Feedback",
"feedback.dialog.intro": "Melde einen Fehler oder teile eine Idee zur Weiterentwicklung von WebSpeak3 mit.",
"feedback.dialog.category": "Kategorie",
+3
View File
@@ -42,6 +42,9 @@
"donate.title": "Support WebSpeak3 on Ko-fi",
"pwa.updateAvailable": "New version available",
"pwa.reload": "Reload",
"news.label": "News",
"news.release": "WebSpeak3 {version} is out",
"news.theme": "New design in the store: \"{name}\" by {author}",
"feedback.dialog.title": "Feedback",
"feedback.dialog.intro": "Report a bug or share an idea to help improve WebSpeak3.",
"feedback.dialog.category": "Category",
+3
View File
@@ -42,6 +42,9 @@
"donate.title": "حمایت از WebSpeak3 در Ko-fi",
"pwa.updateAvailable": "نسخه جدید موجود است",
"pwa.reload": "بارگذاری مجدد",
"news.label": "اخبار",
"news.release": "WebSpeak3 {version} منتشر شد",
"news.theme": "طرح جدید در فروشگاه: «{name}» از {author}",
"feedback.dialog.title": "بازخورد",
"feedback.dialog.intro": "یک اشکال گزارش بده یا ایده‌ای برای بهبود WebSpeak3 به اشتراک بگذار.",
"feedback.dialog.category": "دسته",
+3
View File
@@ -540,6 +540,9 @@
"donate.title": "在 Ko-fi 上支持 WebSpeak3",
"pwa.updateAvailable": "有新版本可用",
"pwa.reload": "重新加载",
"news.label": "新闻",
"news.release": "WebSpeak3 {version} 已发布",
"news.theme": "商店新设计:“{name}”,作者 {author}",
"feedback.dialog.title": "反馈",
"feedback.dialog.intro": "报告一个问题,或分享改进 WebSpeak3 的想法。",
"feedback.dialog.category": "类别",