Weekly horoscope landing page, link previews for the forum, and fixes from the review
- /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:
@@ -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 (
|
||||
|
||||
Reference in New Issue
Block a user