summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorerdgeist <erdgeist@erdgeist.org>2026-07-10 00:35:24 +0200
committererdgeist <erdgeist@erdgeist.org>2026-07-10 00:35:24 +0200
commita25d90335ad3738b6831288190132c2f7498465c (patch)
tree5aa7083d9f8c8701644fe60bc7d28542775694b8 /app/models
parentda0b79a7c1f3116e2b450ecbe50efdf31cf23414 (diff)
Retire vendored cacycle_diff.js for a diff-lcs-based diff view
Revisions#diff now computes an inline or side-by-side word diff server-side (Page#diff_against, lib/html_word_diff.rb) instead of shipping raw/escaped content to the browser for a 2008-era vendored JS differ to mangle. View mode is picked via a `view` param, settable either on the diff page itself or directly from the revisions#index sticky bar next to "Diff revisions". Also fixes a pre-existing bug in RevisionsController#diff's single- revision branch, which set params[:start]/params[:end] instead of params[:start_revision]/params[:end_revision].
Diffstat (limited to 'app/models')
-rw-r--r--app/models/page.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/app/models/page.rb b/app/models/page.rb
index 1a98e08..ea04cd6 100644
--- a/app/models/page.rb
+++ b/app/models/page.rb
@@ -175,6 +175,22 @@ class Page < ApplicationRecord
175 self.save 175 self.save
176 end 176 end
177 177
178 def diff_against other, view: :inline
179 if view == :side_by_side
180 {
181 title: HtmlWordDiff.side_by_side(other.title.to_s, title.to_s),
182 abstract: HtmlWordDiff.side_by_side(other.abstract.to_s, abstract.to_s),
183 body: HtmlWordDiff.side_by_side(other.body.to_s, body.to_s)
184 }
185 else
186 {
187 title: HtmlWordDiff.inline(other.title.to_s, title.to_s),
188 abstract: HtmlWordDiff.inline(other.abstract.to_s, abstract.to_s),
189 body: HtmlWordDiff.inline(other.body.to_s, body.to_s)
190 }
191 end
192 end
193
178 def public? 194 def public?
179 published_at.nil? ? true : published_at < Time.now 195 published_at.nil? ? true : published_at < Time.now
180 end 196 end