app/controllers/documentation/pages_controller.rb in documentation-1.0.1 vs app/controllers/documentation/pages_controller.rb in documentation-1.0.2

- old
+ new

@@ -42,10 +42,25 @@ authorizer.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 + def screenshot + authorizer.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 + def positioning authorizer.check! :reposition_page, @page @pages = @page ? @page.children : Page.roots if request.post? Page.reorder(@page, params[:order]) @@ -66,9 +81,13 @@ end end def safe_params params.require(:page).permit(:title, :permalink, :content, :favourite) + end + + def screenshot_params + params.require(:screenshot).permit(:upload_file, :alt_text) end end end