diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-07-10 04:41:54 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-07-10 04:41:54 +0200 |
| commit | 30ed9fd9a8bffb44e6ab91dfedb8c0e33837769a (patch) | |
| tree | 38ed0ff848d7995951b0e9f0f3b00f2e4f52cea1 /app/models | |
| parent | 644744183602c68508abb02dbb9f1f321a63f88f (diff) | |
Include assets, tags and template in diff between revisions
Diffstat (limited to 'app/models')
| -rw-r--r-- | app/models/page.rb | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/app/models/page.rb b/app/models/page.rb index ea04cd6..740d42e 100644 --- a/app/models/page.rb +++ b/app/models/page.rb | |||
| @@ -176,19 +176,26 @@ class Page < ApplicationRecord | |||
| 176 | end | 176 | end |
| 177 | 177 | ||
| 178 | def diff_against other, view: :inline | 178 | def diff_against other, view: :inline |
| 179 | if view == :side_by_side | 179 | text_diffs = |
| 180 | { | 180 | if view == :side_by_side |
| 181 | title: HtmlWordDiff.side_by_side(other.title.to_s, title.to_s), | 181 | { |
| 182 | abstract: HtmlWordDiff.side_by_side(other.abstract.to_s, abstract.to_s), | 182 | title: HtmlWordDiff.side_by_side(other.title.to_s, title.to_s), |
| 183 | body: HtmlWordDiff.side_by_side(other.body.to_s, body.to_s) | 183 | abstract: HtmlWordDiff.side_by_side(other.abstract.to_s, abstract.to_s), |
| 184 | } | 184 | body: HtmlWordDiff.side_by_side(other.body.to_s, body.to_s) |
| 185 | else | 185 | } |
| 186 | { | 186 | else |
| 187 | title: HtmlWordDiff.inline(other.title.to_s, title.to_s), | 187 | { |
| 188 | abstract: HtmlWordDiff.inline(other.abstract.to_s, abstract.to_s), | 188 | title: HtmlWordDiff.inline(other.title.to_s, title.to_s), |
| 189 | body: HtmlWordDiff.inline(other.body.to_s, body.to_s) | 189 | abstract: HtmlWordDiff.inline(other.abstract.to_s, abstract.to_s), |
| 190 | } | 190 | body: HtmlWordDiff.inline(other.body.to_s, body.to_s) |
| 191 | end | 191 | } |
| 192 | end | ||
| 193 | |||
| 194 | text_diffs.merge( | ||
| 195 | tags: { added: tag_list.to_a - other.tag_list.to_a, removed: other.tag_list.to_a - tag_list.to_a }, | ||
| 196 | template_name: { from: other.template_name, to: template_name, changed: template_name != other.template_name }, | ||
| 197 | assets: { added: assets.to_a - other.assets.to_a, removed: other.assets.to_a - assets.to_a } | ||
| 198 | ) | ||
| 192 | end | 199 | end |
| 193 | 200 | ||
| 194 | def public? | 201 | def public? |
