Wiki Phase 4: full-text search + revision history

Final phase of the wiki upgrade (see WIKI_UPGRADE.md).

Schema (additive): wiki_revisions table (per-save content snapshots).
The FULLTEXT index on wiki_pages(title, body) shipped in Phase 1.

Search:
- MATCH ... AGAINST natural-language search over title + body, ordered by
  relevance
- public: GET /public/wiki?q= (published only); admin: GET /admin/wiki?q=
  (all statuses)
- public wiki index gains a search box; admin list gains a search field

Revision history:
- every create/update snapshots the page into wiki_revisions
- admin endpoints: list revisions, get one, and restore (restore overwrites
  the page, rebuilds links, and appends a new revision — history stays
  append-only); logged as wiki.revision.restore
- editor gains a History modal: revision list + word-level diff (jsdiff) of a
  chosen revision against the current page, with one-click restore

Verified end-to-end: search matches body and title; two edits produce three
revisions; diff renders added/removed words; restore reverts and records a new
revision. No console errors.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-27 15:49:05 -05:00
parent 7c081ae749
commit 7bb992f58d
15 changed files with 492 additions and 14 deletions

View File

@@ -447,6 +447,86 @@ button[disabled] {
border-bottom: 1px dotted #d98b84;
}
/* ===== Wiki revision history ===== */
.wiki-history {
display: grid;
grid-template-columns: 240px 1fr;
gap: 18px;
align-items: start;
}
@media (max-width: 640px) {
.wiki-history {
grid-template-columns: 1fr;
}
}
.wiki-history-list {
list-style: none;
margin: 0;
padding: 0;
max-height: 360px;
overflow-y: auto;
display: flex;
flex-direction: column;
gap: 4px;
}
.wiki-rev {
display: flex;
flex-direction: column;
gap: 2px;
width: 100%;
padding: 8px 10px;
border: 1px solid var(--line);
border-radius: 8px;
background: var(--panel-flat);
color: var(--text);
text-align: left;
cursor: pointer;
}
.wiki-rev:hover {
border-color: var(--accent);
}
.wiki-rev.is-active {
border-color: var(--accent);
background: var(--blue);
}
.wiki-rev-note {
font-family: var(--sans);
font-size: 0.86rem;
color: var(--head);
}
.wiki-rev-latest {
color: var(--accent);
font-size: 0.74rem;
}
.wiki-rev-meta {
font-family: var(--sans);
font-size: 0.72rem;
color: var(--dim);
}
.wiki-diff {
white-space: pre-wrap;
word-break: break-word;
font-family: var(--sans);
font-size: 0.92rem;
line-height: 1.6;
color: var(--text);
max-height: 360px;
overflow-y: auto;
padding: 12px 14px;
border: 1px solid var(--line);
border-radius: 8px;
background: var(--bg);
}
.diff-add {
background: rgba(95, 185, 138, 0.22);
color: #b9e6cd;
}
.diff-del {
background: rgba(176, 102, 95, 0.24);
color: #e3b0aa;
text-decoration: line-through;
}
/* ===== Admin tables ===== */
.adm-table {
width: 100%;