##// END OF EJS Templates
Added page association on versioned WikiContent...
Jean-Philippe Lang -
r562:5332c4362cdf
parent child
Show More
@@ -1,59 +1,60
1 1 # redMine - project management software
2 2 # Copyright (C) 2006-2007 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 require 'zlib'
19 19
20 20 class WikiContent < ActiveRecord::Base
21 21 set_locking_column :version
22 22 belongs_to :page, :class_name => 'WikiPage', :foreign_key => 'page_id'
23 23 belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
24 24 validates_presence_of :text
25 25
26 26 acts_as_versioned
27 27 class Version
28 belongs_to :page, :class_name => 'WikiPage', :foreign_key => 'page_id'
28 29 belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
29 30 attr_protected :data
30 31
31 32 def text=(plain)
32 33 case Setting.wiki_compression
33 34 when 'gzip'
34 35 begin
35 36 self.data = Zlib::Deflate.deflate(plain, Zlib::BEST_COMPRESSION)
36 37 self.compression = 'gzip'
37 38 rescue
38 39 self.data = plain
39 40 self.compression = ''
40 41 end
41 42 else
42 43 self.data = plain
43 44 self.compression = ''
44 45 end
45 46 plain
46 47 end
47 48
48 49 def text
49 50 @text ||= case compression
50 51 when 'gzip'
51 52 Zlib::Inflate.inflate(data)
52 53 else
53 54 # uncompressed data
54 55 data
55 56 end
56 57 end
57 58 end
58 59
59 60 end
General Comments 0
You need to be logged in to leave comments. Login now