volt 0.9.4 → 0.9.5.pre1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -1
- data/Gemfile +3 -1
- data/lib/volt/cli/asset_compile.rb +8 -9
- data/lib/volt/extra_core/object.rb +3 -1
- data/lib/volt/models/associations.rb +9 -6
- data/lib/volt/models/buffer.rb +3 -0
- data/lib/volt/models/field_helpers.rb +38 -21
- data/lib/volt/models/model.rb +1 -1
- data/lib/volt/models/permissions.rb +2 -2
- data/lib/volt/models/validations/validations.rb +5 -1
- data/lib/volt/models/validators/numericality_validator.rb +6 -2
- data/lib/volt/page/bindings/each_binding.rb +7 -0
- data/lib/volt/page/bindings/view_binding.rb +22 -20
- data/lib/volt/server/component_templates.rb +21 -7
- data/lib/volt/server/message_bus/message_encoder.rb +4 -0
- data/lib/volt/server/message_bus/peer_to_peer/peer_connection.rb +1 -1
- data/lib/volt/server/middleware/default_middleware_stack.rb +1 -5
- data/lib/volt/server/rack/asset_files.rb +59 -13
- data/lib/volt/server/rack/component_code.rb +1 -7
- data/lib/volt/server/rack/index_files.rb +12 -4
- data/lib/volt/server/rack/opal_files.rb +29 -7
- data/lib/volt/server/template_handlers/sprockets_component_handler.rb +163 -0
- data/lib/volt/server.rb +2 -3
- data/lib/volt/utils/generic_pool.rb +1 -1
- data/lib/volt/version.rb +1 -1
- data/lib/volt/volt/app.rb +1 -1
- data/lib/volt.rb +6 -1
- data/spec/apps/kitchen_sink/config/base/index.html +3 -7
- data/spec/integration/bindings_spec.rb +1 -0
- data/spec/models/associations_spec.rb +18 -0
- data/spec/models/buffer_spec.rb +12 -0
- data/spec/server/rack/asset_files_spec.rb +35 -25
- data/templates/project/config/base/index.html +2 -7
- data/volt.gemspec +5 -5
- metadata +13 -28
- data/lib/volt/server/component_handler.rb +0 -42
- data/lib/volt/server/template_handlers/handlers.rb +0 -0
@@ -1,42 +0,0 @@
|
|
1
|
-
require 'stringio'
|
2
|
-
require 'volt'
|
3
|
-
require 'volt/server/rack/component_code'
|
4
|
-
|
5
|
-
module Volt
|
6
|
-
class ComponentHandler
|
7
|
-
def initialize(component_paths)
|
8
|
-
@component_paths = component_paths
|
9
|
-
end
|
10
|
-
|
11
|
-
def call(env)
|
12
|
-
req = Rack::Request.new(env)
|
13
|
-
|
14
|
-
path = req.path.strip
|
15
|
-
|
16
|
-
request_source_map = (File.extname(path) == '.map')
|
17
|
-
|
18
|
-
# TODO: Sanatize template path
|
19
|
-
component_name = path.gsub(/^\/components\//, '').gsub(/[.](js|map)$/, '')
|
20
|
-
|
21
|
-
javascript_code = compile_for_component(component_name, true, request_source_map)
|
22
|
-
|
23
|
-
[200, { 'Content-Type' => 'application/javascript; charset=utf-8' }, StringIO.new(javascript_code)]
|
24
|
-
end
|
25
|
-
|
26
|
-
def compile_for_component(component_name, for_client, map = false)
|
27
|
-
code = ComponentCode.new(component_name, @component_paths, for_client).code
|
28
|
-
|
29
|
-
# Compile the code
|
30
|
-
# javascript_code = Opal.compile(code)
|
31
|
-
builder = Opal::Builder.new.build_str(code, 'app.rb')
|
32
|
-
|
33
|
-
if map
|
34
|
-
js_code = builder.source_map
|
35
|
-
else
|
36
|
-
js_code = builder.to_s + "\n//# sourceMappingURL=#{component_name}.map"
|
37
|
-
end
|
38
|
-
|
39
|
-
js_code
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
File without changes
|