app/models/page.rb in instiki-0.10.1 vs app/models/page.rb in instiki-0.10.2
- old
+ new
@@ -8,22 +8,27 @@
include PageLock
attr_reader :name, :web
attr_accessor :revisions
- def initialize(web, name, content, created_at, author)
+ def initialize(web, name)
+ raise 'nil web' if web.nil?
+ raise 'nil name' if name.nil?
@web, @name, @revisions = web, name, []
- revise(content, created_at, author)
end
def revise(content, created_at, author)
if not @revisions.empty? and content == @revisions.last.content
raise Instiki::ValidationError.new(
"You have tried to save page '#{name}' without changing its content")
end
+ # Try to render content to make sure that markup engine can take it,
+ # before addin a revision to the page
+ Revision.new(self, @revisions.length, content, created_at, author).force_rendering
+
# 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
# by the same author, not more than 30 minutes ago, then update the last revision instead of
# creating a new one
if !@revisions.empty? && continous_revision?(created_at, author)
@@ -39,9 +44,12 @@
# references to the page itself are rendered as "unresolved". Clearing the cache allows
# the page to re-render itself once again, hopefully _after_ it is inserted in the web
self.revisions.last.clear_display_cache
@web.refresh_pages_with_references(@name) if @revisions.length == 1
+
+ self
+
end
def rollback(revision_number, created_at, author_ip = nil)
roll_back_revision = @revisions[revision_number].dup
revise(roll_back_revision.content, created_at, Author.new(roll_back_revision.author, author_ip))