Class: Kuhsaft::Cms::PagesController
Instance Method Summary
collapse
#default_url_options, #set_content_locale
Instance Method Details
#create ⇒ Object
22
23
24
25
26
27
28
29
30
31
|
# File 'app/controllers/kuhsaft/cms/pages_controller.rb', line 22
def create
@page = Kuhsaft::Page.create(page_params)
if @page.valid?
flash[:success] = t('layouts.kuhsaft.cms.flash.success', subject: Kuhsaft::Page.model_name.human)
respond_with @page, location: kuhsaft.edit_cms_page_path(@page)
else
render 'new'
end
end
|
#destroy ⇒ Object
50
51
52
53
54
|
# File 'app/controllers/kuhsaft/cms/pages_controller.rb', line 50
def destroy
@page = Kuhsaft::Page.find(params[:id])
@page.destroy
redirect_to kuhsaft.cms_pages_path
end
|
#edit ⇒ Object
33
34
35
36
37
38
|
# File 'app/controllers/kuhsaft/cms/pages_controller.rb', line 33
def edit
@page = Kuhsaft::Page.find(params[:id])
@page.published ||= Kuhsaft::PublishState::UNPUBLISHED
@page.bricks.each { |brick| brick.valid? }
respond_with @page
end
|
#index ⇒ Object
6
7
8
9
|
# File 'app/controllers/kuhsaft/cms/pages_controller.rb', line 6
def index
@pages = Kuhsaft::Page.roots
respond_with @pages
end
|
#mirror ⇒ Object
60
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'app/controllers/kuhsaft/cms/pages_controller.rb', line 60
def mirror
@page = Kuhsaft::Page.find(params[:page_id])
unless @page.bricks.empty?
if params[:rutheless] == 'true' || @page.bricks.unscoped.where(locale: params[:target_locale]).empty?
@page.clear_bricks_for_locale(params[:target_locale])
params[:failed_bricks] = @page.clone_bricks_to(params[:target_locale])
params[:rutheless] = 'true'
end
end
respond_to :js, :html
end
|
#show ⇒ Object
11
12
13
14
|
# File 'app/controllers/kuhsaft/cms/pages_controller.rb', line 11
def show
@page = Kuhsaft::Page.find(params[:id])
respond_with @page
end
|
#sort ⇒ Object
56
57
58
|
# File 'app/controllers/kuhsaft/cms/pages_controller.rb', line 56
def sort
Kuhsaft::PageTree.update(params[:page_tree])
end
|
#update ⇒ Object
40
41
42
43
44
45
46
47
48
|
# File 'app/controllers/kuhsaft/cms/pages_controller.rb', line 40
def update
@page = Kuhsaft::Page.find(params[:id])
if @page.update_attributes(page_params)
flash[:success] = t('layouts.kuhsaft.cms.flash.success', subject: Kuhsaft::Page.model_name.human)
respond_with @page, location: kuhsaft.edit_cms_page_path(@page)
else
render 'edit'
end
end
|