Sha256: 548ada19b3872ceda7a98382b6c6d39a92575cdac5000dbe8a563170a04713d8

Contents?: true

Size: 1.49 KB

Versions: 13

Compression:

Stored size: 1.49 KB

Contents

class ForgeController < ApplicationController
  before_filter :require_admin, :load_help, :get_menu_items, :set_crumbs, :set_title
  layout 'forge'

  rescue_from CanCan::AccessDenied do |exception|
    flash[:warning] = exception.message
    redirect_to '/forge'
  end

  def uses_ckeditor
    @uses_ckeditor = true
  end

  def load_help
    @help_slug = "#{params[:controller].split('/')[1]}_#{params[:action]}"
  end

  def get_menu_items
    require 'rails/application/route_inspector'

    # Read the routes to find out which partials to load to build the menu
    inspector = Rails::Application::RouteInspector.new
    controllers = inspector.collect_routes(Rails.application.routes.routes).select do |route|
      route[:reqs].match('forge')
    end.map do |route|
      route[:reqs].gsub('forge/', '').gsub(/#.*/, '')
    end
    @menu_items = controllers.reject {|c| c == "index"}.uniq!
  end

  def set_crumbs
    @controller_crumb = params[:controller]
    @action_crumb = params[:action]
  end

  def set_title
    case params[:action]
      when "new", "create"
        @page_title = "New #{params[:controller].gsub('forge/', '').singularize.humanize} - Forge".titleize
      when "edit", "update"
        @page_title = "Edit #{params[:controller].gsub('forge/', '').singularize.humanize} - Forge".titleize
      else
        @page_title = params[:controller].gsub('forge/', '').humanize.titleize + " - Forge"
      end
    @page_title = "Forge" if params[:controller].gsub('forge/', '') == "index"
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
forge-cli-0.0.18 lib/forge/app/controllers/forge_controller.rb
forge-cli-0.0.17 lib/forge/app/controllers/forge_controller.rb
forge-cli-0.0.16 lib/forge/app/controllers/forge_controller.rb
forge-cli-0.0.15 lib/forge/app/controllers/forge_controller.rb
forge-cli-0.0.14 lib/forge/app/controllers/forge_controller.rb
forge-cli-0.0.13 lib/forge/app/controllers/forge_controller.rb
forge-cli-0.0.12 lib/forge/app/controllers/forge_controller.rb
forge-cli-0.0.11 lib/forge/app/controllers/forge_controller.rb
forge-cli-0.0.10 lib/forge/app/controllers/forge_controller.rb
forge-cli-0.0.9 lib/forge/app/controllers/forge_controller.rb
forge-cli-0.0.8 lib/forge/app/controllers/forge_controller.rb
forge-cli-0.0.7 lib/forge/app/controllers/forge_controller.rb
forge-cli-0.0.6 lib/forge/app/controllers/forge_controller.rb