Sha256: 2221495e46fbc20acae29dcec9937fa0c2fbb1ea3835b5619d68f1c031a63544

Contents?: true

Size: 965 Bytes

Versions: 1

Compression:

Stored size: 965 Bytes

Contents

class FrontEndController < ApplicationController

  include PushType::Filterable

  before_action :load_node,         only: :show
  before_action :load_preview_node, only: :preview
  before_action :build_presenter
  node_filters

  def show
    render *@node.template_args
  end

  def preview
    response.headers['X-Robots-Tag'] = 'none'
    show
  end

  private  

  def load_node
    @node = PushType::Node.exposed.published.find_by_path permalink_path
  end

  def load_preview_node
    @node = PushType::Node.exposed.find_by_base64_id params[:id]
  end

  def build_presenter
    if @node
      instance_variable_set "@#{ @node.type.underscore }", @node.present!(view_context)
    else
      raise_404
    end
  end

  def root_path?
    request.fullpath == main_app.home_node_path
  end

  def raise_404
    if root_path?
      render template: 'push_type/setup', layout: nil, status: 404
    else
      raise ActiveRecord::RecordNotFound
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
push_type_core-0.10.0.beta.5 app/controllers/front_end_controller.rb