summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
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