Foro: reemplazar el foro anterior por el port del foro estilo FusionCMS
Se sustituye por completo el foro anterior de Next (que estaba vacío: 0 temas, 0 posts) por una adaptación del foro PHP de FusionCMS que tenía el usuario, con su estructura, sus imágenes y su estética, llevadas a Next. BASE DE DATOS (acore_web), esquema idéntico al original (sql/forum_fusion.sql): forum_categories(id, order, name) forum_forums(id, category, order, name, description, icon, colortitle, type) forum_topics(id, forum, name, sticky, locked, deleted, created) forum_posts(id, topic, poster, text, time, deleted) Se hizo DROP de las tablas antiguas (forums, forum_categories, forum_topics, forum_posts) y CREATE de estas, con el seed original (News/Reports/General, foros con icono, clases con color, subforos por idioma con bandera). Única diferencia con el dump: forum_topics.created, que faltaba y usan las vistas, y el recorte del salto de línea final en los nombres de clase. Los temas no guardan autor ni última actividad: se derivan del primer/último post, como en el original. `poster` es el AccountID de acore_auth; el nombre se resuelve al render (username sin el sufijo #N de Battle.net). El texto se guarda como HTML saneado con nh3 (no BBCode) para encajar con el editor. EDITOR: TinyMCE community self-hosted (licenseKey gpl), servido desde /tinymce (scripts/copy-tinymce.mjs en postinstall; public/tinymce en .gitignore por ser artefacto). El HTML se sanea SIEMPRE en el servidor. PÁGINAS (app/[locale]/forum): índice con los 3 tipos de foro (fila normal, tarjeta de clase tipo 1, tarjeta de idioma tipo 2), subforo, tema, crear y editar. La lógica de forum.js (crear/responder/editar/moderar) se portó a fetch + los avisos del sitio, sin jQuery/SweetAlert, y la moderación pasa por POST (no GET). CSS: forum.css adaptado al tema (app/forum.css), rutas de imagen a /forum, dorado alineado al acento del sitio (#d79602), y se aportan .nice_button/.main-wide/ .pagination que no estaban en theme.css. ADMIN: lib/admin-forum.ts, sus rutas y AdminForumManager reescritos al esquema nuevo (categoría, icono, color, tipo, orden; sin _en/visibility). Se eliminan /forum/search y /forum/user (no existen en el foro nuevo) y los componentes que quedaban huérfanos (ForumSearchBox, PostActions, TopicModBar, NewTopicForm). i18n ES/EN completado (next-intl). Verificado en producción: el índice renderiza en es/en con categorías, clases, banderas e iconos; los assets y TinyMCE sirven 200; crear tema y responder guardan las filas con el esquema correcto y las páginas las muestran (autor resuelto, HTML saneado). Datos de prueba borrados: el foro arranca vacío. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,95 +0,0 @@
|
||||
'use client'
|
||||
|
||||
import { useState } from 'react'
|
||||
import { useTranslations } from 'next-intl'
|
||||
import { useRouter } from '@/i18n/navigation'
|
||||
|
||||
export function TopicModBar({
|
||||
topicId,
|
||||
locked,
|
||||
sticky,
|
||||
deleted = false,
|
||||
moveForums = [],
|
||||
}: {
|
||||
topicId: number
|
||||
locked: boolean
|
||||
sticky: boolean
|
||||
deleted?: boolean
|
||||
moveForums?: { id: number; name: string }[]
|
||||
}) {
|
||||
const t = useTranslations('Forum')
|
||||
const router = useRouter()
|
||||
const [busy, setBusy] = useState(false)
|
||||
|
||||
async function act(action: string, extra?: Record<string, unknown>, confirmMsg?: string) {
|
||||
if (busy) return
|
||||
if (confirmMsg && !confirm(confirmMsg)) return
|
||||
setBusy(true)
|
||||
try {
|
||||
const res = await fetch('/api/forum/moderate', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
credentials: 'same-origin',
|
||||
body: JSON.stringify({ topicId, action, ...extra }),
|
||||
})
|
||||
const data: { success?: boolean; forumId?: number } = await res.json()
|
||||
if (data.success && action === 'delete' && data.forumId) {
|
||||
router.push(`/forum/${data.forumId}`)
|
||||
} else if (data.success && action === 'move') {
|
||||
router.push(`/forum/${extra?.forumId}`)
|
||||
} else {
|
||||
router.refresh()
|
||||
}
|
||||
} finally {
|
||||
setBusy(false)
|
||||
}
|
||||
}
|
||||
|
||||
if (deleted) {
|
||||
return (
|
||||
<div className="info-box-light separate">
|
||||
<span className="red-info2">{t('deletedMark')}</span>{' '}
|
||||
<button type="button" onClick={() => act('restore')} disabled={busy} className="ns-tool-btn green-info">
|
||||
{t('restoreTopic')}
|
||||
</button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="info-box-light separate">
|
||||
<span className="yellow-info">{t('moderation')}:</span>{' '}
|
||||
<button type="button" onClick={() => act(locked ? 'unlock' : 'lock')} disabled={busy} className="ns-tool-btn">
|
||||
{locked ? t('unlock') : t('lock')}
|
||||
</button>{' '}
|
||||
<button type="button" onClick={() => act(sticky ? 'unsticky' : 'sticky')} disabled={busy} className="ns-tool-btn">
|
||||
{sticky ? t('unpin') : t('pin')}
|
||||
</button>{' '}
|
||||
{moveForums.length > 0 && (
|
||||
<select
|
||||
defaultValue=""
|
||||
disabled={busy}
|
||||
onChange={(e) => {
|
||||
const forumId = Number(e.target.value)
|
||||
e.target.value = ''
|
||||
if (forumId) act('move', { forumId })
|
||||
}}
|
||||
style={{ width: 'auto' }}
|
||||
aria-label={t('moveTopic')}
|
||||
>
|
||||
<option value="" disabled>
|
||||
{t('moveTopic')}…
|
||||
</option>
|
||||
{moveForums.map((f) => (
|
||||
<option key={f.id} value={f.id}>
|
||||
{f.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
)}{' '}
|
||||
<button type="button" onClick={() => act('delete', undefined, t('confirmDeleteTopic'))} disabled={busy} className="ns-tool-btn red-info2">
|
||||
{t('deleteTopic')}
|
||||
</button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user