Port upstream PR #22 + Lite style updates:
- lib/audit.js: server-side logAudit(req, action, userId), records
IP from x-forwarded-for / cf-connecting-ip
- login/register/create_post/create_reply record server-side
- Remove client logEvent calls (AppProvider/NewPost/ReplyList)
- Remove forgeable POST /api/event-logs endpoint
- CustomPage: fullscreen immersive (fixed, 100vh-nav, mobile 56px
nav offset) matching upstream Lite
- reply_to_id UUID FK: precise parent tracking (username was ambiguous
when same user wrote multiple replies in a chain)
- GET /api/replies: JOIN replies + users to return reply_to_username
- POST /api/replies: accept reply_to_id (UUID) instead of reply_to_username
- Frontend depth calc: follow reply_to_id chain (not username)
- Preview bar: resolve username from local replies by ID
- Indicator scroll: target by data-reply-id
- Replies: compute nesting depth via reply_to_username chain (depth
tracking, max 5 levels, 18px indent per level)
- Post detail card: add border-radius var(--radius)
- Reply preview bar: cleaner bottom-border style (no blue box)
- Replies with a reply_to target get left-border + indent (Discourse
thread feel) via :has() selector
- Reply-box preview bar: removed blue box, now a clean bottom-border
row (回复 @user + 取消 button)
- reply-to indicator: left border line, primary on hover
- Works in light & dark mode (uses --border/--text-light vars)
- Reply button: always visible (opacity 0.5), only icon (no text),
hover → full opacity + primary color
- Works on own replies (no restriction on replying to self)
- Removed .reply-item:hover .reply-btn (was requiring parent hover)
- Each reply shows a 回复 button on hover (always visible on touch)
- Click: sets '正在回复 @user' banner, smooth-scrolls to reply box,
focuses textarea; 取消 clears it
- New reply icon (corner-up-left); clear replyTo after submit
- Reply markdown already rendered via renderMarkdown (sanitized)
- /api/users: mark is_super for the earliest-registered admin (matches
the auto-promotion migration semantics)
- AdminUsers: render 超级管理员 badge for is_super, 管理员 otherwise
- i18n keys admin.user.roleSuper (zh/en)
- Mobile settings nav: active tab gets top-left/top-right rounded
corners only (desktop unchanged)
Root becomes flex column (header fixed, layout flex:1); scroll
container uses flex:1 + minHeight:0 instead of fixed height:70vh so
portrait/phone screens get full remaining height instead of a short
squished panel.
- layout (server): derive language from cookie (user choice) > browser
Accept-Language; set <html lang> accordingly
- I18nInit → I18nProvider: sync initI18n(lng) before children render
(SSR/CSR first render same language, no hydration mismatch)
- setAppLanguage also writes cookie so SSR first paint uses chosen lang
- Verified: en browser → lang=en, zh → zh-CN, cookie overrides
- PostDetail: replies open as drawer (grid-rows animation) automatically
after post loads — no toggle button
- SettingsPage: outer frame overflow hidden (100vh), only inner panel
scrolls; hide #app layout when not on feed (fixes navbar moving when
scrolling settings)
- Title: metadata 'Loading...' → 'Forumlify' (Next resets <title> to
metadata on re-render → title became Loading... after load); unify
title effect (rotate Loading. only while !ready && !forumNameLoaded)
- AdminLinks: link divider uses var(--border) (was #f1f5f9, invisible
in dark mode); add admin.link i18n keys
- AdminPage i18n nav labels
HomeClient rendered className='app-container' but globals.css only
defines #app (flex) — sidebar/feed fell back to block layout, feed
pushed below. Switch to id='app' to match upstream stylesheet.
Also: AdminPage i18n (nav labels + title).
Root cause of loading spinner restarting / name appearing twice:
React hydration mismatch → whole tree regenerated. Fixed all sources:
- AppProvider: remove typeof window in useState init (SSR/client diff);
read cached forum name in useEffect instead
- ToastProvider: remove createPortal(document.body) (SSR absent →
mismatch)
- LoadingScreen: name container uses dangerouslySetInnerHTML('') so
React never manages/clobbers the inline-script-filled text
- layout.js: inline script moved to body first child (React official
anti-FOUC pattern)
Cache: dynamic pages/API no-cache + ETag (304 on revalidate); static
/_next/static assets immutable 1y. Verified: 304 + immutable headers.
Inline script fills cached name into #loadingTitle before React
hydrate; React then saw text mismatch and rewrote the DOM, making the
name appear twice and restarting the spinner animation. Add
suppressHydrationWarning so React keeps the script-filled content.
Loading screen now always renders the title container; layout.js inline
script fills the cached name on DOMContentLoaded (before React hydrate),
so 2nd+ visits show the forum name immediately instead of waiting for
React to start. Static appear class avoids hydrate clobbering.
- GET /api/users/profile/:username public endpoint (no auth) for user
pages, matching upstream main; UserProfile uses it (was admin /users
search)
- Settings page: vertical scroll-snap panels (profile/security/recovery),
swipe up/down to switch smoothly; sidebar nav scrolls to panel and
active highlight follows scroll position
- forumNameLoaded initializes true when localStorage has a cached name,
so 2nd+ visits show the name right away instead of waiting for the
settings fetch
- layout.js inline script writes cached name to <title> on first paint
(first request HTML now carries the name)
- getTheme: manual localStorage override first, else prefers-color-scheme
- layout: inline head script sets data-theme before first paint (no
white flash in dark mode on loading screen)
- AppProvider: listen for system theme change when user hasn't overridden
Modal rendered inside SettingsPage .page-slide whose slideIn animation
creates a containing block, so position:fixed modal was positioned
relative to the slide (invisible in some browsers). Render via
createPortal to document.body.
- PostDetail edit modal: show existing images with delete button, upload
new images (multi-file, 5MB limit), save replaces image list
- API PUT /posts/:id accepts images array; omitting keeps original
- lib/api updatePost passes images
- NewPost/ReplyList captcha answer input: use CSS vars (was hardcoded
#e2e8f0 border with white bg — glaring in dark mode)
- LoadingScreen: remove 🌊 logo; show forum name only after server
responds (fades in place), delayed 650ms before switching to home
- AppProvider: new forumNameLoaded flag; title rotation already handled
- settings API: always returns forum_name (inserts default if missing)
- AdminForumSettings: name input starts empty, fills after fetch
- PostDetail: add id=pagePost so #pagePost .post-detail-card styles
apply (border-radius/shadow were missing)
- LoadingScreen: drop forumName title (default name flashed on first
visit before settings loaded); show 🌊 logo + spinner instead
- AppProvider: during init rotate document.title Loading. → Loading..
→ Loading... every second; after ready show actual forum name
- layout: initial metadata title is 'Loading...' (client takes over)
document.title was only set inside updateForumName (the rename action).
On page reload the cached/loaded forumName never synced to the title, so
the tab stayed 'Forumlify' (server-rendered). Add a useEffect on
forumName that syncs document.title + <title> element, covering init,
DB load and rename paths.
- AppProvider: add 'ready' flag set after init (auth restore + settings)
- page.js: show LoadingScreen (spinner + forum name) until ready, then
fade in main UI (.app-fade-in 0.4s) — no more unloaded UI flash
Feed, PostDetail and ReplyList rendered ui-avatars fallback from
username only, ignoring avatar_url from the posts/replies API. Now
use p.avatar_url / r.avatar_url when present.
React synthetic event stopPropagation doesn't stop native document
listeners (React 17+ attaches to root, document listener is separate).
The document click handler was closing the menu right after avatar
opened it. Now it checks if the click target is inside the dropdown
or on the avatar and skips closing.
- Fix critical bug: useState declared after conditional return in PostDetail
caused 'Rendered more hooks than during previous render' client error
- Add image viewer (click post image to zoom, matching upstream openImageViewer)
- CSS upload warning confirm modal (matching upstream)
- Fix: navbar 消息 menu item now opens notifications page (messages), not DM
list — DM stays on the ✉️ nav button (matches upstream structure)
- Pin/unpin posts (PUT /api/posts/:id/pin, admin) with notification to author
- is_pinned/pinned_at in schema; 📌 badge on feed + detail; admin pin button
- Edited marker (已编辑) on feed + detail; edit button + modal for authors
- Custom CSS: upload/delete API + admin tab + global loader (style.css override)
- Fix: duplicate post title on detail page (remove card title, keep header)
- Fix: forum name flicker on load (localStorage cache before fetch)
- Fix: dropdown menu closes on outside click (document listener)
- Fix: document.title + <title> sync on forum rename
- Remove flex wrapper around Navbar that collapsed it to content width
- Move DM button inside Navbar nav-right, ChatManager renders modals only
- Navbar is a direct body child again, sticky + full width restored