app/controllers/pulitzer/posts_controller.rb in pulitzer-0.11.2 vs app/controllers/pulitzer/posts_controller.rb in pulitzer-0.11.3
- old
+ new
@@ -1,8 +1,9 @@
class Pulitzer::PostsController < Pulitzer::ApplicationController
- before_filter :get_post, only: [:show, :edit, :edit_title, :edit_slug, :update,
+ before_filter :get_post, only: [:show, :edit, :edit_title, :edit_slug, :show_slug, :update,
:update_slug, :processing_preview]
+ before_action :get_version, only: [:edit_slug, :show_slug, :update_slug]
def index
@post_type = Pulitzer::PostType.find params[:post_type_id]
@posts = Pulitzer::Post.where(post_type: @post_type).order(id: :desc)
end
@@ -42,26 +43,34 @@
render head :ok
end
def edit_slug
if request.xhr?
- render partial: 'form_slug', locals: { post: @post }
+ render partial: 'form_slug', locals: { post: @post, version: @version }
end
end
def show_slug
- render partial: 'show_slug', locals: { post: @post }
+ render partial: 'show_slug', locals: { post: @post, version: @version }
end
def update_slug
@post.update_attributes(post_params)
- render partial: 'show_slug', locals: { post: @post }
+ if @version.preview?
+ route = "#{Pulitzer.preview_namespace}_#{@post.post_type.name.parameterize('_')}_path"
+ @preview_path = main_app.public_send(route, @post.slug) if main_app.respond_to?(route)
+ end
+ render partial: 'pulitzer/posts/edit', locals: { version: @version, post: @post }
end
protected
def post_params
params[:post].permit!
+ end
+
+ def get_version
+ @version = Pulitzer::Version.find(params[:version_id])
end
def get_post
@post = Pulitzer::Post.find(params[:id])
end