Sha256: a8df01a58f9f0111037c38ccb8979956b8fb43b536990282a7b043eceec0a0f6

Contents?: true

Size: 927 Bytes

Versions: 1

Compression:

Stored size: 927 Bytes

Contents

module Pulitzer
  module ControllerHelpers
    def pulitzer_view_path(version_number)
      File.join Pulitzer.public_controller,
        action_name,
        "v_#{version_number.to_s}.html.erb"
    end

    def get_active_post(post_type_name)
      @post_type_version = Pulitzer::PostType.named(post_type_name).published_type_version
      @post = get_post_for_version(@post_type_version)
      return @post, @post_type_version
    end

    def get_preview_post(post_type_name)
      @post_type_version = Pulitzer::PostType.named(post_type_name).post_type_versions.find_by(version_number: params[:version_number])
      @post = get_post_for_version(@post_type_version)
      return @post, @post_type_version
    end

    def get_post_for_version(ptv)
      if ptv.plural?
        ptv.posts.find_by!(slug: params[:slug]).get_active_version!
      else
        ptv.singleton_post.get_active_version!
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pulitzer-0.15.5 lib/pulitzer/controller_helpers.rb