A bit of golf
This commit is contained in:
parent
578becb609
commit
87ab5d00ae
|
@ -6,6 +6,7 @@ require 'author'
|
||||||
require 'page'
|
require 'page'
|
||||||
|
|
||||||
class Revision
|
class Revision
|
||||||
|
|
||||||
attr_accessor :page, :number, :content, :created_at, :author
|
attr_accessor :page, :number, :content, :created_at, :author
|
||||||
|
|
||||||
def initialize(page, number, content, created_at, author)
|
def initialize(page, number, content, created_at, author)
|
||||||
|
@ -29,7 +30,7 @@ class Revision
|
||||||
end
|
end
|
||||||
|
|
||||||
def previous_revision
|
def previous_revision
|
||||||
number - 1 >= 0 && page.revisions[number - 1]
|
number > 0 ? page.revisions[number - 1] : nil
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns an array of all the WikiWords present in the content of this revision.
|
# Returns an array of all the WikiWords present in the content of this revision.
|
||||||
|
@ -53,8 +54,8 @@ class Revision
|
||||||
wiki_words - existing_pages
|
wiki_words - existing_pages
|
||||||
end
|
end
|
||||||
|
|
||||||
# Explicit check for new type of display cache with find_chunks method.
|
# Explicit check for new type of display cache with find_chunks method.
|
||||||
# Ensures new version works with older snapshots.
|
# Ensures new version works with older snapshots.
|
||||||
def display_content
|
def display_content
|
||||||
unless @display_cache && @display_cache.respond_to?(:find_chunks)
|
unless @display_cache && @display_cache.respond_to?(:find_chunks)
|
||||||
@display_cache = WikiContent.new(self)
|
@display_cache = WikiContent.new(self)
|
||||||
|
@ -69,7 +70,7 @@ class Revision
|
||||||
def clear_display_cache
|
def clear_display_cache
|
||||||
@display_cache = @published_cache = @wiki_words_cache = nil
|
@display_cache = @published_cache = @wiki_words_cache = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
def display_published
|
def display_published
|
||||||
@published_cache = WikiContent.new(self, {:mode => :publish}) if @published_cache.nil?
|
@published_cache = WikiContent.new(self, {:mode => :publish}) if @published_cache.nil?
|
||||||
@published_cache
|
@published_cache
|
||||||
|
@ -77,5 +78,6 @@ class Revision
|
||||||
|
|
||||||
def display_content_for_export
|
def display_content_for_export
|
||||||
WikiContent.new(self, {:mode => :export} )
|
WikiContent.new(self, {:mode => :export} )
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
end
|
||||||
|
|
Loading…
Reference in a new issue