Weekly horoscope landing page, link previews for the forum, and fixes from the review
CI / test (push) Successful in 3m19s
CI / build (push) Skipped
CI / deploy (push) Skipped

- /heti-horoszkop for visitors: what it is, a real example written for the
  example chart, login and sign-up buttons; its own link preview image.
- Forum: link previews (image, title; a public thread's opening words) for
  every forum page; none of a members-only thread's content.
- Review fixes: a removed thread's photos are no longer served; public photos
  are cached for an hour, not a year (removals take effect); photos of threads
  removed a year ago are cleaned up; deleting one forum question no longer
  revokes the chart link another question still shows; the daily digest
  leaves out closed topics the member is no longer in; typing notices at most
  one a second per connection; the weekly page asks for the text once and
  then only reads it (no repeated paid runs after a failure); turning the
  Monday e-mail back on from the e-mail page waits for next Monday, like the
  site's switch; the week's last day is right in the week the clocks go back.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
feco
2026-11-27 10:12:27 +00:00
co-authored by Claude Opus 5.5
parent 0358e137f1
commit b37094e481
24 changed files with 461 additions and 90 deletions
+18 -2
View File
@@ -6,14 +6,30 @@ import { notFound } from "next/navigation";
import { ForumNav } from "@/components/forum/ForumNav";
import { ThemeToggle } from "@/components/forum/ThemeToggle";
import { PublicHeader } from "@/components/SiteHeader";
import { FORUM_THEME_COOKIE, type ForumNavData, type ForumTheme } from "@/lib/forum";
import { FORUM_PREVIEW, FORUM_THEME_COOKIE, type ForumNavData, type ForumTheme } from "@/lib/forum";
import { forumEnabled, forumGet } from "@/lib/forumServer";
import "./forum.css";
const DESCRIPTION = "Spirituális fórum a Sorsfonalakon: beszélgetés, meghallgatás, asztrológia, álmok.";
export const metadata: Metadata = {
title: { default: "Fórum", template: "%s · Fórum · Sorsfonalak" },
description: "Spirituális fórum a Sorsfonalakon: beszélgetés, meghallgatás, asztrológia, álmok.",
description: DESCRIPTION,
openGraph: {
type: "website",
siteName: "Sorsfonalak",
locale: "hu_HU",
title: "Sorsfonalak fórum",
description: DESCRIPTION,
images: [FORUM_PREVIEW],
},
twitter: {
card: "summary_large_image",
title: "Sorsfonalak fórum",
description: DESCRIPTION,
images: [FORUM_PREVIEW.url],
},
};
/**
@@ -2,7 +2,7 @@ import type { Metadata } from "next";
import { notFound, permanentRedirect, redirect } from "next/navigation";
import { ThreadView } from "@/components/forum/ThreadView";
import type { ThreadPage } from "@/lib/forum";
import { FORUM_PREVIEW, type ThreadPage } from "@/lib/forum";
import { forumGet } from "@/lib/forumServer";
type Props = { params: Promise<{ id: string }> };
@@ -19,18 +19,42 @@ async function load(param: string) {
return forumGet<ThreadPage>(`/v1/forum/threads/${id}`);
}
/** The start of a post for a description: one line, cut at a word, at most `max` characters. */
function excerpt(text: string, max: number): string {
const line = text.replace(/\s+/g, " ").trim();
if (line.length <= max) return line;
const cut = line.slice(0, max - 1);
const words = cut.slice(0, Math.max(cut.lastIndexOf(" "), max / 2)).trimEnd();
return `${words.replace(/[.,;:!?–-]+$/, "")}…`;
}
export async function generateMetadata({ params }: Props): Promise<Metadata> {
const res = await load((await params).id);
if (!res?.ok) return { title: "Fórum", robots: { index: false } };
const { thread, posts } = res.data;
const open = thread.topic.visibility === "public" && !thread.deleted;
const opening = posts.find((p) => p.is_opening)?.body ?? "";
const url = `/forum/szal/${thread.id}-${thread.slug}`;
// The link preview: a public thread's title and opening words; of a
// members-only or removed one nothing (link previews are public).
const preview = open
? { title: thread.title, description: excerpt(opening, 200) }
: { title: "Sorsfonalak fórum", description: "Beszélgetés a Sorsfonalak fórumán." };
return {
title: thread.title,
description: open ? opening.slice(0, 160) : undefined,
alternates: { canonical: `/forum/szal/${thread.id}-${thread.slug}` },
description: open ? excerpt(opening, 160) : undefined,
alternates: { canonical: url },
// Members-only topics and removed threads stay out of search engines.
robots: open ? undefined : { index: false, follow: false },
openGraph: {
type: "article",
siteName: "Sorsfonalak",
locale: "hu_HU",
url,
...preview,
images: [FORUM_PREVIEW],
},
twitter: { card: "summary_large_image", ...preview, images: [FORUM_PREVIEW.url] },
};
}
+4
View File
@@ -1879,3 +1879,7 @@ span.tarot-fan-card { cursor: default; }
.mail-set { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.mail-set legend { font-family: var(--font-display); font-size: 20px; font-weight: 600; margin-bottom: 4px; }
.mail-set label:not(.check) { font-size: 14px; color: var(--ink-2); margin-top: 6px; }
.weekly-landing-lead { font-size: 17px; line-height: 1.6; max-width: 640px; }
.weekly-landing-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 6px; }
.weekly-steps { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 10px; color: var(--ink-2); line-height: 1.55; }
.weekly-steps strong { color: var(--ink); font-weight: 600; }
@@ -0,0 +1,70 @@
import Link from "next/link";
import { Paragraphs } from "@/components/Rich";
import example from "@/content/pelda-heti.json";
import { weekRange } from "@/lib/weekly";
const LOGIN = "/belepes?vissza=/heti-horoszkop";
/**
* The weekly horoscope for visitors: what it is, a real example written for
* the example chart (the one of the Példaelemzés page), and the way in.
*/
export function WeeklyLanding() {
return (
<main className="page weekly-landing" style={{ maxWidth: 820 }}>
<div className="page-head">
<span className="eyebrow">Ingyenes · hétfőnként új</span>
<h1>Heti horoszkóp, ami rólad szól</h1>
<p className="muted weekly-landing-lead">
Nem a csillagjegyedre írt általános szöveg: a hét égboltját a saját születési képletedre vetítjük. Melyik
bolygó milyen fényszöget alkot a te pontjaiddal, melyik napon, és mit kérhet tőled a héten.
</p>
<div className="weekly-landing-actions">
<Link href={LOGIN} className="btn btn-primary lp-btn">
Belépés
</Link>
<Link href={`/belepes?mod=regisztracio&vissza=/heti-horoszkop`} className="btn lp-btn">
Regisztráció
</Link>
</div>
</div>
<article className="card summary-card weekly-card" aria-labelledby="weekly-example-title">
<span className="eyebrow">Példa · {weekRange(example.week_start, example.week_end)}</span>
<h2 id="weekly-example-title" className="summary-title">
{example.title}
</h2>
<div className="summary-text weekly-text" lang="hu">
<Paragraphs text={example.text} />
</div>
<p className="hint" style={{ margin: 0 }}>
Ezt a heti horoszkópot a <Link href="/pelda">példaelemzés</Link> kitalált képletéhez írtuk (1990. március 15.,
14:30, Szeged), ugyanúgy, ahogy a tiédet is megírjuk.
</p>
</article>
<section className="card field weekly-how" aria-labelledby="weekly-how-title" style={{ gap: 12 }}>
<h2 id="weekly-how-title">Hogyan működik?</h2>
<ol className="weekly-steps">
<li>
<strong>Megadod, mikor és hol születtél.</strong> Ebből percre pontosan kiszámoljuk a születési képletedet.
</li>
<li>
<strong>Hétfőnként új heti horoszkópot kapsz,</strong> a te képletedből és a hét égboltjából: a hét fő
témája, a kulcsnapok és egy javaslat.
</li>
<li>
<strong>Hétfő reggel e-mailben szólunk,</strong> hogy itt az új. Ha nem kéred, egy kattintással
kikapcsolhatod.
</li>
</ol>
<div>
<Link href={LOGIN} className="btn btn-primary">
Belépés, és kérem a heti horoszkópomat
</Link>
</div>
</section>
</main>
);
}
@@ -3,9 +3,10 @@
import Link from "next/link";
import { useEffect, useState } from "react";
import { MONTHS, WeekCard, WeeklyEmailSwitch } from "@/components/WeeklyHoroscope";
import { WeekCard, WeeklyEmailSwitch } from "@/components/WeeklyHoroscope";
import { api, errorText } from "@/lib/api";
import type { Analysis } from "@/lib/types";
import { MONTHS } from "@/lib/weekly";
const POLL_MS = 3000;
const MAX_POLLS = 60;
@@ -34,8 +35,9 @@ function monthName(key: string): string {
/**
* One month of weekly horoscopes, the newest week first. In this month the
* week's horoscope is asked for first (queued if new), and polled until the
* worker has written it; meanwhile its card shows the waiting animation.
* week's horoscope is asked for first (queued if new), then read until the
* worker has written it (or given up); meanwhile its card shows the waiting
* animation.
*/
export function WeeklyPage({ month, isAdmin }: { month: string | null; isAdmin: boolean }) {
const [data, setData] = useState<Month | null>(null);
@@ -52,25 +54,45 @@ export function WeeklyPage({ month, isAdmin }: { month: string | null; isAdmin:
useEffect(() => {
let stopped = false;
let timer: ReturnType<typeof setTimeout> | undefined;
let polls = 0;
const poll = async () => {
try {
const week = await api<Week & { email: boolean }>("/weekly", { method: "POST" });
if (stopped) return;
putWeek({ week_start: week.week_start, week_end: week.week_end, analysis: week.analysis });
if (week.analysis.status === "done") return;
} catch {
// try again on the next tick
const wait = () => new Promise((resolve) => (timer = setTimeout(resolve, POLL_MS)));
/**
* This week's text: asked for once (queued if new, or written again if
* the last attempt failed), then only read until the worker is done.
*/
const follow = async () => {
let week: Week | null = null;
for (let tries = 0; !week && tries < 5 && !stopped; tries++) {
try {
const got = await api<Week & { email: boolean }>("/weekly", { method: "POST" });
week = { week_start: got.week_start, week_end: got.week_end, analysis: got.analysis };
} catch {
await wait();
}
}
if (!week || stopped) return setGaveUp(!stopped);
putWeek(week);
for (let polls = 0; !stopped; polls++) {
const { status } = week.analysis;
if (status === "done" || status === "failed") return;
if (polls >= MAX_POLLS) return setGaveUp(true);
await wait();
try {
const id: string = week.analysis.id;
const analysis: Analysis = await api<Analysis>(`/analyses/${id}`);
if (stopped) return;
week = { ...week, analysis };
putWeek(week);
} catch {
// try again on the next tick
}
}
if (++polls >= MAX_POLLS) return setGaveUp(true);
timer = setTimeout(poll, POLL_MS);
};
(async () => {
try {
const page = await api<Month>(`/weekly/history${query}`);
if (stopped) return;
setData(page);
if (page.month === page.current_month) await poll();
if (page.month === page.current_month) await follow();
} catch (e) {
if (!stopped) setError(errorText(e));
}
@@ -1,22 +1,58 @@
import type { Metadata } from "next";
import Link from "next/link";
import { requireMe } from "@/lib/server";
import { PublicHeader } from "@/components/SiteHeader";
import { getMe } from "@/lib/server";
import { siteUrl } from "@/lib/share";
import { WeeklyLanding } from "./Landing";
import { WeeklyPage } from "./WeeklyPage";
export const metadata: Metadata = { title: "Heti horoszkóp" };
/** Bumped when the preview image changes, so Facebook and co. fetch it again. */
const PREVIEW_VERSION = 1;
export async function generateMetadata(): Promise<Metadata> {
const base = await siteUrl();
const title = "Heti horoszkóp, ami rólad szól";
const description =
"Ingyenes, hétfőnként új személyes heti horoszkóp a saját születési képletedből és a hét égboltjából: a hét fő témája, a kulcsnapok és egy javaslat.";
const image = { url: `${base}/kep/heti-horoszkop.png?v=${PREVIEW_VERSION}`, width: 1200, height: 630, alt: title };
return {
title: "Heti horoszkóp",
description,
alternates: { canonical: `${base}/heti-horoszkop` },
openGraph: {
type: "website",
siteName: "Sorsfonalak",
locale: "hu_HU",
url: `${base}/heti-horoszkop`,
title,
description,
images: [image],
},
twitter: { card: "summary_large_image", title, description, images: [image.url] },
};
}
/**
* The member's weekly horoscopes, one month at a time, the newest first
* (`?honap=2026-11` pages back). This week's is written when the page opens.
* The weekly horoscope. Members: their own, one month at a time, the newest
* first (`?honap=2026-11` pages back); this week's is written when the page
* opens. Visitors: what it is, with an example, and the way in.
*/
export default async function WeeklyHoroscopePage({
searchParams,
}: {
searchParams: Promise<Record<string, string | string[]>>;
}) {
const me = await requireMe("/heti-horoszkop");
const me = await getMe();
if (!me) {
return (
<>
<PublicHeader />
<WeeklyLanding />
</>
);
}
const raw = (await searchParams).honap;
const month = (Array.isArray(raw) ? raw[0] : raw) ?? null;
return (
@@ -0,0 +1,21 @@
// The link preview image of the forum's pages (og:image), drawn from the
// example chart. The pages link it with a version (?v=…).
import example from "@/content/pelda.json";
import { chartCard } from "@/lib/ogCard";
import type { ChartResult } from "@/lib/types";
export async function GET() {
return chartCard({
chart: example.chart as unknown as ChartResult,
timeKnown: true,
eyebrow: "SORSFONALAK FÓRUM",
title: "Ahol meghallgatnak.",
text: "Beszélgetés, meghallgatás, asztrológia és álmok: egy nyugodt, figyelmes közösség.",
lines: [
{ glyph: "☽", label: "Meghallgatás" },
{ glyph: "☿", label: "Beszélgetés" },
{ glyph: "♀", label: "Asztrológia" },
],
cacheControl: "public, max-age=86400, s-maxage=604800",
});
}
@@ -0,0 +1,21 @@
// The link preview image of the weekly horoscope page (og:image), drawn from
// the example chart. The page links it with a version (?v=…).
import example from "@/content/pelda.json";
import { chartCard } from "@/lib/ogCard";
import type { ChartResult } from "@/lib/types";
export async function GET() {
return chartCard({
chart: example.chart as unknown as ChartResult,
timeKnown: true,
eyebrow: "HETI HOROSZKÓP",
title: "A te heted, nem a csillagjegyedé.",
text: "Hétfőnként új, személyes horoszkóp a saját születési képletedből és a hét égboltjából. Ingyenes.",
lines: [
{ glyph: "☉", label: "A saját képletedből" },
{ glyph: "☽", label: "A hét égboltjából" },
{ glyph: "☿", label: "Hétfőnként új" },
],
cacheControl: "public, max-age=86400, s-maxage=604800",
});
}
+1
View File
@@ -16,6 +16,7 @@ export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
return [
{ url: `${base}/`, changeFrequency: "weekly", priority: 1 },
{ url: `${base}/pelda`, changeFrequency: "monthly", priority: 0.8 },
{ url: `${base}/heti-horoszkop`, changeFrequency: "weekly", priority: 0.8 },
{ url: `${base}/kartyajoslas/pelda`, changeFrequency: "monthly", priority: 0.7 },
{ url: `${base}/szuletesi-horoszkop`, changeFrequency: "monthly", priority: 0.9 },
{ url: `${base}/csillagjegyek`, changeFrequency: "monthly", priority: 0.8 },
@@ -4,6 +4,7 @@ import { useEffect, useState } from "react";
import { api, errorText } from "@/lib/api";
import type { Analysis } from "@/lib/types";
import { weekRange } from "@/lib/weekly";
import { AnalysisLoading } from "./AnalysisLoading";
import { RateContent } from "./RateContent";
@@ -11,28 +12,6 @@ import { RegenerateButton } from "./RegenerateButton";
import { RetryNotice } from "./RetryNotice";
import { Paragraphs } from "./Rich";
export const MONTHS = [
"január",
"február",
"március",
"április",
"május",
"június",
"július",
"augusztus",
"szeptember",
"október",
"november",
"december",
];
/** "november 30. – december 6." or "december 7–13.". */
export function weekRange(start: string, end: string): string {
const [, m1, d1] = start.split("-").map(Number);
const [, m2, d2] = end.split("-").map(Number);
return m1 === m2 ? `${MONTHS[m1 - 1]} ${d1}–${d2}.` : `${MONTHS[m1 - 1]} ${d1}. – ${MONTHS[m2 - 1]} ${d2}.`;
}
/**
* Monday's e-mail about the weekly horoscope, on or off. Turned on, the first
* one comes next Monday.
@@ -0,0 +1,6 @@
{
"week_start": "2026-11-30",
"week_end": "2026-12-06",
"title": "Gondolatok, amelyek összeérnek",
"text": "A héten a gondolkodásod és a szíved egymásra hangolódnak. A legtisztább üzenetet a Merkúr hozza: a trigonja a születési Merkúrod felett hétfőn pontos, ez a világos fejtartás napja. A Nap a Nyilas jegyében a születési Vénuszodra szextilt vet, a Merkúr pedig a Szaturnuszoddal is harmonizál. A háttérben a Plútó lassan dolgozik a születési Marsod közelében: mély, kitartó átalakulás, nem hirtelen fordulat.\n\nHétfőn a Mars szextilje a születési Jupiteroddal is kedvező, a Mars az 1. házban jár, így a kezdeményezőkedved most erős. Kedden csúcsnap jön: a Nap szextilje a Vénuszoddal és a Merkúr szextilje a Szaturnusszal a hét legtisztább harmóniája, miközben az utolsó negyedben álló Hold a Szűz jegyében, az 1. házban a dolgok lecsupaszítására hív. Szerdán a Merkúr trigonja a Napoddal megerősíti, hogy a szavaid mögött valódi meggyőződés áll. Pénteken a Vénusz Skorpióba lép a 3. házban, szombaton a Hold is követi, így a hét vége befelé forduló, mélyebb hangulatú. Vasárnap a Vénusz trigonja a Jupiterrel bőséges, nagylelkű zárást ad.\n\nJavaslat: kedden írd le azt a kérést vagy elhatározást, amit eddig halogattál, mert a Merkúr és a Szaturnusz összhangja most kitartást ad a szavaidnak. A hét végén engedj teret a csendnek a Hold skorpiós hullámzásában, és vasárnap, a Vénusz–Jupiter trigon jegyében, merj örülni annak, ami már a tiéd."
}
+3
View File
@@ -280,6 +280,9 @@ export const INTENTS = {
} as const;
/** `/forum/szal/123-nem-tudom-elengedni`: the number decides, the words are for reading. */
/** The forum's link preview image (Facebook and co.); a thread adds its own title and text. */
export const FORUM_PREVIEW = { url: "/kep/forum.png?v=1", width: 1200, height: 630, alt: "A Sorsfonalak fóruma" };
export function threadHref(t: { id: number; slug: string }, postId?: number): string {
const path = t.slug ? `/forum/szal/${t.id}-${t.slug}` : `/forum/szal/${t.id}`;
return postId ? `${path}#h${postId}` : path;
+23
View File
@@ -0,0 +1,23 @@
/** Dates of the weekly horoscope (shared by the server and the browser). */
export const MONTHS = [
"január",
"február",
"március",
"április",
"május",
"június",
"július",
"augusztus",
"szeptember",
"október",
"november",
"december",
];
/** "november 30. – december 6." or "december 7–13.". */
export function weekRange(start: string, end: string): string {
const [, m1, d1] = start.split("-").map(Number);
const [, m2, d2] = end.split("-").map(Number);
return m1 === m2 ? `${MONTHS[m1 - 1]} ${d1}–${d2}.` : `${MONTHS[m1 - 1]} ${d1}. – ${MONTHS[m2 - 1]} ${d2}.`;
}