cc158d3819
Reescritura completa del frontend Next.js del sistema visual Tailwind "simulado" al tema Django original (nw-ryu), para paridad pixel con la web actual antes del cutover. - Tema real: copia de static/nw-themes/nw-ryu + favicons a public/, el layout carga el novavow-style.css real de ultimo (gana la cascada sobre Tailwind) + Font Awesome. - Shell replicando los partials Django: SiteHeader, Video, Social, Footer, ServerClock; home con estructura real (main-page/middle-content/...). - Helpers reutilizables: PageShell (main-page > middle-content > body-content > title-content) y ServiceBox (title-box-content + back-to-account). - Paginas migradas a clases reales del tema (fieldset/tool-button/char-box/ item-box/info-box-light/max-center-table/alert-message/botones reales), eliminando el markup Tailwind (.nw-btn/.nw-card/.nw-input): auth (login/register/recover/reset/select-account/activate), cuenta + servicios de personaje (revive/unstuck/rename/customize/ change-race/change-faction/level-up/gold/transfer + pago Stripe), ajustes (change-password/change-email/security-token), comunidad (vote-points/recruit/battlepay), foro completo, y admin (indice + 7 secciones + los Admin*Manager). - Se conserva el bilingue (next-intl); claves nuevas en messages/es|en.json. Verificado: typecheck + build OK; rutas protegidas 307->login; sin MISSING_MESSAGE; cero Tailwind residual (solo .nw-tool-btn/.nw-page, clases propias en globals.css). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
108 lines
4.0 KiB
TypeScript
108 lines
4.0 KiB
TypeScript
import { notFound } from 'next/navigation'
|
|
import { getTranslations, setRequestLocale } from 'next-intl/server'
|
|
import { Link } from '@/i18n/navigation'
|
|
import { getTopic, getPosts, countPosts, listForumsForMove } from '@/lib/forum'
|
|
import { getSession } from '@/lib/session'
|
|
import { forumIsModerator, canEditPost } from '@/lib/forum-perm'
|
|
import { PageShell } from '@/components/PageShell'
|
|
import { ReplyForm } from '@/components/ReplyForm'
|
|
import { PostActions } from '@/components/PostActions'
|
|
import { TopicModBar } from '@/components/TopicModBar'
|
|
import { Pagination } from '@/components/Pagination'
|
|
|
|
export const dynamic = 'force-dynamic'
|
|
|
|
const PER_PAGE = 15
|
|
|
|
export default async function TopicPage({
|
|
params,
|
|
searchParams,
|
|
}: {
|
|
params: Promise<{ locale: string; topicId: string }>
|
|
searchParams: Promise<{ page?: string }>
|
|
}) {
|
|
const { locale, topicId } = await params
|
|
setRequestLocale(locale)
|
|
const t = await getTranslations('Forum')
|
|
|
|
const id = Number(topicId)
|
|
const session = await getSession()
|
|
const isMod = await forumIsModerator(session)
|
|
const topic = await getTopic(id, isMod)
|
|
if (!topic) notFound()
|
|
const total = await countPosts(id, isMod)
|
|
const totalPages = Math.max(1, Math.ceil(total / PER_PAGE))
|
|
const page = Math.min(Math.max(1, Number((await searchParams).page) || 1), totalPages)
|
|
const posts = await getPosts(id, (page - 1) * PER_PAGE, PER_PAGE, isMod)
|
|
const moveForums = isMod ? (await listForumsForMove()).filter((f) => f.id !== topic!.forum_id) : []
|
|
const canReply = Boolean(session.username) && (!topic!.locked || isMod)
|
|
|
|
const title = (
|
|
<>
|
|
{topic!.sticky && <span className="second-yellow">[{t('pinned')}] </span>}
|
|
{topic!.locked && <span className="red-info2">[{t('locked')}] </span>}
|
|
{topic!.deleted && <span className="red-info2">[{t('deletedMark')}] </span>}
|
|
{topic!.name}
|
|
</>
|
|
)
|
|
|
|
return (
|
|
<PageShell title={title}>
|
|
<div className="box-content">
|
|
<div className="body-box-content">
|
|
<p>
|
|
<Link href="/forum">← {t('backToForum')}</Link>
|
|
</p>
|
|
<br />
|
|
|
|
{isMod && (
|
|
<TopicModBar
|
|
topicId={id}
|
|
locked={topic!.locked}
|
|
sticky={topic!.sticky}
|
|
deleted={topic!.deleted}
|
|
moveForums={moveForums}
|
|
/>
|
|
)}
|
|
|
|
{posts.map((post) => (
|
|
<div key={post.id} className="inline-div" style={{ display: 'block', opacity: post.deleted ? 0.5 : 1 }}>
|
|
<div className="lefted">
|
|
<span className="yellow-info">
|
|
<Link href={`/forum/user/${encodeURIComponent(post.poster)}`}>{post.poster}</Link>
|
|
{post.deleted && <span className="red-info2 small-font"> [{t('deletedMark')}]</span>}
|
|
</span>
|
|
{post.time && (
|
|
<span className="date third-brown small-font">
|
|
{new Date(post.time).toLocaleString(locale)}
|
|
{post.edited && <span className="grey-info2"> · {t('editedMark')}</span>}
|
|
</span>
|
|
)}
|
|
</div>
|
|
<hr />
|
|
<div className="post-content" dangerouslySetInnerHTML={{ __html: post.text }} />
|
|
{canEditPost(session, isMod, post.poster_id) && (
|
|
<PostActions postId={post.id} initialText={post.text} deleted={post.deleted} />
|
|
)}
|
|
</div>
|
|
))}
|
|
|
|
<Pagination page={page} totalPages={totalPages} hrefFor={(p) => `/forum/topic/${id}?page=${p}`} />
|
|
|
|
{canReply ? (
|
|
page === totalPages ? (
|
|
<ReplyForm topicId={id} />
|
|
) : (
|
|
<p className="separate">
|
|
<Link href={`/forum/topic/${id}?page=${totalPages}`}>{t('replyOnLastPage')}</Link>
|
|
</p>
|
|
)
|
|
) : (
|
|
!session.username && <p className="second-brown centered separate">{t('loginToPost')}</p>
|
|
)}
|
|
</div>
|
|
</div>
|
|
</PageShell>
|
|
)
|
|
}
|