Forum: a service of its own and the /forum pages

services/forum (axum, port 8083) on the same database and login, in the
forum schema (migration 0038, which also adds the moderator role):
nicknames, profiles with shared signs, topics, threads with listening or
advice intent, two-level replies, read marks and followed threads,
reactions as ratings with points and ranks, newcomer limits (lifted by a
purchase), moderation with reasons, bans and a log. Integration tests run
in CI.

The frontend's /forum pages (light by default, dark on request, phone
first with a desktop layout) are switched on by FORUM_URL; the /api/v1
proxy sends /api/v1/forum/* to the forum service. Concept and status:
docs/kozosseg.md.

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-26 10:29:49 +00:00
co-authored by Claude Opus 5.5
parent fa46dcb757
commit 36b38525c3
52 changed files with 6782 additions and 11 deletions
@@ -0,0 +1,81 @@
import type { Metadata } from "next";
import Link from "next/link";
import { notFound, redirect } from "next/navigation";
import { ThreadList } from "@/components/forum/ThreadList";
import type { TopicPage } from "@/lib/forum";
import { forumGet } from "@/lib/forumServer";
type Props = { params: Promise<{ tema: string }>; searchParams: Promise<{ oldal?: string }> };
async function load(slug: string, page: number) {
return forumGet<TopicPage>(`/v1/forum/topics/${encodeURIComponent(slug)}?page=${page}`);
}
function pageOf(raw: string | undefined): number {
const n = Number(raw ?? 1);
return Number.isInteger(n) && n > 0 ? n : 1;
}
export async function generateMetadata({ params }: Props): Promise<Metadata> {
const { tema } = await params;
const res = await load(tema, 1);
if (!res.ok) return { title: "Fórum" };
const { topic } = res.data;
// Members-only topics stay out of search engines.
return {
title: topic.name,
description: topic.description,
robots: topic.visibility === "public" ? undefined : { index: false, follow: false },
};
}
/** A topic's threads: pinned ones first, then by the latest post. */
export default async function TopicPageView({ params, searchParams }: Props) {
const { tema } = await params;
const page = pageOf((await searchParams).oldal);
const res = await load(tema, page);
if (!res.ok) {
if (res.status === 401) redirect(`/belepes?vissza=/forum/${tema}`);
notFound();
}
const { topic, threads, has_more, viewer } = res.data;
return (
<div className="fh">
<nav className="forum-crumbs" aria-label="Morzsamenü">
<Link href="/forum">Fórum</Link>
</nav>
<header className="ftopic-head">
<div>
<h1>{topic.name}</h1>
<p className="muted">{topic.description}</p>
{topic.listening && (
<p className="hint">
Meghallgatós téma: itt nincs ⌄, és a szálak alapból meghallgatást kérnek, nem tanácsot.
</p>
)}
</div>
<Link
href={viewer.logged_in ? `/forum/uj?tema=${topic.slug}` : `/belepes?vissza=/forum/uj?tema=${topic.slug}`}
className="btn btn-primary"
>
Új szál
</Link>
</header>
{threads.length === 0 ? (
<p className="fh-card fh-empty">Ebben a témában még nincs szál. Nyisd meg te az elsőt!</p>
) : (
<div className="fh-card fh-flush">
<ThreadList threads={threads} showTopic={false} />
</div>
)}
{(page > 1 || has_more) && (
<nav className="forum-pager" aria-label="Lapozás">
{page > 1 ? <Link href={`/forum/${topic.slug}?oldal=${page - 1}`}>‹ Újabbak</Link> : <span />}
<span className="hint">{page}. oldal</span>
{has_more ? <Link href={`/forum/${topic.slug}?oldal=${page + 1}`}>Régebbiek ›</Link> : <span />}
</nav>
)}
</div>
);
}
@@ -0,0 +1,205 @@
"use client";
import { useRouter } from "next/navigation";
import { useEffect, useState } from "react";
import { AVATAR_COLOURS, AVATAR_GLYPHS, Avatar, GLYPH_NAMES } from "@/components/forum/Avatar";
import { signsText } from "@/components/forum/AuthorLine";
import { api, errorText } from "@/lib/api";
import { type ChartShare, type ForumMe, banText, memberHref } from "@/lib/forum";
const SHARE_LEVELS: { value: ChartShare; label: string }[] = [
{ value: "none", label: "Semmit" },
{ value: "sun", label: "Csak a Nap-jegyemet" },
{ value: "big3", label: "Nap, Hold és Aszcendens" },
{ value: "planets", label: "Minden bolygó jegyét" },
];
export function ProfileForm({ me, back }: { me: ForumMe; back: string | null }) {
const router = useRouter();
const member = me.member;
const [nickname, setNickname] = useState(member?.nickname ?? "");
const [check, setCheck] = useState<{ ok: boolean; message?: string } | null>(null);
const [avatar, setAvatar] = useState(member?.avatar ?? "");
const [bio, setBio] = useState(member?.bio ?? "");
const [share, setShare] = useState<ChartShare>(member?.chart_share ?? "none");
const [invisible, setInvisible] = useState(member?.invisible ?? false);
const [busy, setBusy] = useState(false);
const [error, setError] = useState<string | null>(null);
const [saved, setSaved] = useState(false);
// While typing: valid and free? (Not for the member's own current name.)
useEffect(() => {
const name = nickname.trim();
if (!name || name === member?.nickname) {
setCheck(null);
return;
}
const timer = window.setTimeout(() => {
api<{ ok: boolean; message?: string }>(`/forum/nickname-check?name=${encodeURIComponent(name)}`)
.then(setCheck)
.catch(() => setCheck(null));
}, 400);
return () => window.clearTimeout(timer);
}, [nickname, member?.nickname]);
async function submit(e: React.FormEvent) {
e.preventDefault();
setBusy(true);
setError(null);
setSaved(false);
try {
const res = await api<ForumMe>("/forum/me", {
method: "PUT",
body: { nickname, avatar: avatar || null, bio, chart_share: share, invisible },
});
if (back) {
router.push(back);
} else if (!member && res.member) {
router.push(memberHref(res.member.nickname));
} else {
setSaved(true);
}
router.refresh();
} catch (err) {
setError(errorText(err));
} finally {
setBusy(false);
}
}
const preview = share === "none" ? null : me.chart?.[share];
return (
<form className="fprof" onSubmit={submit}>
{member?.banned_until && (
<p className="fh-banner fh-banner-warn">
Most nem írhatsz a fórumba ({banText(member.banned_until)}).
{member.ban_reason && ` Indok: ${member.ban_reason}`}
</p>
)}
<div className="field">
<label htmlFor="fprof-nick">Álnév</label>
<input
id="fprof-nick"
className="inp"
value={nickname}
onChange={(e) => setNickname(e.target.value)}
maxLength={24}
required
autoComplete="off"
aria-describedby="fprof-nick-hint"
/>
<span id="fprof-nick-hint" className={check && !check.ok ? "hint warn" : "hint"}>
{check && !check.ok
? check.message
: check?.ok
? "Szabad, választhatod."
: "Ne a valódi neved legyen, ha nem szeretnéd, hogy felismerjenek. 3–24 karakter: betűk, számok, szóköz, kötőjel."}
</span>
{member?.nickname_change_after && (
<span className="hint">
Új álnevet{" "}
{new Date(member.nickname_change_after).toLocaleDateString("hu-HU", { month: "long", day: "numeric" })} után
választhatsz (az ékezet és a kis- és nagybetű javítható addig is).
</span>
)}
</div>
<fieldset className="fnew-set">
<legend>Avatar</legend>
<div className="fprof-avatars">
{AVATAR_COLOURS.flatMap((colour) =>
AVATAR_GLYPHS.map((glyph) => {
const value = `${glyph}-${colour}`;
return (
<label key={value} className="fprof-avatar" title={GLYPH_NAMES[glyph]}>
<input
type="radio"
name="avatar"
value={value}
checked={avatar === value}
onChange={() => setAvatar(value)}
className="sr-only"
/>
<Avatar avatar={value} size={44} />
<span className="sr-only">{GLYPH_NAMES[glyph]}</span>
</label>
);
}),
)}
</div>
{!avatar && <span className="hint">Ha nem választasz, az álneved alapján kapsz egyet.</span>}
</fieldset>
<div className="field">
<label htmlFor="fprof-bio">Bemutatkozás</label>
<textarea
id="fprof-bio"
className="fc-text"
rows={4}
maxLength={500}
value={bio}
onChange={(e) => setBio(e.target.value)}
placeholder="Pár mondat magadról, ha szeretnéd."
/>
<span className="hint">{bio.length}/500 · link nem tehető bele</span>
</div>
<fieldset className="fnew-set">
<legend>Mit mutatsz meg a képletedből?</legend>
<div className="fnew-intents">
{SHARE_LEVELS.map((level) => (
<label key={level.value} className="fnew-intent">
<input type="radio" name="share" checked={share === level.value} onChange={() => setShare(level.value)} />
<span>
<strong>{level.label}</strong>
</span>
</label>
))}
</div>
<span className="hint">
{me.chart === null
? "Még nincs saját képleted, így most semmi nem látszana."
: preview
? `Így látszik a neved mellett: ${signsText(preview)}`
: share === "none"
? "Semmi nem látszik a képletedből."
: "Ehhez a szinthez nincs adat a képletedben."}{" "}
Fokokat soha nem mutatunk, mert azokból kiszámolható a születési időd.
</span>
</fieldset>
<label className="fprof-check">
<input type="checkbox" checked={invisible} onChange={(e) => setInvisible(e.target.checked)} />
<span>
<strong>Láthatatlan mód</strong>
<span className="hint">Nem jelenik meg mellettem a zöld pötty, és az sem, mikor jártam itt utoljára.</span>
</span>
</label>
{member && (
<div className="fprof-rank">
<span className="eyebrow">Rangod</span>
<strong>{member.rank_name}</strong>
<span className="hint">
{member.points} pont · {member.post_count} hozzászólás
{member.next_rank &&
` · a ${member.next_rank.name} ranghoz ${member.next_rank.points} pont és ${member.next_rank.days} nap tagság kell`}
</span>
</div>
)}
{error && (
<p className="msg msg-error" role="alert">
{error}
</p>
)}
{saved && <p className="msg">Elmentve.</p>}
<button type="submit" className="btn btn-primary" disabled={busy || !nickname.trim() || check?.ok === false}>
{busy ? "Mentés…" : member ? "Mentés" : "Álnév mentése"}
</button>
</form>
);
}
@@ -0,0 +1,32 @@
import { redirect } from "next/navigation";
import type { ForumMe } from "@/lib/forum";
import { forumGet } from "@/lib/forumServer";
import { ProfileForm } from "./ProfileForm";
export const metadata = { title: "Fórumprofil", robots: { index: false } };
type Props = { searchParams: Promise<{ vissza?: string }> };
/** The member's forum profile: the nickname first, then avatar, bio, signs, visibility. */
export default async function ForumSettingsPage({ searchParams }: Props) {
const { vissza } = await searchParams;
const res = await forumGet<ForumMe>("/v1/forum/me");
if (!res.ok) redirect(`/belepes?vissza=${encodeURIComponent("/forum/beallitasok")}`);
// Only back into the forum.
const back = vissza?.startsWith("/forum") ? vissza : null;
const me = res.data;
return (
<div className="fh">
<h1 className="fpage-title">{me.member ? "Fórumprofil" : "Válassz álnevet"}</h1>
{!me.member && (
<p className="muted">
A fórumon mindenki álnéven ír. A valódi neved, az e-mail-címed és a születési adataid soha nem jelennek meg
itt.
</p>
)}
<ProfileForm me={me} back={back} />
</div>
);
}
+447
View File
@@ -0,0 +1,447 @@
/* The forum: phones first (most members write from a phone), big touch
targets and text for the 50+ readers. Light by default, dark on request
(data-theme on .forum, from a cookie): both redefine the site's colour
tokens for the forum's part of the page, so the shared .btn, .inp, .hint
and links follow. */
/* --- themes --- */
.forum {
--f-hover: rgba(255, 255, 255, 0.04);
--f-tint: rgba(217, 180, 106, 0.1);
--f-tint-strong: rgba(217, 180, 106, 0.14);
--f-nav-bg: rgba(13, 18, 32, 0.97);
--f-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
--f-border-hover: #5a6790;
--f-online: #9fd8b0;
--f-blue-tint: rgba(127, 176, 224, 0.12);
--f-orange-tint: rgba(240, 163, 94, 0.12);
--f-red-tint: rgba(242, 160, 160, 0.08);
--f-green-tint: rgba(159, 216, 176, 0.12);
color: var(--ink);
}
.forum[data-theme="light"] {
--bg: #f6f3ed;
--panel: #ffffff;
--panel-2: #faf8f4;
--line: #e6dfd2;
--line-2: #d3c9b6;
--ink: #1b2236;
--ink-2: #3a4259;
--muted: #5c6376;
--gold: #8a6a24;
--gold-hover: #6e5419;
--gold-ink: #ffffff;
--danger: #b03a3a;
--ok: #2d7a4c;
--harmonic: #2c66a0;
--square: #9c520e;
--f-hover: rgba(27, 34, 54, 0.04);
--f-tint: rgba(167, 128, 47, 0.09);
--f-tint-strong: rgba(167, 128, 47, 0.14);
--f-nav-bg: rgba(255, 255, 255, 0.97);
--f-shadow: 0 12px 32px rgba(27, 34, 54, 0.14);
--f-border-hover: #a99d86;
--f-online: #2fa865;
--f-blue-tint: rgba(44, 102, 160, 0.09);
--f-orange-tint: rgba(156, 82, 14, 0.09);
--f-red-tint: rgba(176, 58, 58, 0.07);
--f-green-tint: rgba(45, 122, 76, 0.1);
color-scheme: light;
}
/* The light forum takes the whole page between the (dark) header and footer
(the body rule; the background here is for browsers without :has). */
.forum[data-theme="light"] { background: var(--bg); min-height: 70vh; }
body:has(.forum[data-theme="light"]) { background: #f6f3ed; }
body:has(.forum[data-theme="light"]) .night-sky { display: none; }
body:has(.forum[data-theme="light"]) .site-footer { background: #0d1220; }
.forum[data-theme="light"] .inp:focus { background-color: var(--panel); box-shadow: 0 0 0 3px rgba(167, 128, 47, 0.22); }
.forum[data-theme="light"] .inp::placeholder { color: #8b8f9c; }
.forum[data-theme="light"] .btn:hover { border-color: var(--f-border-hover); background: var(--f-hover); }
.forum[data-theme="light"] .moon-phase-icon .moon-dark { fill: #ebe5d8; stroke: #b99550; }
.forum[data-theme="light"] .moon-phase-icon .moon-lit { fill: #d9b46a; }
/* --- frame --- */
.forum-inner { max-width: 1180px; margin: 0 auto; padding: 8px 16px 104px; }
.forum-main { display: flex; flex-direction: column; }
.forum h1, .forum h2 { font-family: var(--font-display); font-weight: 600; color: var(--ink); }
.forum-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; margin-bottom: 8px; }
.forum-mark { font-family: var(--font-display); font-size: 26px; font-weight: 600; color: var(--ink); text-decoration: none; }
.forum-mark:hover { color: var(--gold); }
.forum-theme {
display: inline-flex; align-items: center; gap: 8px; min-width: 44px; min-height: 44px; padding: 0 10px; justify-content: center;
border: 1px solid var(--line-2); border-radius: 999px; background: var(--panel); color: var(--ink-2);
font: 500 14px var(--font-body); cursor: pointer;
}
.forum-theme:hover { color: var(--gold); border-color: var(--f-border-hover); }
.forum-theme svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.forum-theme-label { display: none; }
/* The forum's menu: a bar at the bottom on phones, tabs in the forum bar on wider screens. */
.forum-nav {
position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
background: var(--f-nav-bg); border-top: 1px solid var(--line);
padding-bottom: env(safe-area-inset-bottom);
box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.08);
}
.fn-item {
display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
min-height: 62px; color: var(--ink-2); text-decoration: none; font-size: 12px;
}
.fn-item[aria-current="page"] { color: var(--gold); font-weight: 600; }
.fn-item:hover { color: var(--gold); }
.fn-icon-wrap { position: relative; display: inline-flex; }
.fn-icon { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.fn-badge {
position: absolute; top: -6px; right: -11px; min-width: 18px; height: 18px; padding: 0 5px; box-sizing: border-box;
border-radius: 999px; background: var(--gold); color: var(--gold-ink); font-size: 11px; font-weight: 600; line-height: 18px; text-align: center;
}
@media (min-width: 760px) {
.forum-inner { padding: 20px 24px 64px; }
.forum-bar {
gap: 16px; margin-bottom: 24px; padding: 6px 6px 6px 18px;
background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
}
.forum-nav {
position: static; flex: 1; display: flex; gap: 4px; padding: 0;
background: none; border: 0; box-shadow: none;
}
.fn-item { flex-direction: row; gap: 8px; min-height: 44px; padding: 0 14px; border-radius: 10px; font-size: 15px; }
.fn-item[aria-current="page"] { background: var(--f-tint); }
.fn-icon { width: 20px; height: 20px; }
.forum-theme { padding: 0 14px; }
.forum-theme-label { display: inline; }
}
/* --- avatars and the author line --- */
.av { position: relative; display: inline-flex; flex: none; }
.av svg { display: block; }
/* The night-coloured avatars keep the bright gold in both themes. */
.av-glyph { fill: none; stroke: #d9b46a; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.av-glyph .av-fill { fill: #d9b46a; stroke: none; }
.av-online {
position: absolute; right: -1px; bottom: -1px; width: 28%; height: 28%; min-width: 9px; min-height: 9px;
border-radius: 50%; background: var(--f-online); border: 2px solid var(--panel); box-sizing: border-box;
}
.fa-line { display: flex; align-items: center; gap: 10px; min-width: 0; }
.fa-avatar { display: inline-flex; }
.fa-meta { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.fa-names { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.fa-name { font-size: 16px; font-weight: 600; color: var(--ink); text-decoration: none; }
.fa-name:hover { color: var(--gold); }
.fa-rank { font-size: 12px; color: var(--ink-2); border: 1px solid var(--line-2); border-radius: 6px; padding: 0 6px; }
.fa-badge { font-size: 12px; border-radius: 6px; padding: 0 6px; }
.fa-badge-mod { color: var(--ok); background: var(--f-green-tint); }
.fa-badge-starter { color: var(--gold); border: 1px solid var(--line-2); }
.fa-badge-new { color: var(--gold-ink); background: var(--gold); font-weight: 600; }
.fa-sub { font-size: 13px; color: var(--muted); }
/* --- cards, banners, sections --- */
.fh { display: flex; flex-direction: column; gap: 22px; }
.fh-card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 18px; }
.forum[data-theme="light"] .fh-card { box-shadow: 0 1px 2px rgba(27, 34, 54, 0.04); }
.fh-flush { padding: 0; overflow: hidden; }
.fh-empty { color: var(--muted); }
.fh-card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 12px; }
.fh-intro { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.fh-intro h1 { font-size: 36px; }
.fh-banner {
display: flex; align-items: center; gap: 12px; justify-content: space-between;
min-height: 52px; padding: 12px 14px; border-radius: 12px;
background: var(--f-tint); border: 1px solid var(--line-2); color: var(--ink); text-decoration: none;
}
.fh-banner strong { color: var(--gold); font-weight: 600; }
.fh-banner:hover { color: var(--ink); background: var(--f-tint-strong); }
.fh-banner-warn { background: var(--f-red-tint); border-color: var(--danger); }
.fh-section { display: flex; flex-direction: column; gap: 12px; }
.fh-section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.fh-section-head h2 { font-size: 24px; }
.fh-sky-body { display: flex; gap: 16px; align-items: flex-start; }
.fh-moon .moon-phase-icon { width: 56px; height: 56px; }
.fh-sky-text { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.fh-sky-text h2 { font-size: 24px; line-height: 1.15; }
.fh-sky-text p { color: var(--ink-2); font-size: 16px; }
.fh-sky-link, .fh-side-link { display: inline-flex; align-items: center; min-height: 44px; margin-top: 8px; font-size: 15px; }
.fh-waiting-grid { display: grid; gap: 12px; }
@media (min-width: 760px) { .fh-waiting-grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); } }
.fh-me { display: flex; flex-direction: column; gap: 14px; }
.fh-me-head { display: flex; align-items: center; gap: 12px; }
.fh-me-names { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.fh-me-actions { display: flex; gap: 8px; flex-wrap: wrap; }
/* Front page: one column on phones in reading order (the two columns'
blocks interleave), main column and sidebar from 1024 px. */
.fh-home .fh-col { display: contents; }
.o-1 { order: 1; } .o-2 { order: 2; } .o-3 { order: 3; } .o-4 { order: 4; }
.o-5 { order: 5; } .o-6 { order: 6; } .o-7 { order: 7; } .o-8 { order: 8; }
@media (min-width: 1024px) {
.fh-home { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 28px; align-items: start; }
.fh-home .fh-col { display: flex; flex-direction: column; gap: 22px; }
.fh-home .fh-col-side { position: sticky; top: 88px; }
}
/* --- topics --- */
.fh-topics { list-style: none; margin: 0; }
.fh-topics li + li { border-top: 1px solid var(--line); }
.fh-topic { display: flex; align-items: center; gap: 14px; padding: 14px 16px; min-height: 76px; color: var(--ink); text-decoration: none; }
.fh-topic:hover { color: var(--ink); background: var(--f-hover); }
.fh-topic-icon {
flex: none; width: 44px; height: 44px; border-radius: 12px; background: var(--f-tint);
display: inline-flex; align-items: center; justify-content: center;
}
.topic-icon { width: 24px; height: 24px; fill: none; stroke: var(--gold); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.fh-topic-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.fh-topic-name { display: flex; align-items: center; gap: 8px; font-size: 17px; font-weight: 600; }
.fh-lock { width: 14px; height: 14px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; }
.fh-topic-desc { font-size: 14px; color: var(--muted); }
.fh-topic-last { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.fh-topic-count { display: none; flex: none; font-size: 14px; color: var(--muted); text-align: right; min-width: 64px; }
.fh-topic-count strong { color: var(--ink); font-weight: 600; }
@media (min-width: 640px) { .fh-topic-count { display: block; } }
/* --- thread lists: a meta line on phones, columns on wider screens --- */
.ft-list { list-style: none; margin: 0; padding: 0; }
.ft-list li + li { border-top: 1px solid var(--line); }
.ft-row { display: flex; align-items: center; gap: 12px; padding: 14px 16px; min-height: 64px; color: var(--ink); text-decoration: none; }
.ft-row:hover { color: var(--ink); background: var(--f-hover); }
.ft-main { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
.ft-title { font-size: 17px; font-weight: 600; line-height: 1.35; }
.ft-row:hover .ft-title { color: var(--gold); }
.ft-excerpt { font-size: 14px; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ft-meta { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.ft-col { display: none; }
.ft-new {
flex: none; font-size: 13px; font-weight: 600; color: var(--gold-ink); background: var(--gold);
border-radius: 999px; padding: 2px 9px; white-space: nowrap;
}
.ft-read { flex: none; font-size: 13px; color: var(--muted); }
@media (min-width: 760px) {
.ft-row { display: grid; grid-template-columns: minmax(0, 1fr) 110px 100px 72px; gap: 16px; padding: 14px 20px; }
.ft-m-narrow { display: none; }
.ft-col { display: flex; flex-direction: column; align-items: flex-end; font-size: 14px; color: var(--muted); }
.ft-col strong { color: var(--ink); font-weight: 600; font-size: 16px; }
.ft-col-replies { flex-direction: row; gap: 4px; align-items: baseline; justify-content: flex-end; flex-wrap: wrap; }
.ft-col-replies .hint { flex-basis: 100%; text-align: right; }
.ft-new, .ft-read { justify-self: end; }
}
.ft-pin {
display: inline-block; margin-right: 8px; vertical-align: 2px; font-size: 12px; font-weight: 500;
color: var(--ink-2); border: 1px solid var(--line-2); border-radius: 6px; padding: 0 6px;
}
.ft-intent { align-self: flex-start; font-size: 13px; font-weight: 500; border-radius: 999px; padding: 3px 10px; }
.ft-intent-listen { color: var(--harmonic); background: var(--f-blue-tint); }
.ft-intent-advice { color: var(--square); background: var(--f-orange-tint); }
.ft-waiting {
display: flex; flex-direction: column; gap: 10px; padding: 16px; border-radius: 14px;
background: var(--panel); border: 1px solid var(--line);
}
.ft-waiting-title { font-size: 18px; font-weight: 600; line-height: 1.35; color: var(--ink); text-decoration: none; }
.ft-waiting-title:hover { color: var(--gold); }
.ft-answer { align-self: flex-start; min-height: 44px; border-color: var(--gold); color: var(--gold); margin-top: auto; }
/* --- topic page and the other headings --- */
.forum-crumbs { display: flex; gap: 8px; align-items: center; font-size: 14px; color: var(--muted); }
.forum-crumbs a { color: var(--ink-2); text-decoration: none; min-height: 32px; display: inline-flex; align-items: center; }
.forum-crumbs a:hover { color: var(--gold); }
.ftopic-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 16px; }
.ftopic-head h1, .fpage-title { font-size: 34px; line-height: 1.1; }
.ftopic-head > div { display: flex; flex-direction: column; gap: 6px; max-width: 620px; }
.forum-pager { display: flex; justify-content: space-between; align-items: center; min-height: 44px; }
/* --- thread view --- */
.ftv { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 980px; margin: 0 auto; }
.ftv-toolbar { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.ftv-toolbar:empty { display: none; }
.ftv-mod { position: relative; }
.ftv-mod summary { list-style: none; cursor: pointer; }
.ftv-mod summary::-webkit-details-marker { display: none; }
.ftv-mod-menu {
position: absolute; right: 0; top: calc(100% + 6px); z-index: 10; min-width: 200px; padding: 6px;
display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line-2); border-radius: 12px;
box-shadow: var(--f-shadow);
}
.ftv-mod-menu button {
min-height: 44px; padding: 0 12px; border: 0; border-radius: 8px; background: none; color: var(--ink);
font: inherit; font-size: 15px; text-align: left; cursor: pointer;
}
.ftv-mod-menu button:hover { background: var(--f-hover); color: var(--gold); }
.ftv-mod-menu button.danger { color: var(--danger); }
.ftv-intent {
display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; border-radius: 12px;
background: var(--f-blue-tint); font-size: 14px; line-height: 1.45; color: var(--ink-2);
}
.ftv-intent strong { color: var(--harmonic); font-weight: 600; }
.ftv-intent-advice { background: var(--f-orange-tint); }
.ftv-intent-advice strong { color: var(--square); }
.ftv-title { font-size: 30px; line-height: 1.12; }
.ftv-count { display: flex; justify-content: space-between; align-items: baseline; padding-top: 6px; }
.ftv .ftv-count h2 { font-family: var(--font-body); font-size: 15px; color: var(--ink-2); }
.ftv-branch { display: flex; flex-direction: column; }
.ftv-children { margin-left: 17px; padding-left: 14px; border-left: 2px solid var(--line); display: flex; flex-direction: column; }
.ftv-marker { display: flex; align-items: center; gap: 10px; margin: 8px 0 0; color: var(--gold); font-size: 13px; font-weight: 600; }
.ftv-marker::before, .ftv-marker::after { content: ""; flex: 1; height: 1px; background: var(--gold); opacity: 0.5; }
.ftv-incoming {
position: sticky; bottom: 84px; align-self: center; z-index: 5;
display: inline-flex; align-items: center; min-height: 44px; padding: 0 18px; border: 0; border-radius: 999px;
background: var(--gold); color: var(--gold-ink); font: 600 15px var(--font-body); cursor: pointer;
box-shadow: var(--f-shadow);
}
.ftv-compose { display: flex; flex-direction: column; gap: 8px; padding-top: 14px; border-top: 1px solid var(--line); scroll-margin-top: 90px; }
.ftv-hint { font-size: 14px; color: var(--harmonic); }
.ftv-replyto { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--ink-2); }
.ftv-gate { padding: 16px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); }
/* --- posts: author on top on phones, the old forums' author column on wide screens --- */
.fp { display: flex; flex-direction: column; padding: 16px 0; border-bottom: 1px solid var(--line); scroll-margin-top: 90px; }
.fp-content { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.fp-author, .fp-when { display: none; }
.ftv-children .fp:last-child { border-bottom: 0; }
.fp-opening { padding-top: 6px; padding-bottom: 20px; }
.fp-body { font-size: 17px; line-height: 1.6; overflow-wrap: anywhere; color: var(--ink); }
.fp-body p + p { margin-top: 10px; }
.fp-removed {
gap: 4px; margin: 12px 0; padding: 12px 14px; border: 1px dashed var(--line-2);
border-radius: 12px; color: var(--ink-2); font-size: 15px;
}
.fp-mod-note { font-size: 13px; color: var(--danger); }
.fp-collapsed {
align-self: flex-start; min-height: 44px; padding: 0; border: 0; background: none; color: var(--muted);
font: inherit; font-size: 15px; text-decoration: underline; cursor: pointer;
}
.fp-helped { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--ok); }
.fp-helped svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.fp-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.fp-spacer { flex: 1; }
.fp-link {
min-height: 44px; padding: 0 8px; border: 0; background: none; color: var(--gold);
font: 500 15px var(--font-body); cursor: pointer;
}
.fp-link:hover { color: var(--gold-hover); }
.fp-tools { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.fp-tools:empty { display: none; }
.fp-tool {
min-height: 36px; padding: 0 8px; border: 0; border-radius: 8px; background: none; color: var(--muted);
font: 400 14px var(--font-body); cursor: pointer;
}
.fp-tool:hover { color: var(--ink); background: var(--f-hover); }
.fp-tool[aria-pressed="true"] { color: var(--ok); }
.fp-tool-mod { color: var(--danger); }
@media (min-width: 900px) {
.forum-inner .ftv { gap: 14px; }
.fp { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 0 24px; padding: 20px 0; }
.fp.fp-removed { display: flex; flex-direction: column; }
.fp-head { display: none; }
.fp-author { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; min-width: 0; }
.fp-author-name { font-size: 16px; font-weight: 600; color: var(--ink); text-decoration: none; overflow-wrap: anywhere; margin-top: 2px; }
.fp-author-name:hover { color: var(--gold); }
.fp-author-signs { display: flex; flex-direction: column; gap: 1px; font-size: 13px; color: var(--muted); margin-top: 2px; }
.fp-when { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.ftv-children { margin-left: 40px; padding-left: 20px; }
.ftv-children .fp { grid-template-columns: 120px minmax(0, 1fr); }
.fr-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.ftv-incoming { bottom: 20px; }
}
/* --- reactions --- */
.fr-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.fr-big {
display: flex; align-items: center; gap: 8px; min-height: 46px; padding: 0 12px; border-radius: 12px;
border: 1px solid var(--line-2); background: var(--panel); color: var(--ink); font: 500 15px var(--font-body); cursor: pointer;
text-align: left;
}
.fr-big:hover:not(:disabled) { border-color: var(--f-border-hover); }
.fr-big[aria-pressed="true"] { border-color: var(--gold); background: var(--f-tint-strong); }
.fr-big:disabled { cursor: default; }
.fr-big-label { flex: 1; min-width: 0; }
.fr-count { color: var(--muted); }
.fr-big[aria-pressed="true"] .fr-count { color: var(--gold); font-weight: 600; }
.fr-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.fr-chip {
min-height: 44px; min-width: 44px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line-2);
background: none; color: var(--ink); font: 500 14px var(--font-body); cursor: pointer;
}
.fr-chip:disabled { cursor: default; }
.fr-chip:hover:not(:disabled) { border-color: var(--f-border-hover); }
.fr-chip[aria-pressed="true"] { border-color: var(--gold); background: var(--f-tint-strong); }
.fr-add { border-style: dashed; color: var(--muted); font-size: 18px; }
.fr-down { color: var(--muted); font-size: 18px; }
.fr-down[aria-pressed="true"] { background: var(--f-hover); color: var(--ink); }
.fr-more { position: relative; }
.fr-pop {
position: absolute; left: 0; bottom: calc(100% + 6px); z-index: 10; min-width: 210px; padding: 6px;
display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line-2); border-radius: 12px;
box-shadow: var(--f-shadow);
}
.fr-pop-item {
display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px; border: 0; border-radius: 8px;
background: none; color: var(--ink); font: 400 15px var(--font-body); text-align: left; cursor: pointer;
}
.fr-pop-item:hover { background: var(--f-hover); }
/* --- composer --- */
.fc { display: flex; flex-direction: column; gap: 8px; }
.fc-text {
width: 100%; min-height: 96px; box-sizing: border-box; padding: 12px 14px; border-radius: 12px;
border: 1px solid var(--line-2); background: var(--panel-2); color: var(--ink); font: 400 16px/1.45 var(--font-body);
resize: vertical; caret-color: var(--gold);
}
.fc-text::placeholder { color: var(--muted); }
.fc-text:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px var(--f-tint-strong); background: var(--panel); }
.fc-actions { display: flex; align-items: center; gap: 8px; }
.fc-spacer { flex: 1; }
.fc-icon-btn {
width: 44px; height: 44px; flex: none; display: inline-flex; align-items: center; justify-content: center;
border: 0; border-radius: 10px; background: none; color: var(--ink-2); cursor: pointer;
}
.fc-icon-btn:hover, .fc-icon-btn[aria-expanded="true"] { color: var(--gold); background: var(--f-tint); }
.fc-icon-btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.fc-tray {
display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: 2px; padding: 8px;
border: 1px solid var(--line-2); border-radius: 12px; background: var(--panel-2);
}
.fc-emoji {
width: 100%; height: 42px; border: 0; border-radius: 8px; background: none; color: var(--ink);
font-size: 22px; cursor: pointer; font-family: var(--font-symbols), sans-serif;
}
.fc-emoji:hover { background: var(--f-hover); }
/* --- new thread and profile forms --- */
.fnew, .fprof { display: flex; flex-direction: column; gap: 22px; width: 100%; max-width: 760px; }
.fnew-set { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.fnew-set legend { font-size: 14px; font-weight: 500; margin-bottom: 8px; padding: 0; }
.fnew-topics, .fnew-intents { display: grid; gap: 8px; }
@media (min-width: 640px) { .fnew-topics { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.fnew-topic, .fnew-intent, .fprof-check {
display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border: 1px solid var(--line-2);
border-radius: 12px; cursor: pointer; background: var(--panel);
}
.fnew-topic:has(input:checked), .fnew-intent:has(input:checked) { border-color: var(--gold); background: var(--f-tint); }
.fnew-topic > span, .fnew-intent > span, .fprof-check > span { display: flex; flex-direction: column; gap: 2px; }
.fnew-topic input, .fnew-intent input, .fprof-check input { margin-top: 4px; accent-color: var(--gold); width: 18px; height: 18px; flex: none; }
.fprof-avatars { display: grid; grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); gap: 6px; }
.fprof-avatar {
display: inline-flex; align-items: center; justify-content: center; padding: 3px; border-radius: 50%;
border: 2px solid transparent; cursor: pointer; justify-self: center;
}
.fprof-avatar:has(input:checked) { border-color: var(--gold); }
.fprof-avatar:has(input:focus-visible) { outline: 2px solid var(--gold); outline-offset: 2px; }
.fprof-rank { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); }
/* --- member page (two columns on wide screens) and moderation --- */
.fmember { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.fmember-head { display: flex; align-items: center; gap: 16px; }
.fmember-names { display: flex; flex-direction: column; gap: 4px; }
.fmember-names h1 { font-size: 30px; line-height: 1.1; }
.fmember-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.fmember-signs { color: var(--ink-2); }
@media (min-width: 900px) {
.fh-member { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 28px; align-items: start; }
.fh-member .fmember { position: sticky; top: 88px; }
}
.fban { align-self: stretch; }
.fban summary { list-style: none; cursor: pointer; display: inline-flex; }
.fban summary::-webkit-details-marker { display: none; }
.fban-body { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; padding: 14px; border: 1px solid var(--line-2); border-radius: 12px; }
.fmodlog { list-style: none; margin: 0; }
.fmodlog li { display: flex; flex-direction: column; gap: 2px; padding: 12px 16px; }
.fmodlog li + li { border-top: 1px solid var(--line); }
@@ -0,0 +1,27 @@
import { redirect } from "next/navigation";
import { ThreadList } from "@/components/forum/ThreadList";
import type { ForumViewer, ThreadCard } from "@/lib/forum";
import { forumGet } from "@/lib/forumServer";
export const metadata = { title: "Követett szálak", robots: { index: false } };
/** The threads the member follows (their own and the ones they replied to), with what is new. */
export default async function FollowedPage() {
const res = await forumGet<{ viewer: ForumViewer; threads: ThreadCard[] }>("/v1/forum/followed");
if (!res.ok) redirect("/belepes?vissza=/forum/kovetett");
const { threads } = res.data;
return (
<div className="fh">
<h1 className="fpage-title">Követett szálak</h1>
<p className="muted">A saját szálaid, azok, amelyekhez hozzászóltál, és amelyeket követni kezdtél.</p>
{threads.length === 0 ? (
<p className="fh-card fh-empty">Még nem követsz egy szálat sem.</p>
) : (
<div className="fh-card fh-flush">
<ThreadList threads={threads} />
</div>
)}
</div>
);
}
@@ -0,0 +1,53 @@
import type { Metadata } from "next";
import { cookies } from "next/headers";
import Link from "next/link";
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 ForumTheme, type ForumViewer } from "@/lib/forum";
import { forumEnabled, forumGet } from "@/lib/forumServer";
import "./forum.css";
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.",
};
/**
* The forum's frame: the visitor header (the logged-in one comes from the
* root layout), the forum's bar with its menu and the light/dark switch.
* Light by default; the choice lives in a cookie.
*/
export default async function ForumLayout({ children }: { children: React.ReactNode }) {
if (!forumEnabled()) notFound();
const [nav, jar] = await Promise.all([
forumGet<{ viewer: ForumViewer; followed: { new_replies: number } | null }>("/v1/forum/nav"),
cookies(),
]);
const viewer = nav.ok ? nav.data.viewer : null;
const theme: ForumTheme = jar.get(FORUM_THEME_COOKIE)?.value === "dark" ? "dark" : "light";
return (
<>
{!viewer?.logged_in && <PublicHeader current="forum" />}
<div className="forum" data-theme={theme}>
<div className="forum-inner">
<div className="forum-bar">
<Link href="/forum" className="forum-mark">
Fórum
</Link>
<ForumNav
member={viewer?.member?.nickname ?? null}
loggedIn={viewer?.logged_in ?? false}
unread={nav.ok ? (nav.data.followed?.new_replies ?? 0) : 0}
/>
<ThemeToggle initial={theme} />
</div>
<main className="forum-main">{children}</main>
</div>
</div>
</>
);
}
@@ -0,0 +1,64 @@
import Link from "next/link";
import { notFound } from "next/navigation";
import { type ModLogEntry, banText, memberHref, threadHref } from "@/lib/forum";
import { forumGet } from "@/lib/forumServer";
export const metadata = { title: "Moderálási napló", robots: { index: false } };
const ACTIONS: Record<string, string> = {
delete_post: "hozzászólást távolított el",
restore_post: "hozzászólást állított vissza",
delete_thread: "szálat távolított el",
restore_thread: "szálat állított vissza",
ban: "eltiltotta",
unban: "feloldotta az eltiltását",
lock: "lezárta a szálat",
unlock: "feloldotta a szálat",
pin: "kitűzte a szálat",
unpin: "levette a kitűzést",
};
/** Every moderation step: who, what, why (moderators only). */
export default async function ModLogPage() {
const res = await forumGet<{ entries: ModLogEntry[] }>("/v1/forum/mod/log");
if (!res.ok) notFound();
return (
<div className="fh">
<h1 className="fpage-title">Moderálási napló</h1>
{res.data.entries.length === 0 ? (
<p className="fh-card fh-empty">Még nem volt moderálás.</p>
) : (
<ul className="fh-card fh-flush fmodlog">
{res.data.entries.map((e) => (
<li key={e.id}>
<span className="hint">
{new Date(e.created_at).toLocaleString("hu-HU", { timeZone: "Europe/Budapest" })}
{e.actor_kind === "ai" && " · AI"}
</span>
<span>
<strong>{e.actor ?? "?"}</strong> {ACTIONS[e.action] ?? e.action}
{e.target && (
<>
{" "}
(<Link href={memberHref(e.target)}>{e.target}</Link>)
</>
)}
{e.thread && (
<>
{": "}
<Link href={threadHref({ id: e.thread.id, slug: "" }, e.post_id ?? undefined)}>
{e.thread.title ?? `#${e.thread.id}`}
</Link>
</>
)}
{e.until && ` · ${banText(e.until)}`}
</span>
{e.reason && <span className="hint">Ok: {e.reason}</span>}
</li>
))}
</ul>
)}
</div>
);
}
+244
View File
@@ -0,0 +1,244 @@
import Link from "next/link";
import { notFound } from "next/navigation";
import { Avatar } from "@/components/forum/Avatar";
import { ThreadList, WaitingCard } from "@/components/forum/ThreadList";
import { MoonPhaseIcon } from "@/components/MoonChip";
import { MOON_PHASES, SIGNS } from "@/lib/astro";
import { type ForumHome, ago, memberHref } from "@/lib/forum";
import { forumGet } from "@/lib/forumServer";
import { loadSky } from "@/lib/sky";
import { MOON_IN_SIGN, SIGN_IN, withArticle } from "@/lib/skyText";
import type { SkyNow } from "@/lib/types";
export const metadata = { title: { absolute: "Fórum · Sorsfonalak" } };
function TopicIcon({ slug }: { slug: string }) {
return (
<svg viewBox="0 0 24 24" aria-hidden="true" className="topic-icon">
{slug === "ami-a-szivemen-van" && (
<path d="M12 20s-7.5-4.6-7.5-10.2A4.2 4.2 0 0 1 12 7.3a4.2 4.2 0 0 1 7.5 2.5C19.5 15.4 12 20 12 20z" />
)}
{slug === "belso-utak" && (
<>
<path d="M12 12a1.2 1.2 0 1 0 1.2-1.2" />
<path d="M13.2 10.8A3.4 3.4 0 1 0 15.4 14" />
<path d="M15.4 14A5.6 5.6 0 1 1 12 6.4" />
<path d="M12 6.4a7.8 7.8 0 1 1-7.6 9.4" />
</>
)}
{slug === "egbolt-es-kepletek" && (
<>
<circle cx="12" cy="12" r="8.5" />
<path d="M12 7.5l1.2 3.3 3.3 1.2-3.3 1.2L12 16.5l-1.2-3.3L7.5 12l3.3-1.2z" />
</>
)}
{slug === "torzsasztal" && (
<>
<path d="M4.5 10h11v4.5a5 5 0 0 1-5 5h-1a5 5 0 0 1-5-5z" />
<path d="M15.5 11.5h1.3a2.4 2.4 0 0 1 0 4.8h-1.6" />
<path d="M8.5 3.5c0 1.4 1 1.6 1 3M12 3.5c0 1.4 1 1.6 1 3" />
</>
)}
{!["ami-a-szivemen-van", "belso-utak", "egbolt-es-kepletek", "torzsasztal"].includes(slug) && (
<circle cx="12" cy="12" r="8.5" />
)}
</svg>
);
}
/** "Mai égbolt": the Moon today, the same for everyone; never empty. */
function SkyCard({ sky }: { sky: SkyNow }) {
const moon = sky.moon;
const sign = moon.position.sign;
const date = new Date(sky.local_time.slice(0, 10) + "T12:00:00Z").toLocaleDateString("hu-HU", {
month: "long",
day: "numeric",
weekday: "long",
timeZone: "UTC",
});
return (
<section className="fh-card fh-sky" aria-labelledby="fh-sky-title">
<div className="fh-card-head">
<span className="eyebrow">Mai égbolt</span>
<span className="hint">{date}</span>
</div>
<div className="fh-sky-body">
<span className="fh-moon">
<MoonPhaseIcon illumination={moon.illumination} waxing={moon.waxing} />
</span>
<div className="fh-sky-text">
<h2 id="fh-sky-title">
{MOON_PHASES[moon.phase] ?? moon.phase}, <span className="sym">{SIGNS[sign]?.glyph}</span> Hold{" "}
{withArticle(SIGN_IN[sign] ?? sign)}
</h2>
<p>{MOON_IN_SIGN[sign]}</p>
</div>
</div>
<Link href="/holdnaptar" className="fh-sky-link">
Holdnaptár és a következő holdfázisok
</Link>
</section>
);
}
export default async function ForumHomePage() {
const [home, sky] = await Promise.all([forumGet<ForumHome>("/v1/forum/home"), loadSky()]);
if (!home.ok) notFound();
const { viewer, followed, topics, unanswered, hot } = home.data;
return (
<div className="fh fh-home">
<div className="fh-col fh-col-main">
{!viewer.logged_in && (
<section className="fh-card fh-intro o-1">
<h1>Fórum</h1>
<p>
Beszélgetés a spiritualitásról, az égboltról, az álmokról és arról, ami a szívedet nyomja. Itt mindenki
álnéven ír, a tempó nyugodt, és a meghallgatás fontosabb a vitánál.
</p>
<p className="hint">
Olvasni belépés nélkül is lehet. Hozzászólni és az „Ami a szívemen van” témát olvasni belépve.
</p>
<Link href="/belepes?vissza=/forum" className="btn btn-primary">
Belépés
</Link>
</section>
)}
{viewer.needs_nickname && (
<Link href="/forum/beallitasok" className="fh-banner o-2">
<span>
<strong>Válassz álnevet</strong>, hogy hozzászólhass. A valódi neved soha nem jelenik meg a fórumon.
</span>
<span aria-hidden="true">›</span>
</Link>
)}
{viewer.member?.banned && (
<p className="fh-banner fh-banner-warn o-2">
Most nem írhatsz a fórumba. A részleteket a beállításaidnál látod.
</p>
)}
{followed && followed.new_replies > 0 && (
<Link href="/forum/kovetett" className="fh-banner o-2">
<span>
<strong>{followed.new_replies} új válasz</strong> a követett szálaidban
</span>
<span aria-hidden="true">›</span>
</Link>
)}
{unanswered.length > 0 && (
<section className="fh-section o-4" aria-labelledby="fh-waiting">
<div className="fh-section-head">
<h2 id="fh-waiting">Várják a válaszod</h2>
<span className="hint">még senki nem válaszolt</span>
</div>
<div className="fh-waiting-grid">
{unanswered.map((t) => (
<WaitingCard key={t.id} thread={t} />
))}
</div>
</section>
)}
{hot.length > 0 && (
<section className="fh-section o-5" aria-labelledby="fh-hot">
<div className="fh-section-head">
<h2 id="fh-hot">Pörgős most</h2>
<span className="hint">az utóbbi 24 órában</span>
</div>
<div className="fh-card fh-flush">
<ThreadList threads={hot} />
</div>
</section>
)}
<section className="fh-section o-6" aria-labelledby="fh-topics">
<div className="fh-section-head">
<h2 id="fh-topics">Témák</h2>
</div>
<ul className="fh-card fh-flush fh-topics">
{topics.map((t) => (
<li key={t.slug}>
<Link href={t.readable ? `/forum/${t.slug}` : `/belepes?vissza=/forum/${t.slug}`} className="fh-topic">
<span className="fh-topic-icon">
<TopicIcon slug={t.slug} />
</span>
<span className="fh-topic-text">
<span className="fh-topic-name">
{t.name}
{t.visibility !== "public" && (
<svg viewBox="0 0 24 24" className="fh-lock" role="img" aria-label="Csak tagoknak">
<rect x="5" y="11" width="14" height="9" rx="2" />
<path d="M8 11V8a4 4 0 0 1 8 0v3" />
</svg>
)}
</span>
<span className="fh-topic-desc">{t.description}</span>
{t.readable && t.last && (
<span className="fh-topic-last">
{t.last.author && (
<Avatar avatar={t.last.author.avatar} size={18} online={t.last.author.online} />
)}
{t.last.author?.nickname ?? "Törölt tag"},{" "}
<time suppressHydrationWarning dateTime={t.last.at}>
{ago(t.last.at)}
</time>
</span>
)}
{!t.readable && <span className="fh-topic-last">Belépés után olvasható</span>}
</span>
{t.readable && (
<span className="fh-topic-count">
<strong>{t.thread_count ?? 0}</strong> szál
</span>
)}
{t.readable && t.new_count ? (
<span className="ft-new">{t.new_count > 99 ? "99+" : t.new_count} új</span>
) : null}
</Link>
</li>
))}
</ul>
</section>
</div>
<aside className="fh-col fh-col-side" aria-label="Oldalsáv">
{sky && (
<div className="o-3">
<SkyCard sky={sky} />
</div>
)}
{viewer.member && (
<section className="fh-card fh-me o-7" aria-label="Saját">
<div className="fh-me-head">
<Avatar avatar={viewer.member.avatar} size={48} />
<span className="fh-me-names">
<Link href={memberHref(viewer.member.nickname)} className="fa-name">
{viewer.member.nickname}
</Link>
<span className="fa-rank">{viewer.member.rank_name}</span>
</span>
</div>
<div className="fh-me-actions">
<Link href="/forum/uj" className="btn btn-primary btn-sm">
Új szál
</Link>
<Link href="/forum/beallitasok" className="btn btn-sm">
Fórumprofil
</Link>
</div>
</section>
)}
{viewer.moderator && (
<Link href="/forum/moderalas" className="fh-side-link o-8">
Moderálási napló
</Link>
)}
</aside>
</div>
);
}
@@ -0,0 +1,49 @@
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 { forumGet } from "@/lib/forumServer";
type Props = { params: Promise<{ id: string }> };
/** `123-nem-tudom-elengedni` → 123; the words after the number are only for reading. */
function threadId(param: string): number | null {
const match = /^(\d{1,15})(?:-|$)/.exec(decodeURIComponent(param));
return match ? Number(match[1]) : null;
}
async function load(param: string) {
const id = threadId(param);
if (id === null) return null;
return forumGet<ThreadPage>(`/v1/forum/threads/${id}`);
}
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 ?? "";
return {
title: thread.title,
description: open ? opening.slice(0, 160) : undefined,
alternates: { canonical: `/forum/szal/${thread.id}-${thread.slug}` },
// Members-only topics and removed threads stay out of search engines.
robots: open ? undefined : { index: false, follow: false },
};
}
export default async function ThreadPageView({ params }: Props) {
const param = (await params).id;
const res = await load(param);
if (!res) notFound();
if (!res.ok) {
if (res.status === 401) redirect(`/belepes?vissza=/forum/szal/${encodeURIComponent(param)}`);
notFound();
}
const { thread } = res.data;
const canonical = thread.slug ? `${thread.id}-${thread.slug}` : `${thread.id}`;
if (decodeURIComponent(param) !== canonical) permanentRedirect(`/forum/szal/${canonical}`);
return <ThreadView initial={res.data} />;
}
@@ -0,0 +1,89 @@
"use client";
import { useRouter } from "next/navigation";
import { useState } from "react";
import { api, errorText } from "@/lib/api";
const DURATIONS: { hours: number | null; label: string }[] = [
{ hours: 3, label: "3 óra" },
{ hours: 24, label: "1 nap" },
{ hours: 72, label: "3 nap" },
{ hours: 168, label: "1 hét" },
{ hours: 720, label: "30 nap" },
{ hours: null, label: "Végleg" },
];
/** Moderators: ban a member for a while or for good (they may still read), or lift it. */
export function BanPanel({ nickname, banned }: { nickname: string; banned: boolean }) {
const router = useRouter();
const [hours, setHours] = useState<string>("24");
const [reason, setReason] = useState("");
const [busy, setBusy] = useState(false);
const [error, setError] = useState<string | null>(null);
const path = `/forum/members/${encodeURIComponent(nickname)}/ban`;
async function act(work: () => Promise<unknown>) {
setBusy(true);
setError(null);
try {
await work();
router.refresh();
} catch (e) {
setError(errorText(e));
} finally {
setBusy(false);
}
}
return (
<details className="fban">
<summary className="btn btn-sm btn-ghost">Moderálás</summary>
<div className="fban-body">
{banned && (
<button
type="button"
className="btn btn-sm"
disabled={busy}
onClick={() => act(() => api(path, { method: "DELETE" }))}
>
Eltiltás feloldása
</button>
)}
<div className="field">
<label htmlFor="fban-hours">Eltiltás</label>
<select id="fban-hours" className="inp" value={hours} onChange={(e) => setHours(e.target.value)}>
{DURATIONS.map((d) => (
<option key={d.label} value={d.hours ?? "forever"}>
{d.label}
</option>
))}
</select>
</div>
<div className="field">
<label htmlFor="fban-reason">Indoklás (a tag látja)</label>
<input
id="fban-reason"
className="inp"
value={reason}
onChange={(e) => setReason(e.target.value)}
maxLength={300}
/>
</div>
{error && (
<p className="msg msg-error" role="alert">
{error}
</p>
)}
<button
type="button"
className="btn btn-sm btn-danger"
disabled={busy || reason.trim().length < 3}
onClick={() => act(() => api(path, { body: { hours: hours === "forever" ? null : Number(hours), reason } }))}
>
Eltiltom
</button>
</div>
</details>
);
}
@@ -0,0 +1,104 @@
import type { Metadata } from "next";
import Link from "next/link";
import { notFound } from "next/navigation";
import { Avatar } from "@/components/forum/Avatar";
import { signsText } from "@/components/forum/AuthorLine";
import { PostBody } from "@/components/forum/PostBody";
import { type MemberProfile, ago, banText, threadHref } from "@/lib/forum";
import { forumGet } from "@/lib/forumServer";
import { BanPanel } from "./BanPanel";
type Props = { params: Promise<{ nev: string }> };
async function load(nev: string) {
return forumGet<MemberProfile>(`/v1/forum/members/${encodeURIComponent(decodeURIComponent(nev))}`);
}
export async function generateMetadata({ params }: Props): Promise<Metadata> {
const res = await load((await params).nev);
return res.ok ? { title: res.data.member.author.nickname, robots: { index: false } } : { title: "Fórum" };
}
const LAST_SEEN: Record<string, string> = {
online: "Most online",
day: "Az elmúlt napban járt itt",
week: "Ezen a héten járt itt",
earlier: "Régebben járt itt",
};
/** A member's profile: what they chose to show, and their recent posts. */
export default async function MemberPage({ params }: Props) {
const res = await load((await params).nev);
if (!res.ok) notFound();
const { member, recent, viewer } = res.data;
const a = member.author;
const signs = signsText(a.signs);
const since = new Date(member.created_at).toLocaleDateString("hu-HU", { year: "numeric", month: "long" });
return (
<div className="fh fh-member">
<section className="fh-card fmember">
<div className="fmember-head">
<Avatar avatar={a.avatar} size={72} online={a.online} />
<div className="fmember-names">
<h1>{a.nickname}</h1>
<span className="fmember-badges">
<span className="fa-rank">{a.rank_name}</span>
{a.moderator && <span className="fa-badge fa-badge-mod">Moderátor</span>}
</span>
{member.last_seen && <span className="hint">{LAST_SEEN[member.last_seen]}</span>}
</div>
</div>
{signs && <p className="sym fmember-signs">{signs}</p>}
{member.bio && <PostBody text={member.bio} />}
<p className="hint">
Tag {since} óta · {member.post_count} hozzászólás · {member.thread_count} szál
</p>
{member.banned_until && (
<p className="fh-banner fh-banner-warn">
Eltiltva ({banText(member.banned_until)}).{member.ban_reason && ` Indok: ${member.ban_reason}`}
</p>
)}
{member.own && (
<Link href="/forum/beallitasok" className="btn btn-sm">
Profil szerkesztése
</Link>
)}
{viewer.moderator && !member.own && !a.moderator && (
<BanPanel nickname={a.nickname} banned={member.banned_until !== null} />
)}
</section>
<section className="fh-section" aria-labelledby="fmember-recent">
<div className="fh-section-head">
<h2 id="fmember-recent">Legutóbbi hozzászólások</h2>
</div>
{recent.length === 0 ? (
<p className="fh-card fh-empty">
Még nincs hozzászólása{viewer.logged_in ? "." : ", vagy csak belépve látható."}
</p>
) : (
<ul className="fh-card fh-flush ft-list">
{recent.map((r) => (
<li key={r.id}>
<Link href={threadHref({ id: r.thread_id, slug: r.thread_slug }, r.id)} className="ft-row">
<span className="ft-main">
<span className="ft-title">{r.thread_title}</span>
<span className="ft-excerpt">{r.excerpt}</span>
<span className="ft-meta">
{r.is_opening ? "Szálat indított" : "Hozzászólt"} · {r.topic.name} ·{" "}
<time suppressHydrationWarning dateTime={r.created_at}>
{ago(r.created_at)}
</time>
</span>
</span>
</Link>
</li>
))}
</ul>
)}
</section>
</div>
);
}
@@ -0,0 +1,166 @@
"use client";
import { useRouter } from "next/navigation";
import { useState } from "react";
import { api, errorText } from "@/lib/api";
import { EMOJI, type ForumTopic, threadHref } from "@/lib/forum";
type Intent = "listen" | "advice" | "";
export function NewThreadForm({ topics, initialTopic }: { topics: ForumTopic[]; initialTopic: string }) {
const router = useRouter();
const [topic, setTopic] = useState(initialTopic);
const listening = topics.find((t) => t.slug === topic)?.listening ?? false;
const [intent, setIntent] = useState<Intent>(listening ? "listen" : "");
const [title, setTitle] = useState("");
const [body, setBody] = useState("");
const [tray, setTray] = useState(false);
const [busy, setBusy] = useState(false);
const [error, setError] = useState<string | null>(null);
function pickTopic(slug: string) {
setTopic(slug);
const t = topics.find((x) => x.slug === slug);
if (t?.listening) setIntent("listen");
}
async function submit(e: React.FormEvent) {
e.preventDefault();
setBusy(true);
setError(null);
try {
const created = await api<{ id: number; slug: string }>("/forum/threads", {
body: { topic, title, body, intent: intent || null },
});
router.push(threadHref(created));
router.refresh();
} catch (err) {
setError(errorText(err));
setBusy(false);
}
}
return (
<form className="fnew" onSubmit={submit}>
<fieldset className="fnew-set">
<legend>Téma</legend>
<div className="fnew-topics">
{topics.map((t) => (
<label key={t.slug} className="fnew-topic">
<input
type="radio"
name="topic"
value={t.slug}
checked={topic === t.slug}
onChange={() => pickTopic(t.slug)}
/>
<span>
<strong>{t.name}</strong>
<span className="hint">{t.description}</span>
</span>
</label>
))}
</div>
</fieldset>
<fieldset className="fnew-set">
<legend>Mit szeretnél?</legend>
<div className="fnew-intents">
<label className="fnew-intent">
<input type="radio" name="intent" checked={intent === "listen"} onChange={() => setIntent("listen")} />
<span>
<strong>Csak meghallgatást kérek</strong>
<span className="hint">Nem kérek tanácsot, jólesne, ha valaki meghallgatna.</span>
</span>
</label>
<label className="fnew-intent">
<input type="radio" name="intent" checked={intent === "advice"} onChange={() => setIntent("advice")} />
<span>
<strong>Tanácsot, véleményt kérek</strong>
<span className="hint">Kíváncsi vagyok, ti mit gondoltok, mit tennétek.</span>
</span>
</label>
{!listening && (
<label className="fnew-intent">
<input type="radio" name="intent" checked={intent === ""} onChange={() => setIntent("")} />
<span>
<strong>Csak beszélgetnék</strong>
<span className="hint">Egy téma, egy gondolat, egy élmény.</span>
</span>
</label>
)}
</div>
</fieldset>
<div className="field">
<label htmlFor="fnew-title">Cím</label>
<input
id="fnew-title"
className="inp"
value={title}
onChange={(e) => setTitle(e.target.value)}
maxLength={120}
required
placeholder="Miről szeretnél beszélgetni?"
/>
</div>
<div className="field">
<label htmlFor="fnew-body">Az első hozzászólás</label>
<textarea
id="fnew-body"
className="fc-text"
rows={8}
value={body}
onChange={(e) => setBody(e.target.value)}
maxLength={10000}
required
placeholder={intent === "listen" ? "Írd le, ami benned van…" : "Írd le a gondolataidat…"}
/>
<div className="fc-actions">
<button
type="button"
className="fc-icon-btn"
aria-label="Emoji"
aria-expanded={tray}
onClick={() => setTray((t) => !t)}
>
<svg viewBox="0 0 24 24" aria-hidden="true">
<circle cx="12" cy="12" r="9" />
<path d="M8.5 14.5a4 4 0 0 0 7 0" />
<path d="M9 9.5h.01M15 9.5h.01" strokeWidth="2.6" />
</svg>
</button>
<span className="hint">
Szöveg és emoji. Képet és videót nem lehet beilleszteni, a linkek sima szövegként látszanak.
</span>
</div>
{tray && (
<div className="fc-tray" role="group" aria-label="Emoji">
{EMOJI.map((em) => (
<button
key={em}
type="button"
className="fc-emoji"
onClick={() => setBody((b) => b + em)}
aria-label={`${em} beszúrása`}
>
{em}
</button>
))}
</div>
)}
</div>
{error && (
<p className="msg msg-error" role="alert">
{error}
</p>
)}
<button type="submit" className="btn btn-primary" disabled={busy || !title.trim() || !body.trim() || !topic}>
{busy ? "Küldés…" : "Szál indítása"}
</button>
</form>
);
}
@@ -0,0 +1,33 @@
import { redirect } from "next/navigation";
import type { ForumTopic, ForumViewer } from "@/lib/forum";
import { forumGet } from "@/lib/forumServer";
import { NewThreadForm } from "./NewThreadForm";
export const metadata = { title: "Új szál", robots: { index: false } };
type Props = { searchParams: Promise<{ tema?: string }> };
/** Starting a thread: a nickname first, then topic, wish, title and text. */
export default async function NewThreadPage({ searchParams }: Props) {
const { tema } = await searchParams;
const back = `/forum/uj${tema ? `?tema=${encodeURIComponent(tema)}` : ""}`;
const res = await forumGet<{ topics: ForumTopic[] }>("/v1/forum/topics");
const nav = await forumGet<{ viewer: ForumViewer }>("/v1/forum/nav");
const viewer = nav.ok ? nav.data.viewer : null;
if (!viewer?.logged_in) redirect(`/belepes?vissza=${encodeURIComponent(back)}`);
if (viewer.needs_nickname) redirect(`/forum/beallitasok?vissza=${encodeURIComponent(back)}`);
const topics = res.ok ? res.data.topics.filter((t) => t.readable) : [];
const initial = topics.find((t) => t.slug === tema)?.slug ?? topics[0]?.slug ?? "";
return (
<div className="fh">
<h1 className="fpage-title">Új szál</h1>
{viewer.member?.banned ? (
<p className="fh-banner fh-banner-warn">Most nem írhatsz a fórumba.</p>
) : (
<NewThreadForm topics={topics} initialTopic={initial} />
)}
</div>
);
}