glib-web 0.5.24 → 0.5.29

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/concerns/glib/json/new_dynamic_text.rb +1 -1
  3. data/app/helpers/glib/dynamic_images_helper.rb +7 -4
  4. data/app/helpers/glib/dynamic_texts_helper.rb +1 -1
  5. data/app/helpers/glib/json_ui/abstract_builder.rb +153 -154
  6. data/app/helpers/glib/json_ui/action_builder.rb +7 -0
  7. data/app/helpers/glib/json_ui/action_builder/http.rb +28 -8
  8. data/app/helpers/glib/json_ui/dynamic_field_builders.rb +4 -4
  9. data/app/helpers/glib/json_ui/menu_builder.rb +1 -1
  10. data/app/helpers/glib/json_ui/page_helper.rb +4 -4
  11. data/app/helpers/glib/json_ui/split_builders.rb +1 -1
  12. data/app/helpers/glib/json_ui/table_builders.rb +7 -7
  13. data/app/helpers/glib/json_ui/view_builder.rb +4 -1
  14. data/app/helpers/glib/json_ui/view_builder/fields.rb +5 -1
  15. data/app/helpers/glib/json_ui/view_builder/panels.rb +4 -1
  16. data/app/views/json_ui/garage/actions/_http.json.jbuilder +1 -1
  17. data/app/views/json_ui/garage/forms/_alert_post_data.json.jbuilder +0 -0
  18. data/app/views/json_ui/garage/forms/index.json.jbuilder +6 -0
  19. data/app/views/json_ui/garage/forms/new_rich_text.json.jbuilder +40 -0
  20. data/app/views/json_ui/garage/forms/pickers.json.jbuilder +6 -5
  21. data/app/views/json_ui/garage/forms/rich_text.json.jbuilder +3 -3
  22. data/app/views/json_ui/garage/forms/selects.json.jbuilder +0 -0
  23. data/app/views/json_ui/garage/forms/styled_boxes.json.jbuilder +0 -0
  24. data/app/views/json_ui/garage/lists/_autoload_section.json.jbuilder +1 -1
  25. data/app/views/json_ui/garage/lists/chat_ui.json.jbuilder +1 -20
  26. data/app/views/json_ui/garage/notifications/web_socket.json.jbuilder +3 -3
  27. data/app/views/json_ui/garage/panels/custom.json.jbuilder +2 -2
  28. data/app/views/json_ui/garage/panels/responsive.json.jbuilder +11 -1
  29. data/app/views/json_ui/garage/panels/split.json.jbuilder +0 -1
  30. data/app/views/json_ui/garage/panels/vertical.json.jbuilder +1 -1
  31. data/lib/glib-web.rb +1 -0
  32. data/lib/glib/json_crawler/router.rb +3 -0
  33. data/lib/glib/mailer_tester.rb +36 -0
  34. data/lib/glib/test_helpers.rb +0 -0
  35. metadata +3 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dc406a3897c823c3c4c9d9470811460a5c08a469178fcb965459b91cbef9b37a
4
- data.tar.gz: 3e38269b7c876f08e084aaa83a12bbe7476cc8724775e8f09ce429d927a133a9
3
+ metadata.gz: 7fbacc0893e8f36261c10fcfc5a1dd488d1170c10c4b901f14285a0c64212383
4
+ data.tar.gz: 00ac950fdf253428ec4b3b1eac29d709c817949df290fb97b065b0adb24e0156
5
5
  SHA512:
6
- metadata.gz: b048d67cd2cf79dc3b7e4f72d0da7ecfb8001a6d504cf933bacc46875f9ad044c1d704621794fea22439eb17bbabd3ca90e5c0ae8cd7b77e5b8e14c0fde86469
7
- data.tar.gz: b58a6fcacead2d9a23e37220fa39a108e1fb147d6e8109d1fabeabb17020647dba8968052015e083824d013c6decd3d3bb9df6ebae9389e2e7d532e35c890ed6
6
+ metadata.gz: 01feace7ab2d3333382d4aed1ef15091fd827c9346270c9393d498330350f32f9559ebbdc577f8c1088eac659cec3c910b99de2b27b64f19810bcbc745049c8a
7
+ data.tar.gz: c83f4a4d8414006746c70e8d692e788d0822ac19cc09964af687dfab1b07992205d69f5c82712fa8ff88c6adbf0b04ad815b40780bf4f0089bb32cc950a34e30
@@ -112,7 +112,7 @@ module Glib::Json::NewDynamicText
112
112
  def substitute_image_with(images)
