Sha256: cdcbe6d2d2c5b17fec4656f756d4e9c0c112d98aeeb7c70ea9b1641c3cb1c02b

Contents?: true

Size: 911 Bytes

Versions: 15

Compression:

Stored size: 911 Bytes

Contents

module PandaCms
  class PagesController < ApplicationController
    include ActionView::Helpers::TagHelper
    before_action :set_paper_trail_whodunnit

    def root
      params[:path] = ""
      show
    end

    def show
      if PandaCms.require_login_to_view && !user_signed_in?
        redirect_to panda_cms_maintenance_path and return
      end

      path_to_find = "/" + params[:path].to_s
      page = Page.find_by(path: path_to_find) || Page.find_by(path: "/404")
      PandaCms::Current.page = page

      if page
        globals = {
          page: page,
          title: page.title
        }

        render inline: "", assigns: globals, status: :ok, layout: page.template.file_path
      else
        # This works for now, but we may want to override in future (e.g. custom 404s)
        render file: "#{Rails.root}/public/404.html", layout: false, status: :not_found
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
panda_cms-0.3.6 app/controllers/panda_cms/pages_controller.rb
panda_cms-0.3.5 app/controllers/panda_cms/pages_controller.rb
panda_cms-0.3.4 app/controllers/panda_cms/pages_controller.rb
panda_cms-0.3.3 app/controllers/panda_cms/pages_controller.rb
panda_cms-0.3.2 app/controllers/panda_cms/pages_controller.rb
panda_cms-0.3.1 app/controllers/panda_cms/pages_controller.rb
panda_cms-0.3.0 app/controllers/panda_cms/pages_controller.rb
panda_cms-0.2.7 app/controllers/panda_cms/pages_controller.rb
panda_cms-0.2.6 app/controllers/panda_cms/pages_controller.rb
panda_cms-0.2.5 app/controllers/panda_cms/pages_controller.rb
panda_cms-0.2.4 app/controllers/panda_cms/pages_controller.rb
panda_cms-0.2.3 app/controllers/panda_cms/pages_controller.rb
panda_cms-0.2.2 app/controllers/panda_cms/pages_controller.rb
panda_cms-0.2.1 app/controllers/panda_cms/pages_controller.rb
panda_cms-0.2.0 app/controllers/panda_cms/pages_controller.rb