feat(wiki): revision diff — compare any two wiki page versions #667

Closed
opened 2026-06-21 06:32:00 +00:00 by jmiller · 0 comments
Owner

Summary

Add side-by-side diff comparison between any two revisions of a wiki page, with a "revert to this version" option. Currently the revision page only shows commit history without visual diffs.

Current State

  • WikiRevision() in routers/web/repo/wiki.go shows commit history for a page via CommitsByFileAndRange()
  • templates/repo/wiki/revision.tmpl renders the commit list with author, date, and message
  • No way to see what actually changed between revisions
  • No way to revert to an older version

Proposed Changes

New Route

GET /:owner/:repo/wiki/:page?action=_diff&rev1=<sha>&rev2=<sha>

UI Changes to revision.tmpl

  • Add radio buttons / checkboxes next to each revision in the commit list
  • "Compare selected revisions" button that navigates to the diff view
  • Each individual revision gets a "View changes" link for quick diff against its parent

Diff Rendering

  • Reuse the existing diff infrastructure from templates/repo/diff/ — the same code that renders PR and commit diffs
  • Show the rendered markdown diff (before/after) and optionally the raw source diff
  • Since wiki content is stored in git, we can use git diff <sha1> <sha2> -- <filename>

Revert

  • "Revert to this version" button on each revision
  • Creates a new wiki commit that sets the page content back to the selected revision
  • Uses existing wiki_service.EditWikiPage() with the old content

Files to Modify

File Change
routers/web/repo/wiki.go New WikiDiff() handler, revert handler
templates/repo/wiki/revision.tmpl Add checkboxes, compare button, diff view
services/wiki/wiki.go Add RevertWikiPage() helper

Wikipedia Parity

Wikipedia's diff view is heavily used by editors to review changes, revert vandalism, and understand edit history. This is essential for collaborative wiki editing.

## Summary Add side-by-side diff comparison between any two revisions of a wiki page, with a "revert to this version" option. Currently the revision page only shows commit history without visual diffs. ## Current State - `WikiRevision()` in `routers/web/repo/wiki.go` shows commit history for a page via `CommitsByFileAndRange()` - `templates/repo/wiki/revision.tmpl` renders the commit list with author, date, and message - No way to see what actually changed between revisions - No way to revert to an older version ## Proposed Changes ### New Route ``` GET /:owner/:repo/wiki/:page?action=_diff&rev1=<sha>&rev2=<sha> ``` ### UI Changes to `revision.tmpl` - Add radio buttons / checkboxes next to each revision in the commit list - "Compare selected revisions" button that navigates to the diff view - Each individual revision gets a "View changes" link for quick diff against its parent ### Diff Rendering - Reuse the existing diff infrastructure from `templates/repo/diff/` — the same code that renders PR and commit diffs - Show the rendered markdown diff (before/after) and optionally the raw source diff - Since wiki content is stored in git, we can use `git diff <sha1> <sha2> -- <filename>` ### Revert - "Revert to this version" button on each revision - Creates a new wiki commit that sets the page content back to the selected revision - Uses existing `wiki_service.EditWikiPage()` with the old content ### Files to Modify | File | Change | |------|--------| | `routers/web/repo/wiki.go` | New `WikiDiff()` handler, revert handler | | `templates/repo/wiki/revision.tmpl` | Add checkboxes, compare button, diff view | | `services/wiki/wiki.go` | Add `RevertWikiPage()` helper | ## Wikipedia Parity Wikipedia's diff view is heavily used by editors to review changes, revert vandalism, and understand edit history. This is essential for collaborative wiki editing.
jmiller added the feature: wiki label 2026-06-21 06:32:00 +00:00
Sign in to join this conversation.