3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/kitsune/page.rb', line 3
def self.included(model)
model.class_eval do
admin do
wysiwyg :body
select :layout, Proc.new {Dir.glob(File.join(RAILS_ROOT, 'app', 'views', 'layouts', '*.html.haml')).map{|f| File.basename(f).split('.').first}}
end
before_save :update_url
belongs_to :page, :foreign_key => "parent_id"
belongs_to :parent, :class_name => 'Page'
def update_url
unless url.present?
write_attribute :url, CGI.escape(title.downcase.gsub(/\s+/, '-'))
else
write_attribute :url, CGI.escape(url)
end
end
end
end
|