Class: MegaBar::LayoutEngine
Instance Method Summary
collapse
#build_block_info, #build_params_hash, #first_tab, #get_filtered_blocks, #has_html_content?, #mega_filtered, #process_block, #process_blocks, #process_model_display_block, #render_block_content, #render_html_block, #render_layout_section, #setup_block_classes, #setup_environment
#get_template_section, #process_layout_section, #process_layouts, #process_page_layout, #render_megabar_page
#handle_non_megabar_page, #handle_static_assets, #set_page_info, #set_pagination_info, #set_rout, #setup_request_environment, #setup_routing, #setup_session, #setup_site, #static_asset?
Constructor Details
#initialize(app = nil, message = "Response Time") ⇒ LayoutEngine
honestly, this is a hugely important file, but there shouldn’t be anything in this file that concerns regular developers or users. Here we figure out which is the current page, then collect which blocks go on a layout and which layouts go on a page. For each block, if it holds a model_display, we’ll call the controller for that model. treat your controllers and models like you would in a normal rails app. this does set some environment variables that are then used in your controllers, but inspect them there. if you’ve set up your page->layouts->blocks->model_displays->field_displays properly this should just work. if you’ve created a page using the gui and its not working.. check it’s path setting and check your routes file to see that they are looking right.
22
23
24
25
|
# File 'lib/mega_bar/layout_engine.rb', line 22
def initialize(app = nil, message = "Response Time")
@app = app
@message = message
end
|
Instance Method Details
#_call(env) ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/mega_bar/layout_engine.rb', line 31
def _call(env)
puts "🔍 DEBUG: _call - PATH_INFO: #{env['PATH_INFO']}, METHOD: #{env['REQUEST_METHOD']}"
return handle_static_assets(env) if static_asset?(env)
path_info = env['PATH_INFO']
if is_devise_route?(path_info)
puts "🔍 DEBUG: Early Devise route detection: #{path_info}"
puts "🔍 DEBUG: Passing through to host application immediately"
return @app.call(env)
end
setup_warden(env)
setup_request_environment(env)
puts "🔍 DEBUG: _call - mega_page: #{env[:mega_page].inspect}"
return handle_non_megabar_page(env) if env[:mega_page].empty?
render_megabar_page(env)
end
|
#call(env) ⇒ Object
27
28
29
|
# File 'lib/mega_bar/layout_engine.rb', line 27
def call(env)
dup._call(env)
end
|
#each(&display) ⇒ Object
67
68
69
70
|
# File 'lib/mega_bar/layout_engine.rb', line 67
def each(&display)
display.call("<!-- #{@message}: #{@stop - @start} -->\n") if (!@headers["Content-Type"].nil? && @headers["Content-Type"].include?("text/html"))
@response.each(&display)
end
|
#is_devise_route?(path_info) ⇒ Boolean
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
# File 'lib/mega_bar/layout_engine.rb', line 83
def is_devise_route?(path_info)
devise_patterns = [
/^\/users\/sign_in$/,
/^\/users\/sign_up$/,
/^\/users\/sign_out$/,
/^\/users\/password\/new$/,
/^\/users\/password$/,
/^\/users\/password\/edit$/,
/^\/users\/confirmation$/,
/^\/users\/confirmation\/new$/,
/^\/users\/unlock\/new$/,
/^\/users\/unlock$/,
/^\/users\/edit$/,
/^\/users\/cancel$/,
/^\/users\/sign_up\/.*$/, /^\/users\/sign_in\/.*$/ ]
devise_patterns.any? { |pattern| path_info.match?(pattern) }
end
|
#setup_warden(env) ⇒ Object
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/mega_bar/layout_engine.rb', line 54
def setup_warden(env)
return unless defined?(Warden)
unless env['warden']
puts "🔍 DEBUG: Setting up Warden proxy"
env['warden'] = Warden::Proxy.new(env, Warden::Manager.new(nil))
end
end
|