Sha256: 9ee44e6f41a044f63c740018c955d462c678e5a52139dbccc5afdd46ad65c1a8

Contents?: true

Size: 969 Bytes

Versions: 2

Compression:

Stored size: 969 Bytes

Contents

module Lookbook
  class PagesController < ApplicationController
    def self.controller_path
      "lookbook/pages"
    end

    def index
      landing = Lookbook.pages.find(&:landing) || Lookbook.pages.first
      if landing.present?
        redirect_to page_path landing.lookup_path
      else
        @title = "Not found"
        render "not_found"
      end
    end

    def show
      @pages = Lookbook.pages
      @page = @pages.find_by_path(params[:path])
      if @page
        @page_content = page_controller.render_page(@page)
        @next_page = @pages.find_next(@page)
        @previous_page = @pages.find_previous(@page)
        @title = @page.title
      else
        @title = "Not found"
        render "not_found"
      end
    end

    protected

    def page_controller
      controller_class = Lookbook.config.page_controller.constantize
      controller = controller_class.new
      controller.request = request
      controller
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lookbook-0.7.1 app/controllers/lookbook/pages_controller.rb
lookbook-0.7.0 app/controllers/lookbook/pages_controller.rb