Class: WikiContent::Version

Inherits:
Object
  • Object
show all
Defined in:
app/models/wiki_content.rb

Instance Method Summary

Instance Method Details

- (Object) previous

Returns the previous version or nil



99
100
101
102
103
104
# File 'app/models/wiki_content.rb', line 99

def previous
  @previous ||= WikiContent::Version.find(:first, 
                                          :order => 'version DESC',
                                          :include => :author,
                                          :conditions => ["wiki_content_id = ? AND version < ?", wiki_content_id, version])
end

- (Object) project



94
95
96
# File 'app/models/wiki_content.rb', line 94

def project
  page.project
end

- (Object) text



84
85
86
87
88
89
90
91
92
# File 'app/models/wiki_content.rb', line 84

def text
  @text ||= case compression
  when 'gzip'
     Zlib::Inflate.inflate(data)
  else
    # uncompressed data
    data
  end      
end

- (Object) text=(plain)



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'app/models/wiki_content.rb', line 67

def text=(plain)
  case Setting.wiki_compression
  when 'gzip'
  begin
    self.data = Zlib::Deflate.deflate(plain, Zlib::BEST_COMPRESSION)
    self.compression = 'gzip'
  rescue
    self.data = plain
    self.compression = ''
  end
  else
    self.data = plain
    self.compression = ''
  end
  plain
end