cms_controller.rb
1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
class CmsController < MyProfileController
# FIXME add the access control again
# protect 'post_content', :profile, :only => [:edit, :new, :reorder, :delete]
include CmsHelper
def view
@article = profile.articles.find(params[:id])
@subitems = @article.children
end
def index
@article = profile.home_page
@subitems = profile.top_level_articles
render :action => 'view'
end
def edit
article = profile.articles.find(params[:id])
redirect_to(url_for_edit_article(article))
end
post_only :set_home_page
def set_home_page
@article = profile.articles.find(params[:id])
profile.home_page = @article
profile.save!
redirect_to :back
end
protected
class << self
def available_editors
Dir.glob(File.join(File.dirname(__FILE__), 'cms', '*.rb'))
end
def available_types
available_editors.map {|item| File.basename(item).gsub(/\.rb$/, '').gsub('_', '/') }
end
end
end
CmsController.available_editors.each do |item|
load item
end