Sha256: dff9bc1b1c0873498613399d1b5c2474808b2cfffadae71efddef2267ff42aef
Contents?: true
Size: 1.57 KB
Versions: 13
Compression:
Stored size: 1.57 KB
Contents
module Effective class PagesController < ApplicationController include Effective::CrudController def show @pages = Effective::Page.deep.all @pages = @pages.published unless EffectiveResources.authorized?(self, :admin, :effective_pages) @page = @pages.find(params[:id]) raise ActionController::RoutingError.new('Not Found') if @page.menu_root_with_children? if @page.authenticate_user? || @page.roles.present? authenticate_user! end raise Effective::AccessDenied.new('Access Denied', :show, @page) unless @page.roles_permit?(current_user) EffectiveResources.authorize!(self, :show, @page) @page_title = @page.title @meta_description = @page.meta_description @canonical_url = effective_pages.page_url(@page) if EffectiveResources.authorized?(self, :admin, :effective_pages) flash.now[:warning] = [ 'Hi Admin!', ('You are viewing a draft page.' unless @page.published?), ("<a href='#{effective_pages.edit_admin_page_path(@page)}' class='alert-link' data-turbolinks='false'>Click here to edit this page</a>.") ].compact.join(' ') end template = File.join(EffectivePages.pages_path, @page.template) layout = File.join(EffectivePages.layouts_path, @page.layout) respond_to do |format| format.html { render(template, layout: layout, locals: { page: @page }) } end end private def admin_edit? EffectiveResources.authorized?(self, :admin, :effective_pages) && (params[:edit].to_s == 'true') end end end
Version data entries
13 entries across 13 versions & 1 rubygems