2011-10-30 23:02:41 +00:00
|
|
|
module Locomotive
|
2010-05-10 22:39:52 +00:00
|
|
|
class PagesController < BaseController
|
2010-07-21 23:35:30 +00:00
|
|
|
|
2010-05-10 22:39:52 +00:00
|
|
|
sections 'contents'
|
2010-07-21 23:35:30 +00:00
|
|
|
|
2012-02-09 10:36:10 +00:00
|
|
|
localized
|
|
|
|
|
2012-01-26 15:51:32 +00:00
|
|
|
before_filter :back_to_default_site_locale, :only => %w(new create)
|
|
|
|
|
2012-02-09 10:36:10 +00:00
|
|
|
respond_to :json, :only => [:show, :create, :update, :sort, :get_path]
|
2010-07-21 23:35:30 +00:00
|
|
|
|
2010-05-10 22:39:52 +00:00
|
|
|
def index
|
2011-01-02 22:58:06 +00:00
|
|
|
@pages = current_site.all_pages_in_once
|
2011-11-09 01:35:59 +00:00
|
|
|
respond_with(@pages)
|
2010-05-10 22:39:52 +00:00
|
|
|
end
|
2010-07-21 23:35:30 +00:00
|
|
|
|
2011-11-21 01:27:05 +00:00
|
|
|
def show
|
|
|
|
@page = current_site.pages.find(params[:id])
|
|
|
|
respond_with @page
|
|
|
|
end
|
|
|
|
|
2010-05-10 22:39:52 +00:00
|
|
|
def new
|
|
|
|
@page = current_site.pages.build
|
2011-11-09 01:35:59 +00:00
|
|
|
respond_with @page
|
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
2011-11-10 21:41:20 +00:00
|
|
|
@page = current_site.pages.create(params[:page])
|
|
|
|
respond_with @page, :location => edit_page_url(@page._id)
|
2010-08-28 00:00:05 +00:00
|
|
|
end
|
|
|
|
|
2011-11-16 00:39:16 +00:00
|
|
|
def edit
|
|
|
|
@page = current_site.pages.find(params[:id])
|
|
|
|
respond_with @page
|
|
|
|
end
|
|
|
|
|
2010-08-28 00:00:05 +00:00
|
|
|
def update
|
2011-11-10 21:41:20 +00:00
|
|
|
@page = current_site.pages.find(params[:id])
|
2011-11-09 01:35:59 +00:00
|
|
|
@page.update_attributes(params[:page])
|
2011-11-21 01:27:05 +00:00
|
|
|
respond_with @page, :location => edit_page_url(@page._id)
|
2010-05-10 22:39:52 +00:00
|
|
|
end
|
2010-07-21 23:35:30 +00:00
|
|
|
|
2011-11-10 21:41:20 +00:00
|
|
|
def destroy
|
|
|
|
@page = current_site.pages.find(params[:id])
|
|
|
|
@page.destroy
|
|
|
|
respond_with @page
|
|
|
|
end
|
|
|
|
|
2010-05-10 22:39:52 +00:00
|
|
|
def sort
|
|
|
|
@page = current_site.pages.find(params[:id])
|
|
|
|
@page.sort_children!(params[:children])
|
2010-07-13 00:46:17 +00:00
|
|
|
respond_with @page
|
2010-05-10 22:39:52 +00:00
|
|
|
end
|
2010-07-21 23:35:30 +00:00
|
|
|
|
2010-05-10 22:39:52 +00:00
|
|
|
def get_path
|
2012-04-06 10:23:11 +00:00
|
|
|
page = current_site.pages.build(:parent => current_site.pages.find(params[:parent_id]), :slug => params[:slug].permalink, :wildcard => params[:wildcard]).tap do |p|
|
2012-03-27 22:26:32 +00:00
|
|
|
p.valid?; p.send(:build_fullpath)
|
|
|
|
end
|
2012-04-06 10:23:11 +00:00
|
|
|
render :json => { :url => public_page_url(page), :slug => page.slug }
|
2010-05-10 22:39:52 +00:00
|
|
|
end
|
2010-07-21 23:35:30 +00:00
|
|
|
|
2010-07-13 00:46:17 +00:00
|
|
|
end
|
2011-11-09 01:35:59 +00:00
|
|
|
end
|