Sha256: b4fedfd15723fba30e9d006f00ffe90f56cef66de7ba2b668aacca4466486284

Contents?: true

Size: 629 Bytes

Versions: 2

Compression:

Stored size: 629 Bytes

Contents

class Shim::PagesController < ActionController::Base
  unloadable
  layout Proc.new { |_| ::Shim.layout }

  rescue_from ActionView::MissingTemplate do |exception|
    if exception.message =~ %r{Missing template #{content_path}}
      raise ActionController::RoutingError, "No such page: #{params[:id]}"
    else
      raise exception
    end
  end

  def show
    render :template => current_page
  end

  protected

  def current_page
    "#{content_path}#{clean_path}"
  end

  def clean_path
    path = Pathname.new "/#{params[:id]}"
    path.cleanpath.to_s[1..-1]
  end

  def content_path
    ::Shim.content_path
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
shim-0.1.1 app/controllers/shim/pages_controller.rb
shim-0.1.0 app/controllers/shim/pages_controller.rb