Class: WikiContent::Version

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

Instance Method Summary collapse

Instance Method Details

#attachmentsObject

Deprecated.

Removed at 4.0.0

Since:

  • 3.3.1



121
122
123
# File 'app/models/wiki_content.rb', line 121

def attachments
  page.nil? ? [] : page.attachments
end

#current_version?Boolean

Deprecated.

Removed at 4.0.0

Return true if the content is the current page content

Returns:

  • (Boolean)

Since:

  • 1.3.0



126
127
128
# File 'app/models/wiki_content.rb', line 126

def current_version?
  page.content.version == self.version
end

#nextObject

Deprecated.

Removed at 4.0.0

Returns the next version or nil

Since:

  • 2.2.0



139
140
141
142
143
144
# File 'app/models/wiki_content.rb', line 139

def next
  @next ||= WikiContent::Version.
    reorder('version ASC').
    includes(:author).
    where("wiki_content_id = ? AND version > ?", wiki_content_id, version).first
end

#previousObject

Deprecated.

Removed at 4.0.0

Returns the previous version or nil

Since:

  • 0.7.0



131
132
133
134
135
136
# File 'app/models/wiki_content.rb', line 131

def previous
  @previous ||= WikiContent::Version.
    reorder('version DESC').
    includes(:author).
    where("wiki_content_id = ? AND version < ?", wiki_content_id, version).first
end

#projectObject

Deprecated.

Removed at 4.0.0

Since:

  • 0.7.0



117
118
119
# File 'app/models/wiki_content.rb', line 117

def project
  page.project
end

#textObject

Deprecated.

Removed at 4.0.0

Since:

  • 0.5.0



103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'app/models/wiki_content.rb', line 103

def text
  @text ||= begin
    str = case compression
          when 'gzip'
            Zlib::Inflate.inflate(data)
          else
            # uncompressed data
            data
          end
    str.force_encoding("UTF-8")
    str
  end
end

#text=(plain) ⇒ Object

Deprecated.

Removed at 4.0.0

Since:

  • 0.5.0



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'app/models/wiki_content.rb', line 86

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