Forum: whom a reply answers, icon badges, the new features on the pages

- Replies stay two levels deep, but a reply to a reply says whom it is
  for ("↪ Holdfény"): posts.reply_to_id.
- The question stands apart on its own card; the listening reminder above
  the reply box is gone.
- Every rank and badge has its own line icon (Vándor, Kereső, Fonó,
  Csillagfonó, Sorsfonó; Moderátor, Meghallgató, Támogató, Szálindító).
- Pages for the new features: own avatar upload and the moderator's reset,
  the listener and supporter switches, mention and weekly summary e-mails
  (the weekly one off by default), "@" suggestions and mention links, the
  daily sky thread by "Sorsfonalak", "Most itt vannak", joining restricted
  topics, and the moderators' Témák tab (requests; topics for the admin).
- Members-only topics say so to members too.
- The privacy notice (HU, EN) and point 8.1 of the terms cover own
  pictures, badges, mentions, restricted topics and the weekly summary;
  the data export and account deletion include them.

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 13:02:38 +00:00
co-authored by Claude Opus 5.5
parent 564c22176f
commit 8bc426460d
28 changed files with 1112 additions and 100 deletions
@@ -49,9 +49,15 @@ export default async function TopicPageView({ params, searchParams }: Props) {
<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.
{topic.visibility !== "public" && (
<p className="ftopic-private">
<svg viewBox="0 0 24 24" aria-hidden="true">
<rect x="5" y="11" width="14" height="9" rx="2" />
<path d="M8 11V8a4 4 0 0 1 8 0v3" />
</svg>
{topic.visibility === "members"
? "Ezt a témát csak belépett tagok látják: amit itt írsz, kívülről és a keresőkből nem olvasható."
: "Zárt kör: ezt a témát csak a jóváhagyott tagjai látják."}
</p>
)}
</div>
@@ -26,8 +26,19 @@ export function ProfileForm({ me, back }: { me: ForumMe; back: string | null })
const [share, setShare] = useState<ChartShare>(member?.chart_share ?? "none");
const [invisible, setInvisible] = useState(member?.invisible ?? false);
const [email, setEmail] = useState<EmailSettings>(
member?.email ?? { replies: "daily", followed: "off", messages: "instant" },
member?.email ?? {
replies: "daily",
followed: "off",
messages: "instant",
mentions: "instant",
listener: "off",
weekly: false,
},
);
const [listener, setListener] = useState(member?.listener ?? false);
const [supporter, setSupporter] = useState(member?.supporter_badge ?? false);
const [uploading, setUploading] = useState(false);
const uploaded = avatar.startsWith("upload:");
const [busy, setBusy] = useState(false);
const [error, setError] = useState<string | null>(null);
const [saved, setSaved] = useState(false);
@@ -55,7 +66,16 @@ export function ProfileForm({ me, back }: { me: ForumMe; back: string | null })
try {
const res = await api<ForumMe>("/forum/me", {
method: "PUT",
body: { nickname, avatar: avatar || null, bio, chart_share: share, invisible, email },
body: {
nickname,
avatar: avatar || null,
bio,
chart_share: share,
invisible,
email,
listener,
supporter_badge: supporter,
},
});
if (back) {
router.push(back);
@@ -135,6 +155,47 @@ export function ProfileForm({ me, back }: { me: ForumMe; back: string | null })
)}
</div>
{!avatar && <span className="hint">Ha nem választasz, az álneved alapján kapsz egyet.</span>}
{member?.can_upload_avatar && (
<div className="fprof-upload">
{uploaded && <Avatar avatar={avatar} size={56} />}
<label className="btn btn-sm fprof-upload-btn">
{uploading ? "Feltöltés…" : uploaded ? "Másik kép" : "Saját kép feltöltése"}
<input
type="file"
accept="image/jpeg,image/png,image/webp"
className="sr-only"
disabled={uploading}
onChange={async (e) => {
const file = e.target.files?.[0];
e.target.value = "";
if (!file) return;
setUploading(true);
setError(null);
try {
const res = await fetch("/api/v1/forum/me/avatar", {
method: "PUT",
body: file,
headers: { "content-type": file.type || "application/octet-stream" },
credentials: "same-origin",
});
const data = await res.json().catch(() => null);
if (!res.ok) throw new Error(data?.error?.message ?? "A feltöltés nem sikerült.");
setAvatar(data.avatar);
router.refresh();
} catch (err) {
setError(err instanceof Error ? err.message : errorText(err));
} finally {
setUploading(false);
}
}}
/>
</label>
<span className="hint">
JPEG, PNG vagy WebP, legfeljebb 8 MB. Négyzetre vágjuk és kicsinyítjük, a kép adatait (hely, gép)
eltávolítjuk. Ha egy kezdő avatart választasz, a saját kép törlődik.
</span>
</div>
)}
</fieldset>
<div className="field">
@@ -183,6 +244,31 @@ export function ProfileForm({ me, back }: { me: ForumMe; back: string | null })
</span>
</label>
{member?.can_listen && (
<label className="fprof-check">
<input type="checkbox" checked={listener} onChange={(e) => setListener(e.target.checked)} />
<span>
<strong>Önkéntes meghallgató vagyok</strong>
<span className="hint">
A nevem mellett megjelenik a „Meghallgató” jelvény, és a menü jelzi, ha egy meghallgatást kérő szál válasz
nélkül vár. E-mailt is kérhetsz róla lent.
</span>
</span>
</label>
)}
{me.can_supporter && (
<label className="fprof-check">
<input type="checkbox" checked={supporter} onChange={(e) => setSupporter(e.target.checked)} />
<span>
<strong>Támogató jelvény</strong>
<span className="hint">
Vásároltál csomagot: ha szeretnéd, a neved mellett megjelenik a „Támogató” jelvény. Rangot nem ad.
</span>
</span>
</label>
)}
<fieldset className="fnew-set">
<legend>Értesítések e-mailben</legend>
<div className="fprof-mail">
@@ -217,7 +303,42 @@ export function ProfileForm({ me, back }: { me: ForumMe; back: string | null })
<option value="instant">Azonnal</option>
<option value="off">Ne küldjetek</option>
</select>
<label htmlFor="fprof-mail-mentions">Ha valaki megemlít (@{nickname || "álnév"})</label>
<select
id="fprof-mail-mentions"
className="inp"
value={email.mentions}
onChange={(e) => setEmail({ ...email, mentions: e.target.value as EmailSettings["mentions"] })}
>
<option value="instant">Azonnal</option>
<option value="off">Ne küldjetek</option>
</select>
{listener && (
<>
<label htmlFor="fprof-mail-listener">Meghallgatóként: ha egy szál két órája válasz nélkül vár</label>
<select
id="fprof-mail-listener"
className="inp"
value={email.listener}
onChange={(e) => setEmail({ ...email, listener: e.target.value as EmailSettings["listener"] })}
>
<option value="off">Ne küldjetek</option>
<option value="instant">Azonnal (hat óránként legfeljebb egy levél)</option>
</select>
</>
)}
</div>
<label className="fprof-check fprof-check-plain">
<input
type="checkbox"
checked={email.weekly}
onChange={(e) => setEmail({ ...email, weekly: e.target.checked })}
/>
<span>
<strong>Heti összefoglaló</strong>
<span className="hint">Vasárnap este: a hét legélénkebb szálai, és ami még válaszra vár.</span>
</span>
</label>
<span className="hint">
Ha éppen itt vagy a fórumon, nem küldünk levelet: a menü jelzi az újdonságot. A privát üzenetek szövege nem
kerül bele a levélbe.
+63 -1
View File
@@ -154,6 +154,14 @@ body:has(.forum[data-theme="light"]) .site-footer { background: #0d1220; }
.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-rank, .fa-badge { display: inline-flex; align-items: center; gap: 3px; line-height: 18px; white-space: nowrap; }
.fa-icon {
width: 12px; height: 12px; flex: none; fill: none; stroke: currentColor; stroke-width: 2;
stroke-linecap: round; stroke-linejoin: round;
}
.fa-badge-new .fa-icon { display: none; }
/* The higher ranks: a golden icon. */
.fa-rank-fono .fa-icon, .fa-rank-csillagfono .fa-icon, .fa-rank-sorsfono .fa-icon { color: var(--gold); }
.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; }
@@ -333,7 +341,13 @@ body:has(.forum[data-theme="light"]) .site-footer { background: #0d1220; }
.fp-content { grid-area: body; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.fp-actions { grid-area: actions; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.fp-report { grid-area: report; }
.fp-opening { padding-top: 10px; padding-bottom: 14px; }
/* The question (the opening post) stands apart: a card; the replies sit on the page. */
.fp.fp-opening {
margin: 6px 0 10px; padding: 16px 18px 14px; border: 1px solid var(--line); border-radius: 16px;
background: var(--panel);
}
.forum[data-theme="light"] .fp.fp-opening { box-shadow: 0 1px 3px rgba(27, 34, 54, 0.06); }
.fp-opening .fp-body { font-size: 17px; }
.fp-opening .fp-names .fa-name { font-size: 16px; }
.ftv-children .fp:last-child { border-bottom: 0; }
.fp-nested { padding: 8px 0; row-gap: 4px; }
@@ -543,3 +557,51 @@ body:has(.forum[data-theme="light"]) .site-footer { background: #0d1220; }
@media (prefers-reduced-motion: reduce) { .ftyping-dots span { animation: none; opacity: 0.6; } }
.fp-link { min-height: 32px; 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); }
/* --- whom a reply answers, mentions, badges --- */
.fp-replyto { display: inline-flex; align-items: center; gap: 3px; font-size: 13px; color: var(--muted); }
.fp-replyto svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.fp-mention { color: var(--gold); font-weight: 500; text-decoration: none; background: var(--f-tint); border-radius: 4px; padding: 0 2px; }
.fp-mention:hover { color: var(--gold-hover); }
.fa-badge-listener { color: var(--harmonic); background: var(--f-blue-tint); }
.fa-badge-supporter { color: var(--gold); background: var(--f-tint); }
/* --- own pictures and the site's mark --- */
.av-picture img { display: block; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.av-site { --av-bg: #1c2540; }
.av-site-mark { stroke: #d9b46a; }
.forum[data-theme="light"] .av-site { --av-bg: #f5ead7; }
.forum[data-theme="light"] .av-site-mark { stroke: #8a6a24; }
/* --- "@" suggestions while typing --- */
.fc-suggest {
display: flex; flex-direction: column; align-self: flex-start; min-width: 220px; max-width: 320px; padding: 4px;
background: var(--panel); border: 1px solid var(--line-2); border-radius: 12px; box-shadow: var(--f-shadow);
}
.fc-suggest-item {
display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 10px; border: 0; border-radius: 8px;
background: none; color: var(--ink); font: 400 15px var(--font-body); text-align: left; cursor: pointer;
}
.fc-suggest-item:hover, .fc-suggest-item:focus-visible { background: var(--f-hover); }
/* --- who is here, restricted topics --- */
.fh-online { display: flex; flex-direction: column; gap: 10px; }
.forum .fh-online-title { font-family: var(--font-body); font-size: 15px; font-weight: 600; color: var(--ink-2); }
.fh-online-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px 12px; }
.fh-online-item { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--ink); text-decoration: none; }
a.fh-online-item:hover { color: var(--gold); }
.fh-topic-closed { flex-wrap: wrap; }
.fjoin { flex-basis: 100%; display: flex; flex-direction: column; gap: 8px; }
/* --- profile form extras, the topics tab --- */
.fprof-upload { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 6px; }
.fprof-upload-btn { cursor: pointer; }
.fprof-check-plain { border: 0; padding: 6px 0 0; background: none; }
.fmodlog li.ftop-member { flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.ftop-vis { width: auto; min-height: 36px; }
/* --- members-only and restricted topics: said plainly, also to members --- */
.ftopic-private { display: flex; align-items: flex-start; gap: 8px; font-size: 14px; color: var(--ink-2); }
.ftopic-private svg, .ftv-private svg { width: 15px; height: 15px; flex: none; margin-top: 2px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.ftv-private { display: inline-flex; align-items: center; gap: 4px; margin-left: 4px; font-size: 13px; color: var(--muted); }
.ftv-private svg { margin-top: 0; width: 13px; height: 13px; }
@@ -45,6 +45,7 @@ export default async function ForumLayout({ children }: { children: React.ReactN
unread: nav.ok ? (nav.data.followed?.new_replies ?? 0) : 0,
messages: nav.ok ? (nav.data.messages ?? 0) : 0,
reports: nav.ok ? (nav.data.reports ?? 0) : 0,
waiting: nav.ok ? (nav.data.waiting ?? 0) : 0,
}}
wsUrl={process.env.FORUM_WS_URL || "/api/v1/forum/ws"}
/>
@@ -0,0 +1,238 @@
"use client";
import { useRouter } from "next/navigation";
import { useState } from "react";
import { Avatar } from "@/components/forum/Avatar";
import { RankBadge } from "@/components/forum/Badges";
import { api, errorText } from "@/lib/api";
import { type ForumTopic, type TopicRequest, ago } from "@/lib/forum";
const VISIBILITY: Record<string, string> = {
public: "Nyilvános (a keresők is látják)",
members: "Csak tagoknak",
restricted: "Zárt (jóváhagyással)",
};
/** Moderators: requests to join restricted topics. Admins also: opening and editing topics. */
export function TopicsAdmin({
requests,
topics,
admin,
}: {
requests: TopicRequest[];
topics: ForumTopic[];
admin: boolean;
}) {
const router = useRouter();
const [busy, setBusy] = useState(false);
const [error, setError] = useState<string | null>(null);
const [form, setForm] = useState({ name: "", description: "", visibility: "restricted", listening: false });
async function act(work: () => Promise<unknown>) {
setBusy(true);
setError(null);
try {
await work();
router.refresh();
} catch (e) {
setError(errorText(e));
} finally {
setBusy(false);
}
}
const decide = (r: TopicRequest, action: "approve" | "reject" | "remove") =>
act(() =>
api("/forum/mod/topic-requests", {
body: { topic: r.topic.slug, nickname: r.member?.nickname ?? "", action },
}),
);
const pending = requests.filter((r) => r.status === "pending");
const approved = requests.filter((r) => r.status === "approved");
return (
<>
{error && (
<p className="msg msg-error" role="alert">
{error}
</p>
)}
<section className="fh-section" aria-labelledby="ftop-pending">
<h2 id="ftop-pending" className="fmsg-h">
Jelentkezések zárt témákba ({pending.length})
</h2>
{pending.length === 0 ? (
<p className="fh-card fh-empty">Nincs várakozó jelentkezés.</p>
) : (
pending.map((r) => (
<article key={`${r.topic.slug}-${r.member?.nickname}`} className="fh-card fmod-report">
<div className="fmod-report-head">
<span className="fh-online-item">
<Avatar avatar={r.member?.avatar} size={28} />
<strong>{r.member?.nickname ?? "?"}</strong>
{r.member && <RankBadge rank={r.member.rank} name={r.member.rank_name} />}
</span>
<span className="hint">
{r.topic.name} ·{" "}
<time suppressHydrationWarning dateTime={r.requested_at}>
{ago(r.requested_at)}
</time>
</span>
</div>
{r.note && <p className="fmod-note">„{r.note}”</p>}
<div className="fmsg-actions">
<button
type="button"
className="btn btn-sm btn-primary"
disabled={busy}
onClick={() => decide(r, "approve")}
>
Jóváhagyom
</button>
<button
type="button"
className="btn btn-sm btn-ghost"
disabled={busy}
onClick={() => decide(r, "reject")}
>
Elutasítom
</button>
</div>
</article>
))
)}
</section>
{approved.length > 0 && (
<section className="fh-section" aria-labelledby="ftop-members">
<h2 id="ftop-members" className="fmsg-h">
Zárt témák tagjai
</h2>
<ul className="fh-card fh-flush fmodlog">
{approved.map((r) => (
<li key={`${r.topic.slug}-${r.member?.nickname}`} className="ftop-member">
<span className="fh-online-item">
<Avatar avatar={r.member?.avatar} size={24} />
{r.member?.nickname ?? "?"}
<span className="hint">· {r.topic.name}</span>
</span>
<button
type="button"
className="btn btn-sm btn-ghost"
disabled={busy}
onClick={() =>
window.confirm(`Eltávolítod ${r.member?.nickname} tagot a(z) „${r.topic.name}” témából?`) &&
decide(r, "remove")
}
>
Eltávolítom
</button>
</li>
))}
</ul>
</section>
)}
{admin && (
<section className="fh-section" aria-labelledby="ftop-admin">
<h2 id="ftop-admin" className="fmsg-h">
Témák (admin)
</h2>
<ul className="fh-card fh-flush fmodlog">
{topics.map((t) => (
<li key={t.slug} className="ftop-member">
<span>
<strong>{t.name}</strong> <span className="hint">· {VISIBILITY[t.visibility] ?? t.visibility}</span>
</span>
<select
className="inp ftop-vis"
aria-label={`${t.name} láthatósága`}
value={t.visibility}
disabled={busy}
onChange={(e) =>
act(() => api(`/forum/topics/${t.slug}`, { method: "PATCH", body: { visibility: e.target.value } }))
}
>
{Object.entries(VISIBILITY).map(([value, label]) => (
<option key={value} value={value}>
{label}
</option>
))}
</select>
</li>
))}
</ul>
<form
className="fh-card fnew"
onSubmit={(e) => {
e.preventDefault();
void act(async () => {
await api("/forum/topics", { body: form });
setForm({ name: "", description: "", visibility: "restricted", listening: false });
});
}}
>
<strong>Új téma</strong>
<div className="field">
<label htmlFor="ftop-name">Név</label>
<input
id="ftop-name"
className="inp"
value={form.name}
maxLength={60}
onChange={(e) => setForm({ ...form, name: e.target.value })}
required
/>
</div>
<div className="field">
<label htmlFor="ftop-desc">Rövid leírás</label>
<input
id="ftop-desc"
className="inp"
value={form.description}
maxLength={160}
onChange={(e) => setForm({ ...form, description: e.target.value })}
required
/>
</div>
<div className="field">
<label htmlFor="ftop-visibility">Láthatóság</label>
<select
id="ftop-visibility"
className="inp"
value={form.visibility}
onChange={(e) => setForm({ ...form, visibility: e.target.value })}
>
{Object.entries(VISIBILITY).map(([value, label]) => (
<option key={value} value={value}>
{label}
</option>
))}
</select>
</div>
<label className="fprof-check">
<input
type="checkbox"
checked={form.listening}
onChange={(e) => setForm({ ...form, listening: e.target.checked })}
/>
<span>
<strong>Meghallgatós téma</strong>
<span className="hint">Az új szálak alapból meghallgatást kérnek, nem tanácsot.</span>
</span>
</label>
<button
type="submit"
className="btn btn-primary"
disabled={busy || !form.name.trim() || !form.description.trim()}
>
Téma létrehozása
</button>
</form>
</section>
)}
</>
);
}
@@ -1,10 +1,20 @@
import Link from "next/link";
import { notFound } from "next/navigation";
import { type ModLogEntry, type ReportEntry, banText, memberHref, threadHref } from "@/lib/forum";
import {
type ForumTopic,
type ModLogEntry,
type ReportEntry,
type TopicRequest,
banText,
memberHref,
threadHref,
} from "@/lib/forum";
import { forumGet } from "@/lib/forumServer";
import { getMe } from "@/lib/server";
import { ReportsList } from "./ReportsList";
import { TopicsAdmin } from "./TopicsAdmin";
export const metadata = { title: "Moderálás", robots: { index: false } };
@@ -21,25 +31,35 @@ const ACTIONS: Record<string, string> = {
unpin: "levette a kitűzést",
resolve_report: "lezárt egy jelentést",
dismiss_report: "alaptalannak ítélt egy jelentést",
approve_member: "felvette egy zárt témába",
reject_member: "elutasította a jelentkezését",
remove_member: "eltávolította egy zárt témából",
reset_avatar: "eltávolította a saját képét",
topic: "témát kezelt",
};
type Props = { searchParams: Promise<{ nezet?: string }> };
/** Moderators: the open reports, and the log of every moderation step. */
export default async function ModerationPage({ searchParams }: Props) {
const log = (await searchParams).nezet === "naplo";
const view = (await searchParams).nezet;
const log = view === "naplo";
const topics = view === "temak";
return (
<div className="fh">
<h1 className="fpage-title">Moderálás</h1>
<nav className="fmod-tabs" aria-label="Moderálás">
<Link href="/forum/moderalas" aria-current={log ? undefined : "page"}>
<Link href="/forum/moderalas" aria-current={log || topics ? undefined : "page"}>
Jelentések
</Link>
<Link href="/forum/moderalas?nezet=temak" aria-current={topics ? "page" : undefined}>
Témák
</Link>
<Link href="/forum/moderalas?nezet=naplo" aria-current={log ? "page" : undefined}>
Napló
</Link>
</nav>
{log ? <LogView /> : <ReportsView />}
{log ? <LogView /> : topics ? <TopicsView /> : <ReportsView />}
</div>
);
}
@@ -50,6 +70,22 @@ async function ReportsView() {
return <ReportsList initial={res.data.reports} />;
}
async function TopicsView() {
const [requests, list, me] = await Promise.all([
forumGet<{ requests: TopicRequest[] }>("/v1/forum/mod/topic-requests"),
forumGet<{ topics: ForumTopic[] }>("/v1/forum/topics"),
getMe(),
]);
if (!requests.ok) notFound();
return (
<TopicsAdmin
requests={requests.data.requests}
topics={list.ok ? list.data.topics : []}
admin={me?.user.roles.includes("admin") ?? false}
/>
);
}
async function LogView() {
const res = await forumGet<{ entries: ModLogEntry[] }>("/v1/forum/mod/log");
if (!res.ok) notFound();
+79 -35
View File
@@ -2,6 +2,8 @@ import Link from "next/link";
import { notFound } from "next/navigation";
import { Avatar } from "@/components/forum/Avatar";
import { RankBadge } from "@/components/forum/Badges";
import { JoinTopic } from "@/components/forum/JoinTopic";
import { ThreadList, WaitingCard } from "@/components/forum/ThreadList";
import { MoonPhaseIcon } from "@/components/MoonChip";
import { MOON_PHASES, SIGNS } from "@/lib/astro";
@@ -161,47 +163,72 @@ export default async function ForumHomePage() {
<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">
{topics.map((t) =>
t.visibility === "restricted" && !t.readable ? (
<li key={t.slug}>
<div className="fh-topic fh-topic-closed">
<span className="fh-topic-icon">
<TopicIcon slug={t.slug} />
</span>
<span className="fh-topic-text">
<span className="fh-topic-name">
{t.name}
<svg viewBox="0 0 24 24" className="fh-lock" role="img" aria-label="Zárt téma">
<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>
<span className="fh-topic-last">Zárt kör: jóváhagyás után olvasható</span>
</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} />
{viewer.member && <JoinTopic slug={t.slug} pending={t.membership === "pending"} />}
</div>
</li>
) : (
<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>
)}
{t.last.author?.nickname ?? "Törölt tag"},{" "}
<time suppressHydrationWarning dateTime={t.last.at}>
{ago(t.last.at)}
</time>
</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 && <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>
))}
{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>
@@ -212,6 +239,23 @@ export default async function ForumHomePage() {
<SkyCard sky={sky} />
</div>
)}
{home.data.online.length > 0 && (
<section className="fh-card fh-online o-7" aria-labelledby="fh-online-title">
<h2 id="fh-online-title" className="fh-online-title">
Most itt vannak <span className="hint">({home.data.online.length})</span>
</h2>
<ul className="fh-online-list">
{home.data.online.map((m) => (
<li key={m.nickname}>
<Link href={memberHref(m.nickname)} className="fh-online-item">
<Avatar avatar={m.avatar} size={28} online />
<span>{m.nickname}</span>
</Link>
</li>
))}
</ul>
</section>
)}
{viewer.member && (
<section className="fh-card fh-me o-7" aria-label="Saját">
<div className="fh-me-head">
@@ -220,7 +264,7 @@ export default async function ForumHomePage() {
<Link href={memberHref(viewer.member.nickname)} className="fa-name">
{viewer.member.nickname}
</Link>
<span className="fa-rank">{viewer.member.rank_name}</span>
<RankBadge rank={viewer.member.rank} name={viewer.member.rank_name} />
</span>
</div>
<div className="fh-me-actions">
@@ -15,7 +15,7 @@ const DURATIONS: { hours: number | null; label: string }[] = [
];
/** 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 }) {
export function BanPanel({ nickname, banned, ownPicture }: { nickname: string; banned: boolean; ownPicture: boolean }) {
const router = useRouter();
const [hours, setHours] = useState<string>("24");
const [reason, setReason] = useState("");
@@ -40,6 +40,19 @@ export function BanPanel({ nickname, banned }: { nickname: string; banned: boole
<details className="fban">
<summary className="btn btn-sm btn-ghost">Moderálás</summary>
<div className="fban-body">
{ownPicture && (
<button
type="button"
className="btn btn-sm"
disabled={busy}
onClick={() =>
window.confirm("Visszaállítod a kezdő avatart? A feltöltött kép törlődik.") &&
act(() => api(`/forum/members/${encodeURIComponent(nickname)}/avatar-reset`, { method: "POST" }))
}
>
Saját kép eltávolítása
</button>
)}
{banned && (
<button
type="button"
@@ -4,6 +4,7 @@ import { notFound } from "next/navigation";
import { Avatar } from "@/components/forum/Avatar";
import { signsText } from "@/components/forum/AuthorLine";
import { Badge, RankBadge } from "@/components/forum/Badges";
import { PostBody } from "@/components/forum/PostBody";
import { type MemberProfile, ago, banText, threadHref } from "@/lib/forum";
import { forumGet } from "@/lib/forumServer";
@@ -45,8 +46,10 @@ export default async function MemberPage({ params }: Props) {
<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>}
<RankBadge rank={a.rank} name={a.rank_name} />
{a.moderator && <Badge kind="mod" />}
{a.listener && <Badge kind="listener" />}
{a.supporter && <Badge kind="supporter" />}
</span>
{member.last_seen && <span className="hint">{LAST_SEEN[member.last_seen]}</span>}
</div>
@@ -68,7 +71,11 @@ export default async function MemberPage({ params }: Props) {
</Link>
)}
{viewer.moderator && !member.own && !a.moderator && (
<BanPanel nickname={a.nickname} banned={member.banned_until !== null} />
<BanPanel
nickname={a.nickname}
banned={member.banned_until !== null}
ownPicture={a.avatar.startsWith("upload:")}
/>
)}
</section>
@@ -5,6 +5,7 @@ import { useRouter } from "next/navigation";
import { useCallback, useEffect, useRef, useState } from "react";
import { Avatar } from "@/components/forum/Avatar";
import { RankBadge } from "@/components/forum/Badges";
import { Composer } from "@/components/forum/Composer";
import { PostBody } from "@/components/forum/PostBody";
import type { LiveNotice } from "@/components/forum/ForumNav";
@@ -130,7 +131,7 @@ export function Chat({ initial }: { initial: ConversationPage }) {
) : (
<span className="fa-name muted">{other}</span>
)}
{c.other && <span className="fa-rank">{c.other.rank_name}</span>}
{c.other && <RankBadge rank={c.other.rank} name={c.other.rank_name} />}
</div>
{c.state === "accepted" && (
<details className="ftv-mod">