Class: Inkling::HomeController

Inherits:
BaseController show all
Defined in:
app/controllers/inkling/home_controller.rb

Instance Method Summary collapse

Instance Method Details

#dashboard_partialsObject



15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/controllers/inkling/home_controller.rb', line 15

def dashboard_partials
  partials = []

  for engine in Rails.application.railties.engines
    dashboard_partials = scan_path_for_dashboard_partial(engine)
    partials += dashboard_partials if dashboard_partials.any?
  end
  
  partials += scan_path_for_dashboard_partial(Rails.application)
  
  partials
end

#render_dashboard_partialsObject

protected these methods would be better in a helper, but it seems helpers have issues loading from engines.



8
9
10
11
12
# File 'app/controllers/inkling/home_controller.rb', line 8

def render_dashboard_partials
  for file in dashboard_partials
  	render(:file => file)
	end
end

#scan_path_for_dashboard_partial(application) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'app/controllers/inkling/home_controller.rb', line 28

def scan_path_for_dashboard_partial(application)
  partials = []
  for path in application.paths.app.views
    if path =~ /views/
	    if File.exist?("#{path}/inkling/home/")
		    for entry in Dir.entries("#{path}/inkling/home/")
			    if entry =~ /_dashboard\./
				    partials << "#{path}/inkling/home/#{entry}"		
			    end
		    end
	    end
    end    
  end
  
  partials
end