Class: Cmsimple::PagesController
- Inherits:
-
Object
- Object
- Cmsimple::PagesController
- Defined in:
- app/controllers/cmsimple/pages_controller.rb
Instance Method Summary collapse
- #check_for_redirect ⇒ Object
- #create ⇒ Object
- #current_page ⇒ Object
-
#current_path ⇒ Object
helpers.
- #destroy ⇒ Object
- #edit ⇒ Object
- #editor ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #publish ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
- #update_content ⇒ Object
Instance Method Details
#check_for_redirect ⇒ Object
79 80 81 82 83 84 85 86 |
# File 'app/controllers/cmsimple/pages_controller.rb', line 79 def check_for_redirect return true if params[:id].present? if current_path.redirect? path = current_path.destination.uri path = "/editor#{path}" if action_name == 'editor' redirect_to path, status: 301 end end |
#create ⇒ Object
52 53 54 55 56 57 58 59 60 |
# File 'app/controllers/cmsimple/pages_controller.rb', line 52 def create params[:page].delete :id if params[:page] && params[:page].key?(:id) @page = Page.new(params[:page]) if @page.save respond_with(@page) else render :new, layout: false, status: 422 end end |
#current_page ⇒ Object
75 76 77 |
# File 'app/controllers/cmsimple/pages_controller.rb', line 75 def current_page @page ||= current_path.destination end |
#current_path ⇒ Object
helpers
71 72 73 |
# File 'app/controllers/cmsimple/pages_controller.rb', line 71 def current_path @path ||= Path.from_request!(request) end |
#destroy ⇒ Object
62 63 64 65 66 67 68 |
# File 'app/controllers/cmsimple/pages_controller.rb', line 62 def destroy @page = Page.find(params[:id]) @page.destroy respond_with(@page) do |format| format.html{ redirect_to '/editor' } end end |
#edit ⇒ Object
27 28 29 30 |
# File 'app/controllers/cmsimple/pages_controller.rb', line 27 def edit @page = Page.find(params[:id]) render :edit, :layout => false end |
#editor ⇒ Object
23 24 25 |
# File 'app/controllers/cmsimple/pages_controller.rb', line 23 def editor render :nothing => true, :layout => 'editor' end |
#index ⇒ Object
8 9 10 11 |
# File 'app/controllers/cmsimple/pages_controller.rb', line 8 def index @pages = Page.all respond_with @pages end |
#new ⇒ Object
32 33 34 35 |
# File 'app/controllers/cmsimple/pages_controller.rb', line 32 def new @page = Page.new render :new, :layout => false end |
#publish ⇒ Object
37 38 39 40 |
# File 'app/controllers/cmsimple/pages_controller.rb', line 37 def publish @page = Page.find(params[:id]) render :publish, :layout => false end |
#show ⇒ Object
13 14 15 16 |
# File 'app/controllers/cmsimple/pages_controller.rb', line 13 def show @page = Page.find(params[:id]) respond_with @page end |
#update ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'app/controllers/cmsimple/pages_controller.rb', line 42 def update @page = Page.find(params[:id]) params[:page].delete :id if params[:page] && params[:page].key?(:id) if @page.update_attributes(params[:page]) respond_with(@page) else render :edit, layout: false, status: 422 end end |
#update_content ⇒ Object
18 19 20 21 |
# File 'app/controllers/cmsimple/pages_controller.rb', line 18 def update_content current_page.update_content(params[:content]) respond_with @page, :location => @page.uri end |