Sha256: 6ef9d8e0dd095ef952c24ef60d8e50c2bda29f84a191719a05d214d176246a56

Contents?: true

Size: 869 Bytes

Versions: 8

Compression:

Stored size: 869 Bytes

Contents

require_dependency "storytime/application_controller"

module Storytime
  class PagesController < ApplicationController
    before_action :ensure_site, unless: ->{ params[:controller] == "storytime/dashboard/sites" }

    def show
      @page = if request.path == "/"
        Page.published.find @site.root_post_id 
      elsif params[:preview]
        page = Page.find_preview(params[:id])
        page.content = page.autosave.content
        page.preview = true
        page
      else
        Page.published.friendly.find(params[:id])
      end
      
      if params[:preview].nil? && ((params[:id] != @page.slug) && (request.path != "/"))
        return redirect_to @page, :status => :moved_permanently
      end

      #allow overriding in the host app
      render @page.slug if lookup_context.template_exists?("storytime/pages/#{@page.slug}")
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
storytime-1.2.0 app/controllers/storytime/pages_controller.rb
storytime-1.1.1 app/controllers/storytime/pages_controller.rb
storytime-1.0.7 app/controllers/storytime/pages_controller.rb
storytime-1.0.6 app/controllers/storytime/pages_controller.rb
storytime-1.0.5 app/controllers/storytime/pages_controller.rb
storytime-1.0.2 app/controllers/storytime/pages_controller.rb
storytime-1.0.1 app/controllers/storytime/pages_controller.rb
storytime-1.0.0 app/controllers/storytime/pages_controller.rb