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
|
|
|
|
|
|
|
respond_to :json, :only => [:update, :sort, :get_path]
|
|
|
|
|
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
|
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 new
|
|
|
|
@page = current_site.pages.build
|
2010-08-28 00:00:05 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
|
|
|
update! do |success, failure|
|
|
|
|
success.json do
|
|
|
|
render :json => {
|
2011-10-30 23:02:41 +00:00
|
|
|
:notice => t('flash.locomotive.pages.update.notice'),
|
2010-08-28 00:00:05 +00:00
|
|
|
:editable_elements => @page.template_changed ?
|
2011-10-30 23:02:41 +00:00
|
|
|
render_to_string(:partial => 'locomotive/pages/editable_elements.html.haml') : ''
|
2010-08-28 00:00:05 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
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 sort
|
|
|
|
@page = current_site.pages.find(params[:id])
|
|
|
|
@page.sort_children!(params[:children])
|
2010-07-21 23:35:30 +00:00
|
|
|
|
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
|
2011-06-21 20:03:24 +00:00
|
|
|
page = current_site.pages.build(:parent => current_site.pages.find(params[:parent_id]), :slug => params[:slug].permalink)
|
2010-07-21 23:35:30 +00:00
|
|
|
|
2011-04-24 23:21:38 +00:00
|
|
|
render :json => { :url => 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
|
2010-07-23 20:09:54 +00:00
|
|
|
end
|