Class: ForgeController

Inherits:
ApplicationController show all
Defined in:
lib/forge/app/controllers/forge_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#app_init

Instance Method Details

#get_menu_itemsObject



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/forge/app/controllers/forge_controller.rb', line 18

def get_menu_items
  # TODO: we're really not supposed to be reading the routes like this
  # Read the routes to find out which partials to load to build the menu
  routes = Rails.application.routes.routes
  inspector = ActionDispatch::Routing::RoutesInspector.new(routes)
  formatter = ActionDispatch::Routing::ConsoleFormatter.new
  controllers = inspector.format(formatter).split("\n").select do |route|
    route.match('forge')
  end.map do |route|
    route.gsub(/.*\)\s+/,'').gsub("forge/","").gsub(/#.*/, "")
  end
  @menu_items = controllers.reject {|c| c == "index"}.uniq!
end

#load_helpObject



14
15
16
# File 'lib/forge/app/controllers/forge_controller.rb', line 14

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

#set_crumbsObject



32
33
34
35
# File 'lib/forge/app/controllers/forge_controller.rb', line 32

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

#set_titleObject



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/forge/app/controllers/forge_controller.rb', line 37

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

#uses_ckeditorObject



10
11
12
# File 'lib/forge/app/controllers/forge_controller.rb', line 10

def uses_ckeditor
  @uses_ckeditor = true
end