Sha256: 8de0fbc51a134f63dd8349a1b0f58df36b04a5faf51be35658226d48c0260e5b

Contents?: true

Size: 1.05 KB

Versions: 9

Compression:

Stored size: 1.05 KB

Contents

# The primary Manifest admin controller. Mostly used for determining {#current_editor} and for authorization.
class Manifest::ManifestController < ApplicationController
  before_filter :authorize

  layout 'manifest/manifest'

  private

  # @return [Editor] the currently signed-in {Editor}, or nil.
  def current_editor
    @current_editor ||= Editor.find(session[:editor_id]) if session[:editor_id]
  end

  helper_method :current_editor

  # Redirects to login if {#current_editor} is nil.
  def authorize
    redirect_to manifest_login_url if current_editor.nil?
  end

  # Used to protect sensitive {Page} and {ContentBlock} actions from non-admin {Editor}s.
  def authorize_admin
    redirect_to manifest_path, alert: 'Admins only' unless current_editor.admin?
  end

  # Expires the cached version of every {Page} object view.
  def expire_all_pages
    expire_page '/index.html'

    Page.all.each do |p|
      expire_page "/#{p.slug}.html"
    end
  end

  def set_layout
    if request.headers['X-PJAX']
      false
    else
      'manifest/manifest'
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
manifest-rails-0.2.8 app/controllers/manifest/manifest_controller.rb
manifest-rails-0.2.7 app/controllers/manifest/manifest_controller.rb
manifest-rails-0.2.6 app/controllers/manifest/manifest_controller.rb
manifest-rails-0.2.5 app/controllers/manifest/manifest_controller.rb
manifest-rails-0.2.4 app/controllers/manifest/manifest_controller.rb
manifest-rails-0.2.3 app/controllers/manifest/manifest_controller.rb
manifest-rails-0.2.2 app/controllers/manifest/manifest_controller.rb
manifest-rails-0.2.1 app/controllers/manifest/manifest_controller.rb
manifest-rails-0.2.0 app/controllers/manifest/manifest_controller.rb