Class: Publinator::Manage::PublishableController
Instance Method Summary
collapse
#body_id, #current_controller, #current_domain, #current_layout, #current_site, #current_site_name
Instance Method Details
#create ⇒ Object
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'app/controllers/publinator/manage/publishable_controller.rb', line 58
def create
@publishable = @publishable_class.new(params[@publishable_member_name.to_sym])
logger.info current_site.to_yaml
@publishable.publication.site = current_site
if @publishable.save
redirect_to "/manage/#{@publishable_collection_name}", :notice => "#{@publishable_type.name} created."
else
begin
render "#{@publishable_collection_name}/new", :notice => "#{@publishable_type.name} could not be created."
rescue ActionView::MissingTemplate
render "publinator/manage/publishable/new", :notice => "#{@publishable_type.name} could not be created."
end
end
end
|
#edit ⇒ Object
48
49
50
51
52
53
54
55
56
|
# File 'app/controllers/publinator/manage/publishable_controller.rb', line 48
def edit
@publishable.asset_items.build
begin
render "manage/#{@publishable_collection_name}/edit"
rescue ActionView::MissingTemplate
render "publinator/manage/publishable/edit"
end
end
|
#index ⇒ Object
10
11
12
13
14
15
16
|
# File 'app/controllers/publinator/manage/publishable_controller.rb', line 10
def index
begin
render "manage/#{@publishable_collection_name}/index"
rescue ActionView::MissingTemplate
render "publinator/manage/publishable/index"
end
end
|
#new ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'app/controllers/publinator/manage/publishable_controller.rb', line 30
def new
@publishable = @publishable_class.new(
:publication => Publinator::Publication.new(
:publish_at => 1.day.from_now.beginning_of_day + 8.hours,
:archive_at => 31.days.from_now.beginning_of_day,
:site => current_site,
:publishable_type => @publishable_type.name
)
)
@publishable.asset_items.build
@field_names = @publishable.editable_fields.collect{ |an| an.to_sym }
begin
render "manage/#{@publishable_collection_name}/new"
rescue ActionView::MissingTemplate
render "publinator/manage/publishable/new"
end
end
|
#preview ⇒ Object
26
27
28
|
# File 'app/controllers/publinator/manage/publishable_controller.rb', line 26
def preview
render :text => RDiscount.new(params[:preview_text]).to_html.html_safe, :layout => false
end
|
#show ⇒ Object
18
19
20
21
22
23
24
|
# File 'app/controllers/publinator/manage/publishable_controller.rb', line 18
def show
begin
render "manage/#{@publishable_collection_name}/show"
rescue ActionView::MissingTemplate
render "publinator/manage/publishable/show"
end
end
|
#sort ⇒ Object
86
87
88
89
90
91
92
93
|
# File 'app/controllers/publinator/manage/publishable_controller.rb', line 86
def sort
collection_class = @publishable.collection_name.singularize.downcase
@publishable..each do |item|
item.position = params[collection_class].index(item.id.to_s) + 1
item.save
end
render :nothing => true
end
|
#update ⇒ Object
74
75
76
77
78
79
80
81
82
83
84
|
# File 'app/controllers/publinator/manage/publishable_controller.rb', line 74
def update
if @publishable_class.send(:update, @publishable.id, params[@publishable_class_name.downcase.to_sym])
redirect_to "/manage/#{@publishable_collection_name}", :notice => "#{@publishable_type.name} updated."
else
begin
render "#{@publishable_collection_name}/edit", :notice => "#{@publishable_type.name} could not be updated."
rescue ActionView::MissingTemplate
render "publinator/manage/publishable/edit", :notice => "#{@publishable_type.name} could not be updated."
end
end
end
|