Deleted the last of the rendering logic from Revision (making it a totally anemic entity, by the way)
This commit is contained in:
parent
427f989d69
commit
4838f6e684
|
@ -2,7 +2,7 @@ class Page < ActiveRecord::Base
|
||||||
belongs_to :web
|
belongs_to :web
|
||||||
has_many :revisions, :order => 'id'
|
has_many :revisions, :order => 'id'
|
||||||
has_one :current_revision, :class_name => 'Revision', :order => 'id DESC'
|
has_one :current_revision, :class_name => 'Revision', :order => 'id DESC'
|
||||||
|
|
||||||
def revise(content, time, author)
|
def revise(content, time, author)
|
||||||
revisions_size = new_record? ? 0 : revisions.size
|
revisions_size = new_record? ? 0 : revisions.size
|
||||||
if (revisions_size > 0) and content == current_revision.content
|
if (revisions_size > 0) and content == current_revision.content
|
||||||
|
@ -13,7 +13,8 @@ class Page < ActiveRecord::Base
|
||||||
author = Author.new(author.to_s) unless author.is_a?(Author)
|
author = Author.new(author.to_s) unless author.is_a?(Author)
|
||||||
|
|
||||||
# Try to render content to make sure that markup engine can take it,
|
# Try to render content to make sure that markup engine can take it,
|
||||||
Revision.new(:page => self, :content => content, :author => author, :revised_at => time).force_rendering
|
r = Revision.new(:page => self, :content => content, :author => author, :revised_at => time)
|
||||||
|
PageRenderer.new(r).force_rendering
|
||||||
|
|
||||||
# A user may change a page, look at it and make some more changes - several times.
|
# A user may change a page, look at it and make some more changes - several times.
|
||||||
# Not to record every such iteration as a new revision, if the previous revision was done
|
# Not to record every such iteration as a new revision, if the previous revision was done
|
||||||
|
|
|
@ -1,12 +1,4 @@
|
||||||
require 'diff'
|
|
||||||
class Revision < ActiveRecord::Base
|
class Revision < ActiveRecord::Base
|
||||||
belongs_to :page
|
belongs_to :page
|
||||||
composed_of :author, :mapping => [ %w(author name), %w(ip ip) ]
|
composed_of :author, :mapping => [ %w(author name), %w(ip ip) ]
|
||||||
|
|
||||||
after_create :force_rendering
|
|
||||||
|
|
||||||
def force_rendering
|
|
||||||
PageRenderer.new(self).force_rendering
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
require 'diff'
|
||||||
# Temporary class containing all rendering stuff from a Revision
|
# Temporary class containing all rendering stuff from a Revision
|
||||||
# I want to shift all rendering loguc to the controller eventually
|
# I want to shift all rendering loguc to the controller eventually
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue