Class: Volt::IndexFiles
Instance Method Summary collapse
- #call(env) ⇒ Object
- #css_files(*args) ⇒ Object
- #css_tags ⇒ Object
- #html ⇒ Object
-
#initialize(rack_app, volt_app, component_paths, opal_files) ⇒ IndexFiles
constructor
A new instance of IndexFiles.
- #javascript_files(*args) ⇒ Object
- #javascript_tags ⇒ Object
- #route_match?(path) ⇒ Boolean
Constructor Details
#initialize(rack_app, volt_app, component_paths, opal_files) ⇒ IndexFiles
Returns a new instance of IndexFiles.
7 8 9 10 11 12 13 14 |
# File 'lib/volt/server/rack/index_files.rb', line 7 def initialize(rack_app, volt_app, component_paths, opal_files) @rack_app = rack_app @volt_app = volt_app @component_paths = component_paths @opal_files = opal_files @@router = volt_app.router end |
Instance Method Details
#call(env) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/volt/server/rack/index_files.rb', line 24 def call(env) if route_match?(env['PATH_INFO']) [200, { 'Content-Type' => 'text/html; charset=utf-8' }, [html]] else @rack_app.call env end end |
#css_files(*args) ⇒ Object
43 44 45 |
# File 'lib/volt/server/rack/index_files.rb', line 43 def css_files(*args) fail "Deprecation: #css_files is deprecated in config/base/index.html, opal 0.8 required a new format." end |
#css_tags ⇒ Object
52 53 54 |
# File 'lib/volt/server/rack/index_files.rb', line 52 def AssetFiles.from_cache(@volt_app.app_url, 'main', @component_paths). end |
#html ⇒ Object
32 33 34 35 36 37 |
# File 'lib/volt/server/rack/index_files.rb', line 32 def html index_path = File.(File.join(Volt.root, 'config/base/index.html')) html = File.read(index_path) ERB.new(html, nil, '-').result(binding) end |
#javascript_files(*args) ⇒ Object
39 40 41 |
# File 'lib/volt/server/rack/index_files.rb', line 39 def javascript_files(*args) fail "Deprecation: #javascript_files is deprecated in config/base/index.html, opal 0.8 required a new format." end |
#javascript_tags ⇒ Object
47 48 49 50 |
# File 'lib/volt/server/rack/index_files.rb', line 47 def # TODO: Cache somehow, this is being loaded every time AssetFiles.from_cache(@volt_app.app_url, 'main', @component_paths).(@volt_app) end |
#route_match?(path) ⇒ Boolean
16 17 18 19 20 21 22 |
# File 'lib/volt/server/rack/index_files.rb', line 16 def route_match?(path) params = @@router.url_to_params(path) return params if params false end |