summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
Diffstat (limited to 'app/models')
-rw-r--r--app/models/page.rb33
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?