Class: Documentation::PagesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Documentation::PagesController
- Defined in:
- app/controllers/documentation/pages_controller.rb
Instance Method Summary collapse
- #destroy ⇒ Object
- #edit ⇒ Object
- #new ⇒ Object
- #positioning ⇒ Object
- #screenshot ⇒ Object
- #search ⇒ Object
- #show ⇒ Object
Instance Method Details
#destroy ⇒ Object
41 42 43 44 45 |
# File 'app/controllers/documentation/pages_controller.rb', line 41 def destroy .check! :delete_page, @page @page.destroy redirect_to @page.parent ? page_path(@page.parent.full_permalink) : root_path, :notice => "Page has been removed successfully." end |
#edit ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/controllers/documentation/pages_controller.rb', line 10 def edit .check! :edit_page, @page if request.patch? if @page.update_attributes(safe_params) redirect_to page_path(@page.full_permalink), :notice => "Page has been saved successfully." return end end render :action => "form" end |
#new ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/controllers/documentation/pages_controller.rb', line 22 def new .check! :add_page, @page parent = @page @page = Page.new(:title => "Untitled Page") if @page.parent = parent @page.parents = parent. end if request.post? @page.attributes = safe_params if @page.save redirect_to page_path(@page.full_permalink), :notice => "Page created successfully" return end end render :action => "form" end |
#positioning ⇒ Object
62 63 64 65 66 67 68 69 |
# File 'app/controllers/documentation/pages_controller.rb', line 62 def positioning .check! :reposition_page, @page @pages = @page ? @page.children : Page.roots if request.post? Page.reorder(@page, params[:order]) render :json => {:status => 'ok'} end end |
#screenshot ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'app/controllers/documentation/pages_controller.rb', line 47 def screenshot .check! :upload, @page if request.post? @screenshot = Screenshot.new(screenshot_params) if @screenshot.save render :json => { :id => @screenshot.id, :title => @screenshot.alt_text, :path => @screenshot.upload.path }, :status => :created else render :json => { :errors => @screenshot.errors }, :status => :unprocessible_entity end else @screenshot = Screenshot.new render 'screenshot', :layout => false end end |
#search ⇒ Object
71 72 73 74 |
# File 'app/controllers/documentation/pages_controller.rb', line 71 def search .check! :search @result = Documentation::Page.search(params[:query], :page => params[:page].blank? ? 1 : params[:page].to_i) end |
#show ⇒ Object
6 7 8 |
# File 'app/controllers/documentation/pages_controller.rb', line 6 def show .check! :view_page, @page end |