113
113
  view[prop] = view[prop].gsub(/\{\{image(\d)\}\}/) {
114
114
  if image = images[$1.to_i - 1]
115
- ApplicationController.helpers.dynamic_image_url(image.blob.key)
115
+ ApplicationController.helpers.glib_dynamic_image_url(image.blob.key)
116
116
  else
117
117
  "{{image#{$1}}}"
118
118
  end
@@ -1,7 +1,7 @@
1
1
  module Glib
2
2
  module DynamicImagesHelper
3
3
  # NOTE: The bucket should probably be set as a parameter for json_libs
4
- def dynamic_image_url(blob_key, width: 100, height: 100, fit: 'clip', bucket: Rails.application.config.try(:aws_s3_bucket))
4
+ def glib_dynamic_image_url(blob_key, width: 100, height: 100, fit: 'clip', bucket: Rails.application.config.try(:aws_s3_bucket), signature_key: nil)
5
5
  return unless blob_key.present?
6
6
 
7
7
  full_params_hash = {
@@ -10,17 +10,20 @@ module Glib
10
10
  w: width,
11
11
  h: height,
12
12
  fit: fit,
13
- expires: 1.hours.from_now.to_i
13
+ # expires: 1.hours.from_now.to_i
14
+ expires: 1.month.from_now.end_of_month.to_i
14
15
  }
16
+
15
17
  request_params_hash = full_params_hash.except(:bucket_name, :blob_key)
16
18
 
17
- if (private_key = ENV['PRIVATE_API_KEY'])
19
+ if (private_key = signature_key)
18
20
  encryption_service = EncryptionService.new(bucket, private_key)
21
+ # This produces different signature every time.
22
+ # TODO: Use digest instead, because we really only need to verify. We don't need to be able to decrypt.
19
23
  signature = encryption_service.encrypt(full_params_hash)
20
24
  request_params_hash = request_params_hash.merge(signature: signature)
21
25
  end
22
26
 
23
- # TODO: This should probably be set as a parameter for json_libs
24
27
  uri = URI::HTTPS.build(
25
28
  host: 'imageserver-demo.herokuapp.com',
26
29
  path: "/image/#{bucket}/#{blob_key}",
@@ -17,7 +17,7 @@ module Glib
17
17
  if text_object.images.attached?
18
18
  content = content.gsub(/\{\{image(\d)\}\}/) {
19
19
  if image = text_object.images[$1.to_i - 1]
20
- dynamic_image_url(image.blob.key)
20
+ glib_dynamic_image_url(image.blob.key)
21
21
  else
22
22
  "{{image#{$1}}}"
23
23
  end
@@ -10,7 +10,7 @@ module Glib
10
10
 
11
11
  private
12
12
  def capitalize_first_letter_and_leave_others_alone(str)
13
- str.slice(0,1).capitalize + str.slice(1..-1)
13
+ str.slice(0, 1).capitalize + str.slice(1..-1)
14
14
  end
15
15
 
16
16
  def add_singleton_element(type, name, *args)
@@ -19,7 +19,7 @@ module Glib
19
19
  args = [yield] if block_given?
20
20
 
21
21
  # TODO: consider caching these instances
22
- "#{self.class.name}::#{name_components.map{ |str| capitalize_first_letter_and_leave_others_alone(str) }.join('::')}".constantize.new(json, @page).props(*args)
22
+ "#{self.class.name}::#{name_components.map { |str| capitalize_first_letter_and_leave_others_alone(str) }.join('::')}".constantize.new(json, @page).props(*args)
23
23
  end
24
24
 
25
25
  def add_element_to_array(type, name, *args)
@@ -29,15 +29,15 @@ module Glib
29
29
  end
30
30
 
31
31
  # TODO: Consider removing this in favour of non 'v1' suffix
32
- def add_singleton_element_v1 type, name, *args
32
+ def add_singleton_element_v1(type, name, *args)
33
33
  name_components = name.to_s.split('_')
34
34
  json.set! type, "#{name_components.join('/')}-v1" if type
35
35
  args = [yield] if block_given?
36
- "#{self.class.name}::#{name_components.map{ |str| capitalize_first_letter_and_leave_others_alone(str) }.join('::')}".constantize.new(json, @page).props(*args)
36
+ "#{self.class.name}::#{name_components.map { |str| capitalize_first_letter_and_leave_others_alone(str) }.join('::')}".constantize.new(json, @page).props(*args)
37
37
  end
38
38
 
39
39
  # TODO: Consider removing this in favour of non 'v1' suffix
40
- def add_element_to_array_v1 type, name, *args
40
+ def add_element_to_array_v1(type, name, *args)
41
41
  json.child! do
42
42
  add_singleton_element_v1 type, name, *args
43
43
  end
@@ -68,219 +68,218 @@ module Glib
68
68
  end
69
69
 
70
70
  private
71
-
72
- def self.any(propName)
73
- define_method(propName) do |value|
74
- json.set! propName, value
71
+ def self.any(propName)
72
+ define_method(propName) do |value|
73
+ json.set! propName, value
74
+ end
75
75
  end
76
- end
77
76
 
78
- def self.date(propName)
79
- define_method(propName) do |value|
80
- json.set! propName, value&.to_date
77
+ def self.date(propName)
78
+ define_method(propName) do |value|
79
+ json.set! propName, value&.to_date
81
80
 
82
- # if (value = value&.to_s)
83
- # if !Rails.env.production?
84
- # raise "Invalid date for #{propName}: #{value}" unless value =~ /^\d{4}-\d{2}-\d{2}$/
85
- # end
81
+ # if (value = value&.to_s)
82
+ # if !Rails.env.production?
83
+ # raise "Invalid date for #{propName}: #{value}" unless value =~ /^\d{4}-\d{2}-\d{2}$/
84
+ # end
86
85
 
87
- # json.set! propName, value
88
- # end
86
+ # json.set! propName, value
87
+ # end
88
+ end
89
89
  end
90
- end
91
90
 
92
- def self.date_time(propName)
93
- define_method(propName) do |value|
94
- json.set! propName, value&.to_datetime
91
+ def self.date_time(propName)
92
+ define_method(propName) do |value|
93
+ json.set! propName, value&.to_datetime
95
94
 
96
- # if (value = value&.to_s)
97
- # if !Rails.env.production?
98
- # try Date.parse(value) rescue raise "Invalid date: #{value}"
99
- # end
95
+ # if (value = value&.to_s)
96
+ # if !Rails.env.production?
97
+ # try Date.parse(value) rescue raise "Invalid date: #{value}"
98
+ # end
100
99
 
101
- # json.set! propName, value
102
- # end
100
+ # json.set! propName, value
101
+ # end
102
+ end
103
103
  end
104
- end
105
104
 
106
- def self.color propName
107
- define_method(propName) do |value|
108
- if (value = value&.to_s)
109
- if !Rails.env.production?
110
- if !value.match /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/i
111
- raise "Invalid color: #{value}"
105
+ def self.color(propName)
106
+ define_method(propName) do |value|
107
+ if (value = value&.to_s)
108
+ if !Rails.env.production?
109
+ if !value.match /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/i
110
+ raise "Invalid color: #{value}"
111
+ end
112
112
  end
113
- end
114
113
 
115
- json.set! propName, value
114
+ json.set! propName, value
115
+ end
116
116
  end
117
117
  end
118
- end
119
118
 
120
- def self.length propName
121
- define_method(propName) do |value|
122
- if value
123
- if !Rails.env.production?
124
- case value
125
- when 'matchParent'
126
- when 'wrapContent'
127
- else
128
- if !value.is_a? Integer
129
- raise "Invalid length: #{value}"
119
+ def self.length(propName)
120
+ define_method(propName) do |value|
121
+ if value
122
+ if !Rails.env.production?
123
+ case value
124
+ when 'matchParent'
125
+ when 'wrapContent'
126
+ else
127
+ if !value.is_a? Integer
128
+ raise "Invalid length: #{value}"
129
+ end
130
130
  end
131
131
  end
132
- end
133
132
 
134
- json.set! propName, value
133
+ json.set! propName, value
134
+ end
135
135
  end
136
136
  end
137
- end
138
137
 
139
- def self.string propName, options = {}
140
- define_method(propName) do |value|
141
- str = value&.to_s
142
- instance_variable_set("@#{propName}", str) if options[:cache]
143
- json.set! propName, str
138
+ def self.string(propName, options = {})
139
+ define_method(propName) do |value|
140
+ str = value&.to_s
141
+ instance_variable_set("@#{propName}", str) if options[:cache]
142
+ json.set! propName, str
143
+ end
144
144
  end
145
- end
146
145
 
147
- # Support either string or dynamic_text hash
148
- def self.text propName, options = {}
149
- define_method(propName) do |value|
150
- if value.is_a?(Hash)
151
- json.set! propName, value
152
- else
153
- json.set! propName, value&.to_s
146
+ # Support either string or dynamic_text hash
147
+ def self.text(propName, options = {})
148
+ define_method(propName) do |value|
149
+ if value.is_a?(Hash)
150
+ json.set! propName, value
151
+ else
152
+ json.set! propName, value&.to_s
153
+ end
154
154
  end
155
155
  end
156
- end
157
156
 
158
- def self.int propName
159
- define_method(propName) do |value|
160
- json.set! propName, value&.to_i
157
+ def self.int(propName)
158
+ define_method(propName) do |value|
159
+ json.set! propName, value&.to_i
160
+ end
161
161
  end
162
- end
163
162
 
164
- def self.float propName
165
- define_method(propName) do |value|
166
- json.set! propName, value&.to_f
163
+ def self.float(propName)
164
+ define_method(propName) do |value|
165
+ json.set! propName, value&.to_f
166
+ end
167
167
  end
168
- end
169
168
 
170
- def self.bool propName, options = {}
171
- define_method(propName) do |value|
172
- bool = value == true
173
- instance_variable_set("@#{propName}", bool) if options[:cache]
174
- json.set! propName, bool
169
+ def self.bool(propName, options = {})
170
+ define_method(propName) do |value|
171
+ bool = value == true
172
+ instance_variable_set("@#{propName}", bool) if options[:cache]
173
+ json.set! propName, bool
174
+ end
175
175
  end
176
- end
177
176
 
178
- def self.icon propName, options = {}
179
- define_method(propName) do |value|
177
+ def self.icon(propName, options = {})
178
+ define_method(propName) do |value|
180
179
 
181
- if value.is_a?(Hash)
182
- data = value
183
- name = data[:name]
184
- else
185
- data = {}
186
- name = value
187
- # data = { material: { name: value } }
180
+ if value.is_a?(Hash)
181
+ data = value
182
+ name = data[:name]
183
+ else
184
+ data = {}
185
+ name = value
186
+ # data = { material: { name: value } }
188
187
 
189
- # name = value
188
+ # name = value
190
189
 
191
- # TODO: deprecated
192
- # json.set!(propName) do
193
- # json.name name
194
- # end
195
- end
196
-
197
- json.set!(propName) do
198
- if name
199
- data[:material] ||= {}
200
- data[:material][:name] = name
190
+ # TODO: deprecated
191
+ # json.set!(propName) do
192
+ # json.name name
193
+ # end
201
194
  end
202
195
 
203
- if (material = data[:material])
204
- json.material do
205
- json.name material[:name]
206
- json.size material[:size] if material[:size]
196
+ json.set!(propName) do
197
+ if name
198
+ data[:material] ||= {}
199
+ data[:material][:name] = name
207
200
  end
208
- end
209
201
 
210
- if (fa = data[:fa])
211
- json.fa do
212
- json.name fa[:name]
213
- json.size fa[:size] if fa[:size]
202
+ if (material = data[:material])
203
+ json.material do
204
+ json.name material[:name]
205
+ json.size material[:size] if material[:size]
206
+ end
214
207
  end
215
- end
216
208
 
217
- if (custom = data[:custom])
218
- json.custom do
219
- json.name custom[:name]
220
- json.size custom[:size] if custom[:size]
209
+ if (fa = data[:fa])
210
+ json.fa do
211
+ json.name fa[:name]
212
+ json.size fa[:size] if fa[:size]
213
+ end
221
214
  end
222
- end
223
215
 
224
- if (badge = data[:badge])
225
- if badge.is_a?(Hash)
226
- json.badge badge
227
- else
228
- json.badge do
229
- json.text badge
216
+ if (custom = data[:custom])
217
+ json.custom do
218
+ json.name custom[:name]
219
+ json.size custom[:size] if custom[:size]
230
220
  end
231
221
  end
232
- end
233
222
 
234
- end
223
+ if (badge = data[:badge])
224
+ if badge.is_a?(Hash)
225
+ json.badge badge
226
+ else
227
+ json.badge do
228
+ json.text badge
229
+ end
230
+ end
231
+ end
235
232
 
236
- # raise "Invalid properties: #{options.keys}" if options.size > 0
233
+ end
237
234
 
238
- # instance_variable_set("@#{propName}", name) if options[:cache]
235
+ # raise "Invalid properties: #{options.keys}" if options.size > 0
239
236
 
237
+ # instance_variable_set("@#{propName}", name) if options[:cache]
238
+
239
+ end
240
240
  end
241
- end
242
241
 
243
- def self.action propName
244
- define_method(propName) do |value|
245
- json.set!(propName) { value.call(page.action_builder) }
242
+ def self.action(propName)
243
+ define_method(propName) do |value|
244
+ json.set!(propName) { value.call(page.action_builder) }
245
+ end
246
246
  end
247
- end
248
247
 
249
- def self.views propName
250
- define_method(propName) do |value|
251
- json.set!(propName) { value.call(page.view_builder) }
248
+ def self.views(propName)
249
+ define_method(propName) do |value|
250
+ json.set!(propName) { value.call(page.view_builder) }
251
+ end
252
252
  end
253
- end
254
253
 
255
- def self.array propName
256
- define_method(propName) do |value|
257
- json.set! propName, value&.to_a
254
+ def self.array(propName)
255
+ define_method(propName) do |value|
256
+ json.set! propName, value&.to_a
257
+ end
258
258
  end
259
- end
260
259
 
261
- def self.hash propName
262
- define_method(propName) do |value|
263
- json.set! propName, value
260
+ def self.hash(propName)
261
+ define_method(propName) do |value|
262
+ json.set! propName, value
263
+ end
264
264
  end
265
- end
266
265
 
267
- def self.singleton_array singletonName, arrayName
268
- array arrayName
266
+ def self.singleton_array(singletonName, arrayName)
267
+ array arrayName
269
268
 
270
- define_method(singletonName) do |value|
271
- json.set! arrayName, [value]
269
+ define_method(singletonName) do |value|
270
+ json.set! arrayName, [value]
271
+ end
272
272
  end
273
- end
274
273
 
275
- def self.panels_builder(propName, *panelNames)
276
- define_method(propName) do |value|
277
- value.call(page.content_builder(panelNames))
274
+ def self.panels_builder(propName, *panelNames)
275
+ define_method(propName) do |value|
276
+ value.call(page.content_builder(panelNames))
277
+ end
278
278
  end
279
- end
280
279
 
281
- def created
282
- # To be overridden
283
- end
280
+ def created
281
+ # To be overridden
282
+ end
284
283
 
285
284
  end
286
285
  end
@@ -68,6 +68,13 @@ module Glib
68
68
 
69
69
  class Restart < Action
70
70
  end
71
+
72
+ class CreditCard < Action
73
+ string :publicKey
74
+ string :clientSecret
75
+ action :onSuccess
76
+ action :onFailure
77
+ end
71
78
  end
72
79
 
73
80
  module Devices
@@ -1,18 +1,38 @@
1
1
  class Glib::JsonUi::ActionBuilder
2
2
  module Http
3
- class Post < Action
3
+ class AbstractHttp < Action
4
4
  string :url, cache: true
5
- hash :formData
5
+
6
+ def formData(hash)
7
+ form_data = {}
8
+ hash.each do |key, value|
9
+ flatten_nested_params(form_data, key, value)
10
+ end
11
+ json.formData form_data
12
+ end
13
+
14
+ def flatten_nested_params(form_data, key, value)
15
+ if value.is_a?(Hash)
16
+ value.each do |nested_key, nested_value|
17
+ flatten_nested_params(form_data, "#{key}[#{nested_key}]", nested_value)
18
+ end
19
+ else
20
+ form_data[key] = value
21
+ end
22
+ end
6
23
  end
7
24
 
8
- class Patch < Action
9
- string :url, cache: true
10
- hash :formData
25
+ class Post < AbstractHttp
11
26
  end
12
27
 
13
- class Delete < Action
14
- string :url, cache: true
15
- hash :formData
28
+ class Patch < AbstractHttp
29
+ # string :url, cache: true
30
+ # hash :formData
31
+ end
32
+
33
+ class Delete < AbstractHttp
34
+ # string :url, cache: true
35
+ # hash :formData
16
36
  end
17
37
 
18
38
  end
@@ -1,9 +1,9 @@
1
1
  module Glib
2
2
  module JsonUi
3
3
  module DynamicFieldBuilders
4
-
4
+
5
5
  class Group < AbstractBuilder
6
- def initialize json, page, template
6
+ def initialize(json, page, template)
7
7
  super json, page
8
8
  @template = template
9
9
  end
@@ -15,11 +15,11 @@ module Glib
15
15
 
16
16
  def template(options = {})
17
17
  # json.template do
18
- page.vertical_content(options)
18
+ page.vertical_content(options)
19
19
  # end
20
20
  end
21
21
  end
22
-
22
+
23
23
  end
24
24
  end
25
25
  end
@@ -1,7 +1,7 @@
1
1
  module Glib
2
2
  module JsonUi
3
3
  class MenuBuilder < AbstractBuilder
4
- def method_missing m, *args
4
+ def method_missing(m, *args)
5
5
  add_element_to_array_v1 nil, m, *args
6
6
  end
7
7
 
@@ -3,10 +3,10 @@ module Glib
3
3
  module PageHelper
4
4
  def json_ui_garage_url(options = {})
5
5
  Glib::Web::Engine.routes.url_helpers.json_ui_garage_url(options.merge(
6
- protocol: request.protocol,
7
- host: request.host,
8
- port: request.port,
9
- _render: params[:_render], format: params[:format])
6
+ protocol: request.protocol,
7
+ host: request.host,
8
+ port: request.port,
9
+ _render: params[:_render], format: params[:format])
10
10
  )
11
11
  end
12
12
 
@@ -3,7 +3,7 @@ module Glib
3
3
  module SplitBuilders
4
4
 
5
5
  class Content < AbstractBuilder
6
- def initialize json, page, template
6
+ def initialize(json, page, template)
7
7
  super json, page
8
8
  @template = template
9
9
  end
@@ -2,10 +2,10 @@ module Glib
2
2
  module JsonUi
3
3
  module TableBuilders
4
4
  class Template < AbstractBuilder
5
- def method_missing m, *args
5
+ def method_missing(m, *args)
6
6
  add_element_to_array 'template', m, *args
7
7
  end
8
-
8
+
9
9
  class AbstractTemplate < JsonUiElement
10
10
 
11
11
  def editButtons(block)
@@ -13,9 +13,9 @@ module Glib
13
13
  block.call page.menu_builder
14
14
  end
15
15
  end
16
-
16
+
17
17
  end
18
-
18
+
19
19
  class Default < AbstractTemplate
20
20
  views :cellViews
21
21
  action :onClick
@@ -23,9 +23,9 @@ module Glib
23
23
  array :colStyles
24
24
  end
25
25
  end
26
-
26
+
27
27
  class Section < AbstractBuilder
28
- def initialize json, page, template
28
+ def initialize(json, page, template)
29
29
  super json, page
30
30
  @template = template
31
31
  end
@@ -68,7 +68,7 @@ module Glib
68
68
  # end
69
69
 
70
70
  end
71
-
71
+
72
72
  end
73
73
  end
74
74
  end
@@ -104,6 +104,9 @@ module Glib
104
104
  bool :previewVideo
105
105
  end
106
106
 
107
+ class Html < AbstractText
108
+ end
109
+
107
110
  class Label < AbstractText
108
111
  # string :format
109
112
  action :onClick
@@ -199,4 +202,4 @@ module Glib
199
202
 
200
203
  end
201
204
  end
202
- end
205
+ end
@@ -207,14 +207,18 @@ class Glib::JsonUi::ViewBuilder
207
207
  date_time :max
208
208
  end
209
209
 
210
- class LatLong < AbstractField
210
+ class Location < AbstractField
211
211
  hash :latitudeField
212
212
  hash :longitudeField
213
+ hash :zoomField
213
214
  end
214
215
 
215
216
  class StripeToken < AbstractField
216
217
  string :publicKey
217
218
  end
218
219
 
220
+ class CreditCard < AbstractField
221
+ string :publicKey
222
+ end
219
223
  end
220
224
  end
@@ -97,7 +97,9 @@ class Glib::JsonUi::ViewBuilder
97
97
  end
98
98
 
99
99
  class List < View
100
- hash :ws
100
+ hash :phoenixSocket
101
+ hash :actionCable
102
+
101
103
  hash :nextPage
102
104
  action :onScrollToTop
103
105
  action :onScrollToBottom
@@ -156,6 +158,7 @@ class Glib::JsonUi::ViewBuilder
156
158
  class Responsive < View
157
159
  views :childViews
158
160
  string :align
161
+ action :onClick
159
162
  end
160
163
 
161
164
  class Column < View
@@ -6,7 +6,7 @@ end
6
6
  section.rows builder: ->(template) do
7
7
  template.thumbnail title: 'http/post', onClick: ->(action) do
8
8
  action.auth_saveCsrfToken token: form_authenticity_token, onSave: ->(subaction) do
9
- subaction.http_post url: json_ui_garage_url(path: 'forms/basic_post'), formData: { 'user[name]' => 'New Joe' }
9
+ subaction.http_post url: json_ui_garage_url(path: 'forms/basic_post'), formData: { user: { name: { first: 'New', last: 'Joe' } } }
10
10
  end
11
11
  end
12
12
 
@@ -76,6 +76,12 @@ json_ui_page json do |page|
76
76
  template.thumbnail title: 'Rich Text Editor', onClick: ->(action) do
77
77
  action.windows_open url: json_ui_garage_url(path: 'forms/rich_text')
78
78
  end
79
+ end
80
+
81
+ section.rows builder: ->(template) do
82
+ template.thumbnail title: 'New Rich Text Editor', onClick: ->(action) do
83
+ action.windows_open url: json_ui_garage_url(path: 'forms/new_rich_text')
84
+ end
79
85
 
80
86
  end
81
87
  end, ->(section) do
@@ -0,0 +1,40 @@
1
+ json.title 'Forms'
2
+
3
+ json_ui_page json do |page|
4
+ render "#{@path_prefix}/nav_menu", json: json, page: page
5
+
6
+ page.form url: json_ui_garage_url(path: 'forms/basic_post'), method: 'post', padding: { top: 12, left: 20, right: 20, bottom: 12 }, childViews: ->(form) do
7
+ form.fields_text name: 'user[name]', width: 'matchParent', label: 'Name'
8
+
9
+ # images = [
10
+ # {
11
+ # value: "eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBFQT09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--193dc0d939b9558fc4973fafbba91d989cbb04d4",
12
+ # fileUrl: "https://imageserver-demo.herokuapp.com/image/itinerarybuilder-demo/o6CKzNt67PWnkPdUEnWMt7pr?h=100&w=100"
13
+ # }
14
+ # ]
15
+ # form.fields_richText name: 'user[bio]', width: 'matchParent', label: 'Content', images: images, value: '<p>Test {{image1}}</p>'
16
+
17
+ json.child! do
18
+ json.view 'fields/newRichText-v1'
19
+ json.width 'matchParent'
20
+ json.label 'Content'
21
+ json.name 'user[bio]'
22
+ json.value '<p>Test {{image1}}</p>'
23
+
24
+ json.images do
25
+ json.child! do
26
+ json.value "eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBFQT09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--193dc0d939b9558fc4973fafbba91d989cbb04d4"
27
+ # json.fileTitle "hita i hanom hg.jpg"
28
+ json.fileUrl "https://imageserver-demo.herokuapp.com/image/itinerarybuilder-demo/o6CKzNt67PWnkPdUEnWMt7pr?h=100&w=100"
29
+ end
30
+ end
31
+
32
+ json.imageUploader do
33
+ json.accepts(fileType: "image/*", maxFileSize: 5000)
34
+ json.directUploadUrl rails_direct_uploads_url
35
+ end
36
+ end
37
+
38
+ form.button text: 'Submit', onClick: ->(action) { action.forms_submit }
39
+ end
40
+ end
@@ -2,7 +2,7 @@ json.title 'Forms'
2
2
 
3
3
  json_ui_page json do |page|
4
4
  render "#{@path_prefix}/nav_menu", json: json, page: page
5
-
5
+
6
6
  page.form url: json_ui_garage_url(path: 'forms/generic_post'), method: 'post', padding: glib_json_padding_body, childViews: ->(form) do
7
7
  form.h2 text: 'Radio Group'
8
8
  form.spacer height: 6
@@ -12,7 +12,7 @@ json_ui_page json do |page|
12
12
  group.fields_radio value: 'M', label: 'Male'
13
13
  group.fields_radio value: 'F', label: 'Female'
14
14
  end
15
-
15
+
16
16
  form.spacer height: 20
17
17
  form.h2 text: 'Single Checkbox'
18
18
  form.fields_check name: 'user[age_range]', value: '16+', checkValue: '16+', uncheckValue: '0-16', label: 'I am over 16 (has default value)'
@@ -34,9 +34,10 @@ json_ui_page json do |page|
34
34
  form.spacer height: 20
35
35
  form.h2 text: 'Map'
36
36
  form.spacer height: 6
37
- form.fields_latLong name: 'user[address]', width: 'matchParent', label: 'Type an address', value: 'Sydney Harbour Bridge',
38
- latitudeField: { name: 'user[latitude]', label: 'Lat', value: -33.8523063, readOnly: true },
39
- longitudeField: { name: 'user[longitude]', label: 'Long', value: 151.21078710000006, readOnly: true }
37
+ form.fields_location name: 'user[address]', width: 'matchParent', label: 'Type an address', value: 'Sydney Harbour Bridge',
38
+ latitudeField: { view: 'fields/text', name: 'user[latitude]', label: 'Lat', value: -33.8523063, readOnly: true },
39
+ longitudeField: { view: 'fields/text', name: 'user[longitude]', label: 'Long', value: 151.21078710000006, readOnly: true },
40
+ zoomField: { view: 'fields/text', name: 'user[zoom]', label: 'Zoom' }
40
41
 
41
42
  form.spacer height: 20
42
43
  form.fields_submit text: 'Submit'
@@ -2,12 +2,12 @@ json.title 'Forms'
2
2
 
3
3
  json_ui_page json do |page|
4
4
  render "#{@path_prefix}/nav_menu", json: json, page: page
5
-
5
+
6
6
  page.form url: json_ui_garage_url(path: 'forms/basic_post'), method: 'post', padding: { top: 12, left: 20, right: 20, bottom: 12 }, childViews: ->(form) do
7
7
  form.fields_text name: 'user[name]', width: 'matchParent', label: 'Name'
8
8
 
9
9
  # images = [
10
- # {
10
+ # {
11
11
  # value: "eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBFQT09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--193dc0d939b9558fc4973fafbba91d989cbb04d4",
12
12
  # fileUrl: "https://imageserver-demo.herokuapp.com/image/itinerarybuilder-demo/o6CKzNt67PWnkPdUEnWMt7pr?h=100&w=100"
13
13
  # }
@@ -28,7 +28,7 @@ json_ui_page json do |page|
28
28
  json.fileUrl "https://imageserver-demo.herokuapp.com/image/itinerarybuilder-demo/o6CKzNt67PWnkPdUEnWMt7pr?h=100&w=100"
29
29
  end
30
30
  end
31
-
31
+
32
32
  json.imageUploader do
33
33
  json.accepts(fileType: "image/*", maxFileSize: 5000)
34
34
  json.directUploadUrl rails_direct_uploads_url
@@ -19,7 +19,7 @@ section.rows builder: ->(row) do
19
19
  index = page_index * batch_count + i
20
20
  if local_assigns[:reorder]
21
21
  row.thumbnail title: "Item #{index}", onReorder: ->(action) do
22
- action.dialogs_alert
22
+ action.dialogs_notification title: "Item #{index}"
23
23
  end, paramNameForFormData: 'message', paramNameForNewIndex: 'new_index'
24
24
  else
25
25
  row.thumbnail title: "Item #{index}"
@@ -5,7 +5,7 @@ liked = params[:liked] == 'true'
5
5
  page = json_ui_page json
6
6
  render "#{@path_prefix}/nav_menu", json: json, page: page
7
7
 
8
- json.ws({
8
+ json.phoenixSocket({
9
9
  "socket" => {
10
10
  "endpoint" => "/socket/websocket",
11
11
  "params" => {
@@ -71,25 +71,6 @@ page.list ws: list_ws, firstSection: ->(section) do
71
71
  end
72
72
 
73
73
  page.footer padding: { top: 12, left: 16, right: 16, bottom: 12 }, childViews: ->(footer) do
74
- # json.ws({
75
- # "socket" => {
76
- # "endpoint" => "/socket/websocket",
77
- # "params" => {
78
- # vsn: '2.0.0',
79
- # token: 'TOKEN'
80
- # }
81
- # },
82
- # # "topic" => "room:30",
83
- # # "event" => "comments_updated",
84
- # "topic" => "links",
85
- # "events" => ["new_link_added"],
86
- # "header" => {
87
- # "user_id" => 2,
88
- # "prev_item_id" => nil,
89
- # "last_item_id" => nil
90
- # }
91
- # })
92
-
93
74
  footer.panels_form width: 'matchParent', url: json_ui_garage_url(path: 'forms/basic_post'), method: 'post', padding: glib_json_padding_body, paramNameForFormData: 'formData', onSubmit: ->(action) do
94
75
  json.action "ws/push"
95
76
  json.topic "rooms"
@@ -3,7 +3,7 @@ json.title 'Forms'
3
3
  page = json_ui_page json
4
4
  render "#{@path_prefix}/nav_menu", json: json, page: page
5
5
 
6
- json.ws({
6
+ json.phoenixSocket({
7
7
  "socket" => {
8
8
  "endpoint" => "/socket/websocket",
9
9
  "params" => {
@@ -43,7 +43,7 @@ end, childViews: ->(form) do
43
43
 
44
44
  # TODO: Change this to radio for selecting alert vs reload response
45
45
  form.fields_password name: 'user[password]', width: 'matchParent', label: 'Password'
46
-
46
+
47
47
  form.fields_hidden name: 'baseUrl', width: 'matchParent', value: json_ui_garage_url(path: 'notifications/web_socket')
48
48
 
49
49
  form.panels_split width: 'matchParent', content: ->(split) do
@@ -56,5 +56,5 @@ end, childViews: ->(form) do
56
56
  right.button text: 'Submit', onClick: ->(action) { action.forms_submit }
57
57
  end
58
58
  end
59
-
59
+
60
60
  end
@@ -2,13 +2,13 @@ json.title 'Panels'
2
2
 
3
3
  json_ui_page json do |page|
4
4
  render "#{@path_prefix}/nav_menu", json: json, page: page
5
-
5
+
6
6
  page.scroll padding: glib_json_padding_body, childViews: ->(scroll) do
7
7
  scroll.h2 text: 'Thumbnail Template'
8
8
  scroll.spacer height: 6
9
9
  scroll.panels_custom template: 'thumbnail', width: 'matchParent', backgroundColor: '#fafafa',
10
10
  data: { imageUrl: glib_json_image_standard_url, title: 'Title', subtitle: 'Use the same template from list templates' }
11
-
11
+
12
12
  scroll.spacer height: 20
13
13
  scroll.h2 text: 'Non-existent Template'
14
14
  scroll.spacer height: 6
@@ -71,7 +71,7 @@ page.scroll padding: glib_json_padding_body, childViews: ->(scroll) do
71
71
  # responsive.panels_column lg: { cols: 4 }, childViews: ->(column) do
72
72
  # column.button width: 'matchParent', text: '2'
73
73
  # end
74
-
74
+
75
75
  responsive.panels_column lg: { cols: 8 }, backgroundColor: '#c3cad2', childViews: ->(column) do
76
76
  column.button text: '1'
77
77
  end
@@ -84,5 +84,15 @@ page.scroll padding: glib_json_padding_body, childViews: ->(scroll) do
84
84
  end
85
85
 
86
86
  scroll.spacer height: 20
87
+ scroll.h2 text: 'With onClick'
88
+ scroll.spacer height: 6
89
+ scroll.panels_responsive backgroundColor: '#c3cad2', padding: { left: 20, right: 20, top: 10, bottom: 10 }, childViews: ->(responsive) do
90
+ responsive.h4 text: 'Heading'
91
+ responsive.label text: 'Label'
92
+ end, onClick: ->(action) do
93
+ action.windows_open url: json_ui_garage_url(path: 'home/blank')
94
+ end
95
+
96
+ scroll.spacer height: 20
87
97
 
88
98
  end
@@ -180,4 +180,3 @@ json_ui_page json do |page|
180
180
  end
181
181
  end
182
182
  end
183
-
@@ -2,7 +2,7 @@ json.title 'Panels'
2
2
 
3
3
  json_ui_page json do |page|
4
4
  render "#{@path_prefix}/nav_menu", json: json, page: page
5
-
5
+
6
6
  page.scroll padding: glib_json_padding_body, childViews: ->(scroll) do
7
7
  scroll.h1 text: 'Basic'
8
8
  scroll.panels_vertical backgroundColor: '#b3bac2', childViews: ->(panel) do
@@ -6,3 +6,4 @@ require 'glib/json_crawler'
6
6
  require 'glib/dynamic_text'
7
7
  require 'glib/crypt'
8
8
  require 'glib/test_helpers'
9
+ require 'glib/mailer_tester'
@@ -81,6 +81,9 @@ module Glib
81
81
  end
82
82
 
83
83
  def tear_down
84
+ # NOTE: Experimental, to address issue where sometimes changes don't get saved.
85
+ @logger.flush
86
+
84
87
  @logger.close
85
88
  end
86
89
 
@@ -0,0 +1,36 @@
1
+ module Glib
2
+ module MailerTester
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ project_root = Rails.root
7
+ paths = Dir.glob(project_root + 'test/mailers/previews/*')
8
+ paths.each do |file|
9
+ require file
10
+ end
11
+
12
+ ActionMailer::Preview.subclasses.each do |preview_class|
13
+ preview = preview_class.new
14
+
15
+ preview_class.instance_methods(false).each do |mailer_method|
16
+ test "mailer for #{preview_class}##{mailer_method}" do
17
+ preview.send(mailer_method).deliver_now
18
+
19
+ logfile = File.join(log_dir, "#{preview_class.name.underscore}##{mailer_method}.txt")
20
+
21
+ # Use rstrip to avoid trailing space issues
22
+ expected = File.exist?(logfile) ? File.read(logfile).rstrip : ''
23
+ last_delivery = ActionMailer::Base.deliveries.last
24
+ result = last_delivery.html_part.body.raw_source.rstrip
25
+
26
+ logger = File.open(logfile, 'w')
27
+ logger.puts result
28
+ logger.close
29
+
30
+ assert_equal expected, result, "Result mismatch! #{logfile.sub(/\.txt$/, '')}"
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
File without changes
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glib-web
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.24
4
+ version: 0.5.29
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''
@@ -131,6 +131,7 @@ files:
131
131
  - app/views/json_ui/garage/forms/generic_post.json.jbuilder
132
132
  - app/views/json_ui/garage/forms/get_request.json.jbuilder
133
133
  - app/views/json_ui/garage/forms/index.json.jbuilder
134
+ - app/views/json_ui/garage/forms/new_rich_text.json.jbuilder
134
135
  - app/views/json_ui/garage/forms/pickers.json.jbuilder
135
136
  - app/views/json_ui/garage/forms/rich_text.json.jbuilder
136
137
  - app/views/json_ui/garage/forms/selects.json.jbuilder
@@ -224,6 +225,7 @@ files:
224
225
  - lib/glib/json_crawler/coverage.rb
225
226
  - lib/glib/json_crawler/http.rb
226
227
  - lib/glib/json_crawler/router.rb
228
+ - lib/glib/mailer_tester.rb
227
229
  - lib/glib/test_helpers.rb
228
230
  - lib/glib/value.rb
229
231
  - lib/glib/version.rb