Sha256: 48e6e201696ca313b2f5b46b318a2d1f33ab7b5ebe143adfb2d9cae749e7b273

Contents?: true

Size: 1.6 KB

Versions: 18

Compression:

Stored size: 1.6 KB

Contents

module Locomotive
  class PagesController < BaseController

    sections 'contents'

    localized

    before_filter :back_to_default_site_locale, only: %w(new create)

    respond_to    :json, only: [:show, :create, :update, :sort, :get_path]

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

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

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

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

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

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

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

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

    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

  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
locomotive_cms-2.5.7 app/controllers/locomotive/pages_controller.rb
locomotive_cms-2.5.6 app/controllers/locomotive/pages_controller.rb
locomotive_cms-2.5.6.rc2 app/controllers/locomotive/pages_controller.rb
locomotive_cms-2.5.6.rc1 app/controllers/locomotive/pages_controller.rb
locomotive_cms-2.5.5 app/controllers/locomotive/pages_controller.rb
locomotive_cms-2.5.4 app/controllers/locomotive/pages_controller.rb
locomotive_cms-2.5.3 app/controllers/locomotive/pages_controller.rb
locomotive_cms-2.5.2 app/controllers/locomotive/pages_controller.rb
locomotive_cms-2.5.1 app/controllers/locomotive/pages_controller.rb
locomotive_cms-2.5.0 app/controllers/locomotive/pages_controller.rb
locomotive_cms-2.5.0.rc3 app/controllers/locomotive/pages_controller.rb
locomotive_cms-2.5.0.rc2 app/controllers/locomotive/pages_controller.rb
locomotive_cms-2.5.0.rc1 app/controllers/locomotive/pages_controller.rb
locomotive_cms-2.4.1 app/controllers/locomotive/pages_controller.rb
locomotive_cms-2.4.0 app/controllers/locomotive/pages_controller.rb
locomotive_cms-2.3.1 app/controllers/locomotive/pages_controller.rb
locomotive_cms-2.3.0 app/controllers/locomotive/pages_controller.rb
locomotive_cms-2.2.3 app/controllers/locomotive/pages_controller.rb