glimmer-dsl-opal 0.12.0 → 0.16.0
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 +22 -0
- data/README.md +179 -1296
- data/VERSION +1 -1
- data/app/controllers/glimmer/application_controller.rb +4 -0
- data/app/controllers/glimmer/image_paths_controller.rb +46 -0
- data/app/views/glimmer/image_paths/index.html.erb +1 -0
- data/{lib/glimmer-dsl-opal/samples/hello/hello_computed/contact.rb → config/routes.rb} +2 -20
- data/lib/glimmer-dsl-opal.rb +9 -3
- data/lib/glimmer-dsl-opal/ext/file.rb +25 -0
- data/lib/glimmer-dsl-opal/samples/elaborate/contact_manager.rb +0 -2
- data/lib/glimmer-dsl-opal/samples/elaborate/weather.rb +157 -0
- data/lib/glimmer-dsl-opal/samples/hello/hello_button.rb +7 -7
- data/lib/glimmer-dsl-opal/samples/hello/hello_checkbox.rb +16 -14
- data/lib/glimmer-dsl-opal/samples/hello/hello_checkbox_group.rb +14 -9
- data/lib/glimmer-dsl-opal/samples/hello/hello_combo.rb +24 -22
- data/lib/glimmer-dsl-opal/samples/hello/hello_computed.rb +27 -9
- data/lib/glimmer-dsl-opal/samples/hello/hello_custom_shell.rb +15 -11
- data/lib/glimmer-dsl-opal/samples/hello/hello_custom_widget.rb +1 -1
- data/lib/glimmer-dsl-opal/samples/hello/hello_radio.rb +18 -16
- data/lib/glimmer-dsl-opal/samples/hello/hello_radio_group.rb +17 -12
- data/lib/glimmer-dsl-opal/samples/hello/hello_table.rb +29 -21
- data/lib/glimmer-dsl-opal/samples/hello/hello_table/baseball_park.png +0 -0
- data/lib/glimmer/config.rb +11 -0
- data/lib/glimmer/dsl/opal/custom_widget_expression.rb +2 -2
- data/lib/glimmer/engine.rb +21 -0
- data/lib/glimmer/swt/composite_proxy.rb +34 -0
- data/lib/glimmer/swt/label_proxy.rb +15 -2
- data/lib/glimmer/swt/shell_proxy.rb +43 -0
- data/lib/glimmer/swt/table_item_proxy.rb +3 -0
- data/lib/glimmer/ui/custom_widget.rb +11 -2
- data/lib/net/http.rb +15 -6
- metadata +9 -3
Binary file
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module Glimmer
|
2
|
+
# Consumer Rails apps can set these attributes in their assets.rb file
|
3
|
+
module Config
|
4
|
+
class << self
|
5
|
+
# (server-side option) used to collect image paths for copying to assets & matching in Opal to download and use in Glimmer GUI
|
6
|
+
def gems_having_image_paths
|
7
|
+
@gems_having_image_paths ||= []
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -87,8 +87,8 @@ module Glimmer
|
|
87
87
|
|
88
88
|
def add_content(parent, keyword, *args, &block)
|
89
89
|
return unless parent.is_a?(Glimmer::UI::CustomWidget)
|
90
|
-
# TODO consider avoiding source_location
|
91
|
-
if block.source_location == parent.content&.__getobj__
|
90
|
+
# TODO consider avoiding source_location since it does not work in Opal
|
91
|
+
if block.source_location && (block.source_location == parent.content&.__getobj__&.source_location)
|
92
92
|
parent.content.call(parent) unless parent.content.called?
|
93
93
|
else
|
94
94
|
super
|
data/lib/glimmer/engine.rb
CHANGED
@@ -1,3 +1,24 @@
|
|
1
|
+
# Copyright (c) 2020-2021 Andy Maleh
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
# a copy of this software and associated documentation files (the
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
# the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be
|
12
|
+
# included in all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
1
22
|
module Glimmer
|
2
23
|
class Engine < ::Rails::Engine
|
3
24
|
isolate_namespace Glimmer
|
@@ -1,3 +1,24 @@
|
|
1
|
+
# Copyright (c) 2020-2021 Andy Maleh
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
# a copy of this software and associated documentation files (the
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
# the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be
|
12
|
+
# included in all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
1
22
|
require 'glimmer/swt/grid_layout_proxy'
|
2
23
|
require 'glimmer/swt/widget_proxy'
|
3
24
|
|
@@ -41,6 +62,19 @@ module Glimmer
|
|
41
62
|
# TODO implement layout(changed = nil, all = nil) just as per SWT API
|
42
63
|
@layout&.layout(self, changed)
|
43
64
|
end
|
65
|
+
|
66
|
+
# background image
|
67
|
+
def background_image
|
68
|
+
@background_image
|
69
|
+
end
|
70
|
+
|
71
|
+
# background image is stretched by default
|
72
|
+
def background_image=(value)
|
73
|
+
@background_image = value
|
74
|
+
dom_element.css('background-image', "url(#{background_image})")
|
75
|
+
dom_element.css('background-repeat', 'no-repeat')
|
76
|
+
dom_element.css('background-size', 'cover')
|
77
|
+
end
|
44
78
|
|
45
79
|
end
|
46
80
|
|
@@ -40,12 +40,12 @@ module Glimmer
|
|
40
40
|
text&.gsub("\n", '<br />')
|
41
41
|
end
|
42
42
|
|
43
|
-
|
43
|
+
# def background_image=(*image_options)
|
44
44
|
# TODO consider if there is a difference between background_image and image in label and to have one reuse the other
|
45
45
|
# TODO finish implementation
|
46
46
|
# @background_image = Glimmer::SWT::ImageProxy.create(*image_options)
|
47
47
|
# dom_element.css('background-image', @background_image.image_data.dom_element.src)
|
48
|
-
|
48
|
+
# end
|
49
49
|
|
50
50
|
def image=(*image_options)
|
51
51
|
# TODO finish implementation
|
@@ -53,6 +53,19 @@ module Glimmer
|
|
53
53
|
# dom_element.css('background-image', @image.image_data.dom_element.src)
|
54
54
|
end
|
55
55
|
|
56
|
+
# background image
|
57
|
+
def background_image
|
58
|
+
@background_image
|
59
|
+
end
|
60
|
+
|
61
|
+
# background image is stretched by default
|
62
|
+
def background_image=(value)
|
63
|
+
@background_image = value
|
64
|
+
dom_element.css('background-image', "url(#{background_image})")
|
65
|
+
dom_element.css('background-repeat', 'no-repeat')
|
66
|
+
dom_element.css('background-size', 'cover')
|
67
|
+
end
|
68
|
+
|
56
69
|
def element
|
57
70
|
'label'
|
58
71
|
end
|
@@ -1,3 +1,24 @@
|
|
1
|
+
# Copyright (c) 2020-2021 Andy Maleh
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
# a copy of this software and associated documentation files (the
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
# the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be
|
12
|
+
# included in all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
1
22
|
require 'glimmer/swt/widget_proxy'
|
2
23
|
require 'glimmer/swt/layout_proxy'
|
3
24
|
require 'glimmer/swt/display_proxy'
|
@@ -71,6 +92,28 @@ module Glimmer
|
|
71
92
|
Document.title = value
|
72
93
|
end
|
73
94
|
|
95
|
+
# favicon
|
96
|
+
def image
|
97
|
+
@image
|
98
|
+
end
|
99
|
+
|
100
|
+
def image=(value)
|
101
|
+
@image = value
|
102
|
+
# TODO consider moving this code to favicon_dom_element
|
103
|
+
if favicon_dom_element.empty?
|
104
|
+
favicon_element = Element.new(:link)
|
105
|
+
favicon_element.attr('rel', 'icon')
|
106
|
+
Document.find('head').append(favicon_element)
|
107
|
+
else
|
108
|
+
favicon_element = favicon_dom_element
|
109
|
+
end
|
110
|
+
favicon_element.attr('href', image)
|
111
|
+
end
|
112
|
+
|
113
|
+
def favicon_dom_element
|
114
|
+
Document.find('link[rel=icon]')
|
115
|
+
end
|
116
|
+
|
74
117
|
def minimum_size=(width_or_minimum_size, height = nil)
|
75
118
|
@minimum_size = height.nil? ? width_or_minimum_size : Point.new(width_or_minimum_size, height)
|
76
119
|
return if @minimum_size.nil?
|
@@ -83,6 +83,16 @@ module Glimmer
|
|
83
83
|
@after_body_blocks ||= []
|
84
84
|
@after_body_blocks << block
|
85
85
|
end
|
86
|
+
|
87
|
+
def keyword
|
88
|
+
self.name.underscore.gsub('::', '__')
|
89
|
+
end
|
90
|
+
|
91
|
+
# Returns shortcut keyword to use for this custom widget (keyword minus namespace)
|
92
|
+
def shortcut_keyword
|
93
|
+
self.name.underscore.gsub('::', '__').split('__').last
|
94
|
+
end
|
95
|
+
|
86
96
|
end
|
87
97
|
|
88
98
|
class << self
|
@@ -143,7 +153,6 @@ module Glimmer
|
|
143
153
|
def reset_custom_widget_namespaces
|
144
154
|
@custom_widget_namespaces = Set[Object, Glimmer::UI]
|
145
155
|
end
|
146
|
-
|
147
156
|
end
|
148
157
|
# <- end of class methods
|
149
158
|
|
@@ -259,7 +268,7 @@ module Glimmer
|
|
259
268
|
# Otherwise, if a block is passed, it adds it as content to this custom widget
|
260
269
|
def content(&block)
|
261
270
|
if block_given?
|
262
|
-
|
271
|
+
Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::Opal::CustomWidgetExpression.new, self.class.keyword, &block)
|
263
272
|
else
|
264
273
|
@content
|
265
274
|
end
|
data/lib/net/http.rb
CHANGED
@@ -19,8 +19,6 @@
|
|
19
19
|
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
20
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
21
|
|
22
|
-
# Missing Net module class methods TODO implement
|
23
|
-
|
24
22
|
require_relative '../uri'
|
25
23
|
|
26
24
|
module Net
|
@@ -30,11 +28,22 @@ module Net
|
|
30
28
|
class HTTP
|
31
29
|
class << self
|
32
30
|
def post_form(uri, params)
|
33
|
-
|
34
|
-
result =
|
35
|
-
|
31
|
+
uri = "#{`window.location.protocol`}//#{File.join(uri)}" unless uri.start_with?('http:') || uri.start_with?('https:') # TODO refactor repetitive code
|
32
|
+
result = nil
|
33
|
+
::HTTP.post(uri, {async: false, dataType: 'text', data: params}) do |response|
|
34
|
+
result = response.body if response.ok?
|
35
|
+
end
|
36
|
+
result
|
37
|
+
end
|
38
|
+
|
39
|
+
def get(uri, path_and_params)
|
40
|
+
uri = File.join(uri, path_and_params)
|
41
|
+
uri = "#{`window.location.protocol`}//#{uri}" unless uri.start_with?('http:') || uri.start_with?('https:') # TODO refactor repetitive code
|
42
|
+
result = nil
|
43
|
+
::HTTP.get(uri, {async: false, dataType: 'text'}) do |response|
|
44
|
+
result = response.body if response.ok?
|
36
45
|
end
|
37
|
-
|
46
|
+
result
|
38
47
|
end
|
39
48
|
end
|
40
49
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glimmer-dsl-opal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.16.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- AndyMaleh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-07-
|
11
|
+
date: 2021-07-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: glimmer
|
@@ -263,6 +263,10 @@ files:
|
|
263
263
|
- app/assets/stylesheets/glimmer/jquery-ui.structure.css
|
264
264
|
- app/assets/stylesheets/glimmer/jquery-ui.theme.css
|
265
265
|
- app/assets/stylesheets/glimmer/jquery.ui.timepicker.css
|
266
|
+
- app/controllers/glimmer/application_controller.rb
|
267
|
+
- app/controllers/glimmer/image_paths_controller.rb
|
268
|
+
- app/views/glimmer/image_paths/index.html.erb
|
269
|
+
- config/routes.rb
|
266
270
|
- lib/display.rb
|
267
271
|
- lib/glimmer-dsl-opal.rb
|
268
272
|
- lib/glimmer-dsl-opal/ext/class.rb
|
@@ -278,13 +282,13 @@ files:
|
|
278
282
|
- lib/glimmer-dsl-opal/samples/elaborate/tic_tac_toe.rb
|
279
283
|
- lib/glimmer-dsl-opal/samples/elaborate/tic_tac_toe/board.rb
|
280
284
|
- lib/glimmer-dsl-opal/samples/elaborate/tic_tac_toe/cell.rb
|
285
|
+
- lib/glimmer-dsl-opal/samples/elaborate/weather.rb
|
281
286
|
- lib/glimmer-dsl-opal/samples/hello/hello_browser.rb
|
282
287
|
- lib/glimmer-dsl-opal/samples/hello/hello_button.rb
|
283
288
|
- lib/glimmer-dsl-opal/samples/hello/hello_checkbox.rb
|
284
289
|
- lib/glimmer-dsl-opal/samples/hello/hello_checkbox_group.rb
|
285
290
|
- lib/glimmer-dsl-opal/samples/hello/hello_combo.rb
|
286
291
|
- lib/glimmer-dsl-opal/samples/hello/hello_computed.rb
|
287
|
-
- lib/glimmer-dsl-opal/samples/hello/hello_computed/contact.rb
|
288
292
|
- lib/glimmer-dsl-opal/samples/hello/hello_custom_shell.rb
|
289
293
|
- lib/glimmer-dsl-opal/samples/hello/hello_custom_widget.rb
|
290
294
|
- lib/glimmer-dsl-opal/samples/hello/hello_date_time.rb
|
@@ -299,6 +303,7 @@ files:
|
|
299
303
|
- lib/glimmer-dsl-opal/samples/hello/hello_radio_group.rb
|
300
304
|
- lib/glimmer-dsl-opal/samples/hello/hello_tab.rb
|
301
305
|
- lib/glimmer-dsl-opal/samples/hello/hello_table.rb
|
306
|
+
- lib/glimmer-dsl-opal/samples/hello/hello_table/baseball_park.png
|
302
307
|
- lib/glimmer-dsl-opal/samples/hello/hello_world.rb
|
303
308
|
- lib/glimmer-dsl-opal/vendor/jquery-ui-timepicker/GPL-LICENSE.txt
|
304
309
|
- lib/glimmer-dsl-opal/vendor/jquery-ui-timepicker/MIT-LICENSE.txt
|
@@ -319,6 +324,7 @@ files:
|
|
319
324
|
- lib/glimmer-dsl-opal/vendor/jquery-ui/package.json
|
320
325
|
- lib/glimmer-dsl-opal/vendor/jquery.js
|
321
326
|
- lib/glimmer-dsl-swt.rb
|
327
|
+
- lib/glimmer/config.rb
|
322
328
|
- lib/glimmer/config/opal_logger.rb
|
323
329
|
- lib/glimmer/data_binding/element_binding.rb
|
324
330
|
- lib/glimmer/data_binding/list_selection_binding.rb
|