Add niche admin + public expansions + self-host Nunito font (batches 3-4)
Built via two more parallel agent workflows (read schema -> return files), integrated + verified. Admin: /admin/emulator (emulator_settings + emulator_texts key/value editor), /admin/badges (give-badge via RCON), /admin/rare-values (CRUD), /admin/housekeeping (CRUD), /admin/email-templates (CRUD), /admin/photos (moderation). Public: /rares (+[category]), /leaderboard (credits/diamonds/duckets), /guilds (+[id] members), /redeem (voucher -> sendCurrency). Expanded: /u/[username] now shows badges + photos + guestbook (post form); /news/[slug] now shows reactions + comments (comment form). Reactions tallied in JS (Prisma groupBy typing avoided). Self-hosted Nunito via next/font/google wired to --font-nunito (the atom theme font, no runtime external fetch). Header + admin nav extended. Verified: tsc exit 0, vitest 48/48, next build exit 0.
This commit is contained in:
1 parent
e96b606e1e
commit
e8be0461d8
28 files changed
+2347
-5
No files matched your search
@@ -0,0 +1,191 @@
|
||||
import Link from "next/link";
|
||||
import { notFound } from "next/navigation";
|
||||
import { avatarImageUrl } from "@/lib/format";
|
||||
import { prisma } from "@/lib/prisma";
|
||||
import { siteSettings } from "@/lib/services/site-settings";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
type GuildView = {
|
||||
id: number;
|
||||
name: string;
|
||||
description: string;
|
||||
badge: string;
|
||||
userId: number;
|
||||
dateCreated: number;
|
||||
};
|
||||
|
||||
type MemberView = {
|
||||
userId: number;
|
||||
username: string;
|
||||
look: string;
|
||||
motto: string;
|
||||
memberSince: number;
|
||||
isOwner: boolean;
|
||||
};
|
||||
|
||||
function formatTimestamp(ts: number): string {
|
||||
if (!ts) return "";
|
||||
return new Date(ts * 1000).toISOString().slice(0, 10);
|
||||
}
|
||||
|
||||
export default async function GuildPage({
|
||||
params,
|
||||
}: {
|
||||
params: Promise<{ id: string }>;
|
||||
}) {
|
||||
const { id } = await params;
|
||||
const guildId = Number(id);
|
||||
if (!Number.isInteger(guildId) || guildId <= 0) notFound();
|
||||
|
||||
let guild: GuildView | null = null;
|
||||
try {
|
||||
guild = await prisma.guilds.findUnique({
|
||||
where: { id: guildId },
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
description: true,
|
||||
badge: true,
|
||||
userId: true,
|
||||
dateCreated: true,
|
||||
},
|
||||
});
|
||||
} catch {
|
||||
guild = null;
|
||||
}
|
||||
|
||||
if (!guild) notFound();
|
||||
|
||||
// Members come from guilds_members; there is no relation in the schema, so we
|
||||
// join the users table manually by id.
|
||||
let memberRows: { userId: number; memberSince: number }[] = [];
|
||||
try {
|
||||
memberRows = await prisma.guildsMembers.findMany({
|
||||
where: { guildId: guild.id },
|
||||
orderBy: { memberSince: "asc" },
|
||||
take: 200,
|
||||
select: { userId: true, memberSince: true },
|
||||
});
|
||||
} catch {
|
||||
memberRows = [];
|
||||
}
|
||||
|
||||
const memberIds = Array.from(
|
||||
new Set([guild.userId, ...memberRows.map((m) => m.userId)].filter((v) => v > 0)),
|
||||
);
|
||||
|
||||
let users: { id: number; username: string; look: string; motto: string }[] = [];
|
||||
try {
|
||||
users = memberIds.length
|
||||
? await prisma.user.findMany({
|
||||
where: { id: { in: memberIds } },
|
||||
select: { id: true, username: true, look: true, motto: true },
|
||||
})
|
||||
: [];
|
||||
} catch {
|
||||
users = [];
|
||||
}
|
||||
|
||||
const imagerBase = await siteSettings.get(
|
||||
"habbo_imaging_url",
|
||||
"https://www.habbo.com/habbo-imaging/avatarimage",
|
||||
);
|
||||
|
||||
const usersById = new Map(users.map((u) => [u.id, u]));
|
||||
const sinceById = new Map(memberRows.map((m) => [m.userId, m.memberSince]));
|
||||
|
||||
const members: MemberView[] = memberIds
|
||||
.map((uid) => {
|
||||
const u = usersById.get(uid);
|
||||
if (!u) return null;
|
||||
return {
|
||||
userId: u.id,
|
||||
username: u.username,
|
||||
look: u.look,
|
||||
motto: u.motto,
|
||||
memberSince: sinceById.get(uid) ?? 0,
|
||||
isOwner: uid === guild!.userId,
|
||||
};
|
||||
})
|
||||
.filter((m): m is MemberView => m !== null)
|
||||
// Owner first, then by join date.
|
||||
.sort((a, b) => {
|
||||
if (a.isOwner !== b.isOwner) return a.isOwner ? -1 : 1;
|
||||
return a.memberSince - b.memberSince;
|
||||
});
|
||||
|
||||
const created = formatTimestamp(guild.dateCreated);
|
||||
|
||||
return (
|
||||
<main>
|
||||
<p style={{ marginTop: 0 }}>
|
||||
<Link href="/guilds">← All guilds</Link>
|
||||
</p>
|
||||
|
||||
<div
|
||||
className="card"
|
||||
style={{ display: "flex", gap: "1.25rem", alignItems: "flex-start" }}
|
||||
>
|
||||
{guild.badge ? (
|
||||
// eslint-disable-next-line @next/next/no-img-element
|
||||
<img
|
||||
src={`https://habbo-stories-content.s3.amazonaws.com/badge-part-images/${guild.badge}.gif`}
|
||||
alt={`${guild.name} badge`}
|
||||
width={48}
|
||||
height={48}
|
||||
style={{ flex: "0 0 auto" }}
|
||||
/>
|
||||
) : null}
|
||||
<div style={{ minWidth: 0 }}>
|
||||
<h1 style={{ margin: "0 0 0.25rem" }}>{guild.name || "Unnamed guild"}</h1>
|
||||
<p style={{ margin: "0 0 0.5rem" }}>
|
||||
{guild.description || <span className="muted">No description</span>}
|
||||
</p>
|
||||
<p className="muted" style={{ margin: 0 }}>
|
||||
{members.length} {members.length === 1 ? "member" : "members"}
|
||||
{created ? ` · Founded ${created}` : ""}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h2 style={{ marginTop: "1.5rem" }}>Members</h2>
|
||||
{members.length === 0 ? (
|
||||
<p className="muted">No members.</p>
|
||||
) : (
|
||||
<div className="grid cols-3">
|
||||
{members.map((m) => (
|
||||
<div
|
||||
key={m.userId}
|
||||
className="card"
|
||||
style={{ display: "flex", gap: "0.85rem", alignItems: "center" }}
|
||||
>
|
||||
{/* eslint-disable-next-line @next/next/no-img-element */}
|
||||
<img
|
||||
className="avatar"
|
||||
src={avatarImageUrl(imagerBase ?? "", m.look, { size: "l" })}
|
||||
alt={`${m.username} avatar`}
|
||||
width={50}
|
||||
height={75}
|
||||
style={{ flex: "0 0 auto" }}
|
||||
/>
|
||||
<div style={{ minWidth: 0 }}>
|
||||
<h3 style={{ margin: "0 0 0.15rem" }}>
|
||||
<Link href={`/u/${m.username}`}>{m.username}</Link>
|
||||
</h3>
|
||||
{m.isOwner ? (
|
||||
<p className="muted" style={{ margin: "0 0 0.15rem" }}>
|
||||
Owner
|
||||
</p>
|
||||
) : null}
|
||||
<p className="muted" style={{ margin: 0 }}>
|
||||
{m.motto || "No motto"}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</main>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
import Link from "next/link";
|
||||
import { excerpt } from "@/lib/format";
|
||||
import { prisma } from "@/lib/prisma";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
type GuildCard = {
|
||||
id: number;
|
||||
name: string;
|
||||
description: string;
|
||||
badge: string;
|
||||
};
|
||||
|
||||
async function getGuilds(): Promise<GuildCard[]> {
|
||||
try {
|
||||
const guilds = await prisma.guilds.findMany({
|
||||
orderBy: { id: "desc" },
|
||||
take: 40,
|
||||
select: { id: true, name: true, description: true, badge: true },
|
||||
});
|
||||
return guilds;
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
export default async function GuildsPage() {
|
||||
const guilds = await getGuilds();
|
||||
|
||||
return (
|
||||
<main>
|
||||
<h1>Guilds</h1>
|
||||
{guilds.length === 0 ? (
|
||||
<p className="muted">No guilds yet.</p>
|
||||
) : (
|
||||
<div className="grid cols-3">
|
||||
{guilds.map((g) => (
|
||||
<Link
|
||||
key={g.id}
|
||||
href={`/guilds/${g.id}`}
|
||||
className="card hover"
|
||||
style={{
|
||||
display: "flex",
|
||||
gap: "0.85rem",
|
||||
alignItems: "flex-start",
|
||||
color: "inherit",
|
||||
textDecoration: "none",
|
||||
}}
|
||||
>
|
||||
{g.badge ? (
|
||||
// eslint-disable-next-line @next/next/no-img-element
|
||||
<img
|
||||
src={`https://habbo-stories-content.s3.amazonaws.com/badge-part-images/${g.badge}.gif`}
|
||||
alt={`${g.name} badge`}
|
||||
width={40}
|
||||
height={40}
|
||||
style={{ flex: "0 0 auto" }}
|
||||
/>
|
||||
) : null}
|
||||
<div style={{ minWidth: 0 }}>
|
||||
<h3 style={{ margin: "0 0 0.25rem" }}>{g.name || "Unnamed guild"}</h3>
|
||||
<p className="muted" style={{ margin: 0 }}>
|
||||
{g.description ? excerpt(g.description, 120) : "No description"}
|
||||
</p>
|
||||
</div>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</main>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user