Class: Locomotive::PagesController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/locomotive/pages_controller.rb

Instance Method Summary collapse

Methods included from ActionController::Ssl

#require_ssl

Methods included from ActionController::UrlHelpers

#current_site_public_url, #public_page_url, #switch_to_site_url

Methods included from ActionController::SectionHelpers

#sections

Methods included from ActionController::LocaleHelpers

#back_to_default_site_locale, #current_content_locale, #localized?, #set_back_office_locale, #set_current_content_locale, #setup_i18n_fallbacks

Instance Method Details

#createObject



27
28
29
30
# File 'app/controllers/locomotive/pages_controller.rb', line 27

def create
  @page = current_site.pages.create(params[:page])
  respond_with @page, location: edit_page_path(@page._id)
end

#destroyObject



43
44
45
46
47
# File 'app/controllers/locomotive/pages_controller.rb', line 43

def destroy
  @page = current_site.pages.find(params[:id])
  @page.destroy
  respond_with @page
end

#editObject



32
33
34
35
# File 'app/controllers/locomotive/pages_controller.rb', line 32

def edit
  @page = current_site.pages.find(params[:id])
  respond_with @page
end

#get_pathObject



55
56
57
58
59
60
61
62
63
64
# File 'app/controllers/locomotive/pages_controller.rb', line 55

def get_path
  page = current_site.pages.build(parent: current_site.pages.find(params[:parent_id]), slug: params[:slug].permalink).tap do |p|
    p.valid?; p.send(:build_fullpath)
  end
  render json: {
    url:                public_page_url(page, locale: current_content_locale),
    slug:               page.slug,
    templatized_parent: page.templatized_from_parent?
  }
end

#indexObject



12
13
14
15
# File 'app/controllers/locomotive/pages_controller.rb', line 12

def index
  @pages = current_site.all_pages_in_once
  respond_with(@pages)
end

#newObject



22
23
24
25
# File 'app/controllers/locomotive/pages_controller.rb', line 22

def new
  @page = current_site.pages.build
  respond_with @page
end

#showObject



17
18
19
20
# File 'app/controllers/locomotive/pages_controller.rb', line 17

def show
  @page = current_site.pages.find(params[:id])
  respond_with @page
end

#sortObject



49
50
51
52
53
# File 'app/controllers/locomotive/pages_controller.rb', line 49

def sort
  @page = current_site.pages.find(params[:id])
  @page.sort_children!(params[:children])
  respond_with @page
end

#updateObject



37
38
39
40
41
# File 'app/controllers/locomotive/pages_controller.rb', line 37

def update
  @page = current_site.pages.find(params[:id])
  @page.update_attributes(params[:page])
  respond_with @page, location: edit_page_path(@page._id)
end