Class: Lookbook::PagesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/lookbook/pages_controller.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.controller_pathObject



7
8
9
# File 'app/controllers/lookbook/pages_controller.rb', line 7

def self.controller_path
  "lookbook/pages"
end

Instance Method Details

#indexObject



11
12
13
14
15
16
17
18
# File 'app/controllers/lookbook/pages_controller.rb', line 11

def index
  landing = Lookbook.pages.find(&:landing?) || Lookbook.pages.first
  if landing.present?
    redirect_to lookbook_page_path(landing.path)
  else
    show_404
  end
end

#showObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/controllers/lookbook/pages_controller.rb', line 20

def show
  @page = @pages.find_by_path(params[:path])
  if @page
    @next_page = @pages.next(@page)
    @previous_page = @pages.previous(@page)
    begin
      @page_content = page_controller.render_page(@page)
      @title = @page.title
    rescue => exception
      render_in_layout "lookbook/error",
        layout: "lookbook/page",
        error: Lookbook::Error.new(exception, file_path: @page.file_path, source_code: @page.content)
    end
  else
    show_404
  end
end