glib-web 0.5.9 → 0.5.15

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8cb6ba9cc8312e05a50ed1179f7690b3dd985410
4
- data.tar.gz: b896cd852f0f42fa7e5a198ff6d3a49f5fca037e
3
+ metadata.gz: 1fa8b104b9be3155b11356fdadff6265d8320dca
4
+ data.tar.gz: 7e4a6dbccc939a2b3438d5699f550173d3292c0e
5
5
  SHA512:
6
- metadata.gz: b151098400b68a0eea5271b0d513be08a527fb091668d25769375215d6975d2c71f10268d2303125c156fdba610cf8d6a965b6ec8eb9d3c18a61c32f5fc528f6
7
- data.tar.gz: 030e32c03a9d1b4ad9b4141406d367b60de018b6ce7738eab0080ef5327a9b2958b363d84a182663bcaae9df4fa4b8b66554af4cbcc61a738cebc1d7511be292
6
+ metadata.gz: 66f64b2d23d1c8fca7a66d6517c938c010ae49d7314dfb712d164d39cb6b276be8a769a54e5f8db0186ee10591f0d83a2d56e1d048c7804ba71a1ca36d0f95ea
7
+ data.tar.gz: 5b4d4d505cdf52861a1bfe3102eb34d2697005d6259b84065f63258b73b1fb2153cbed5062aa495a6d1aedd02cea7e472aed4368e394c4e93759e8a5fac24a5e
@@ -76,8 +76,9 @@ module Glib::Json::Traversal
76
76
  # Table/List
77
77
  if (sections = view['sections']).is_a? Array
78
78
  sections.each do |section|
79
- # Table
79
+ traverse_vertical_content section['header'], block
80
80
  traverse_multiple section['rows'], block
81
+ traverse_vertical_content section['footer'], block
81
82
  end
82
83
  end
83
84
  end
@@ -31,8 +31,8 @@ module Glib::Json::Ui
31
31
  @__json_ui_activated
32
32
  end
33
33
 
34
- def json_ui_lifecycle_prop(name)
35
- if (hash = json_transformation_start).is_a?(Hash)
34
+ def json_ui_page_lifecycle_prop(name)
35
+ if (hash = json_transformation_start).is_a?(Hash) && hash['body'] # A valid page
36
36
  hash[name] ||= { 'action' => 'runMultiple', 'childActions' => [] }
37
37
  hash[name]['childActions']
38
38
  end
@@ -66,6 +66,9 @@ module Glib
66
66
  string :token
67
67
  action :onSave
68
68
  end
69
+
70
+ class Restart < Action
71
+ end
69
72
  end
70
73
 
71
74
  module Analytics
@@ -7,7 +7,11 @@ module Glib
7
7
  end
8
8
 
9
9
  class AbstractTemplate < JsonUiElement
10
- # hash :padding
10
+ # def contextButtons(block)
11
+ # json.contextButtons do
12
+ # block.call page.menu_builder
13
+ # end
14
+ # end
11
15
 
12
16
  def editButtons(block)
13
17
  json.editButtons do
@@ -22,12 +26,13 @@ module Glib
22
26
  end
23
27
  end
24
28
 
25
- class Thumbnail < AbstractTemplate
29
+ class Standard < AbstractTemplate
26
30
  string :title
27
31
  string :subtitle
28
32
  string :subsubtitle
29
33
  string :imageUrl
30
34
  action :onClick
35
+ action :onLongPress
31
36
  icon :icon
32
37
  bool :avatar
33
38
 
@@ -36,10 +41,19 @@ module Glib
36
41
  # views :accessoryViews
37
42
  end
38
43
 
39
- class Featured < Thumbnail
44
+ class Featured < Standard
40
45
  end
41
46
 
42
- class Custom < Thumbnail
47
+ class Thumbnail < Standard
48
+ end
49
+
50
+ class CommentOutgoing < Standard
51
+ end
52
+
53
+ class CommentIncoming < Standard
54
+ end
55
+
56
+ class Custom < Standard
43
57
  string :template
44
58
 
45
59
  # TODO: Experimental
@@ -12,7 +12,6 @@ section.rows builder: ->(template) do
12
12
  menu.button text: 'Option2', onClick: ->(subaction) do
13
13
  subaction.dialogs_alert message: 'Option 2'
14
14
  end
15
- menu.button text: 'Cancel'
16
15
  end
17
16
  end
18
17
 
@@ -0,0 +1,112 @@
1
+ json.title 'Lists'
2
+
3
+ liked = params[:liked] == 'true'
4
+
5
+ json_ui_page json do |page|
6
+ render "#{@path_prefix}/nav_menu", json: json, page: page
7
+
8
+ page.list firstSection: ->(section) do
9
+ section.header padding: { top: 12, left: 16, right: 16, bottom: 12 }, childViews: ->(header) do
10
+ header.h3 text: 'Chat with John Doe'
11
+ end
12
+
13
+ section.rows builder: ->(template) do
14
+ # template.thumbnail title: "windows/reload (timestamp: #{DateTime.current.to_i}) -- #{liked}", onClick: ->(action) do
15
+ # action.windows_reload
16
+ # end, onLongPress: ->(action) do
17
+ # action.sheets_select message: "Context Menu (#{DateTime.current.to_i})", buttons: ->(menu) do
18
+ # if liked
19
+ # menu.button text: 'Cancel 👍', onClick: ->(subaction) do
20
+ # subaction.windows_reload url: json_ui_garage_url(path: 'lists/chat', liked: false)
21
+ # end
22
+ # else
23
+ # menu.button text: 'Give 👍', onClick: ->(subaction) do
24
+ # subaction.windows_reload url: json_ui_garage_url(path: 'lists/chat', liked: true)
25
+ # end
26
+ # end
27
+ # end
28
+ # end
29
+
30
+ template.commentOutgoing subtitle: 'Hey!', subsubtitle: l(10.minutes.ago, format: :short), imageUrl: glib_json_image_standard_url, chips: ->(menu) do
31
+ menu.button text: '😊 2', styleClass: 'info'
32
+ end
33
+
34
+ template.commentOutgoing subtitle: 'How are you?', subsubtitle: l(DateTime.current, format: :short)
35
+
36
+ template.commentIncoming title: 'John Doe', subtitle: 'Very well', subsubtitle: l(7.minutes.ago, format: :short), imageUrl: glib_json_image_standard_url, chips: ->(menu) do
37
+ menu.button text: "👍 #{liked ? 2 : 1}"
38
+ end, onLongPress: ->(action) do
39
+ action.sheets_select message: 'Context Menu', buttons: ->(menu) do
40
+ if liked
41
+ menu.button text: 'Cancel 👍', onClick: ->(subaction) do
42
+ subaction.windows_reload url: json_ui_garage_url(path: 'lists/chat', liked: false)
43
+ end
44
+ else
45
+ menu.button text: 'Give 👍', onClick: ->(subaction) do
46
+ subaction.windows_reload url: json_ui_garage_url(path: 'lists/chat', liked: true)
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
52
+
53
+ section.footer padding: { top: 12, left: 16, right: 16, bottom: 12 }, childViews: ->(footer) do
54
+ # footer.
55
+
56
+ # json.ws({
57
+ # "socket" => {
58
+ # "endpoint" => "/socket/websocket",
59
+ # "params" => {
60
+ # vsn: '2.0.0',
61
+ # token: 'TOKEN'
62
+ # }
63
+ # },
64
+ # # "topic" => "room:30",
65
+ # # "event" => "comments_updated",
66
+ # "topic" => "links",
67
+ # "events" => ["new_link_added"],
68
+ # "header" => {
69
+ # "user_id" => 2,
70
+ # "prev_item_id" => nil,
71
+ # "last_item_id" => nil
72
+ # }
73
+ # })
74
+
75
+ # page.form url: json_ui_garage_url(path: 'forms/basic_post'), method: 'post', padding: glib_json_padding_body, paramNameForFormData: 'formData', onSubmit: ->(action) do
76
+ # json.action "ws/push"
77
+ # json.topic "links"
78
+ # json.event "new_link"
79
+ # json.payload({
80
+ # "club_id": "2",
81
+ # "room_id": "30",
82
+ # "user_id": "2"
83
+ # # title: "TITLE",
84
+ # # url: "URL"
85
+ # })
86
+
87
+ # end, childViews: ->(form) do
88
+ # form.spacer height: 14
89
+ # form.label text: "Message: #{params[:message]}"
90
+ # form.spacer height: 14
91
+
92
+ # form.fields_text name: 'message[body]', width: 'matchParent', label: 'Message'
93
+
94
+ # # TODO: Change this to radio for selecting alert vs reload response
95
+ # form.fields_password name: 'user[password]', width: 'matchParent', label: 'Password'
96
+
97
+ # form.fields_hidden name: 'baseUrl', width: 'matchParent', value: json_ui_garage_url(path: 'notifications/web_socket')
98
+
99
+ # form.panels_split width: 'matchParent', content: ->(split) do
100
+ # # split.left childViews: ->(left) do
101
+ # # if params[:mode] == 'dialog'
102
+ # # left.button styleClass: 'link', text: 'cancel', onClick: ->(action) { action.dialogs_close }
103
+ # # end
104
+ # # end
105
+ # split.right childViews: ->(right) do
106
+ # right.button text: 'Submit', onClick: ->(action) { action.forms_submit }
107
+ # end
108
+ # end
109
+
110
+ end
111
+ end
112
+ end
@@ -2,7 +2,7 @@ json.title 'Lists'
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.list firstSection: ->(section) do
7
7
  section.rows builder: ->(template) do
8
8
  template.thumbnail title: 'Click menu (web) or swipe left (Android/iOS)', editButtons: ->(menu) do
@@ -13,6 +13,30 @@ json_ui_page json do |page|
13
13
  action.dialogs_alert message: 'Perform action'
14
14
  end
15
15
  end
16
+
17
+ template.thumbnail title: 'Long press to get an alert', onLongPress: ->(action) do
18
+ action.dialogs_alert message: 'This is an alert'
19
+ end
20
+
21
+ template.thumbnail title: 'Long press to see menu', onLongPress: ->(action) do
22
+ action.sheets_select message: 'Context Menu', buttons: ->(menu) do
23
+ menu.button icon: 'edit', text: 'Edit', onClick: ->(subaction) do
24
+ subaction.dialogs_alert message: 'Perform action'
25
+ end
26
+ menu.button icon: 'delete', text: 'Delete', onClick: ->(subaction) do
27
+ subaction.dialogs_alert message: 'Perform action'
28
+ end
29
+ end
30
+ end
31
+
32
+ # template.thumbnail title: 'Long press to see menu', contextButtons: ->(menu) do
33
+ # menu.button text: 'Edit', onClick: ->(action) do
34
+ # action.dialogs_alert message: 'Perform action'
35
+ # end
36
+ # menu.button text: 'Delete', onClick: ->(action) do
37
+ # action.dialogs_alert message: 'Perform action'
38
+ # end
39
+ # end
16
40
  end
17
41
 
18
42
  end
@@ -17,6 +17,9 @@ json_ui_page json do |page|
17
17
  template.thumbnail title: 'FAB (Floating Action Button)', onClick: ->(action) do
18
18
  action.windows_open url: json_ui_garage_url(path: 'lists/fab')
19
19
  end
20
+ template.thumbnail title: 'Chat Prototype', onClick: ->(action) do
21
+ action.windows_open url: json_ui_garage_url(path: 'lists/chat')
22
+ end
20
23
  end
21
24
 
22
25
  end
@@ -1,4 +1,3 @@
1
-
2
1
  batch_count = 30
3
2
  items = (1..batch_count)
4
3
  section = page.table_section_builder
@@ -10,4 +9,4 @@ section.rows objects: items, builder: ->(row, item, index) do
10
9
  end, onClick: ->(action) do
11
10
  action.windows_open url: json_ui_garage_url(path: 'home/blank')
12
11
  end
13
- end
12
+ end
@@ -1,39 +1,39 @@
1
1
 
2
2
  page_index = params[:page].to_i
3
3
  next_page = {
4
- url: json_ui_garage_url(path: 'tables/autoload_all', page: page_index + 1, section_only: 'v1'),
4
+ url: json_ui_garage_url(path: 'tables/autoload_as_needed', page: page_index + 1, section_only: 'v1'),
5
5
  autoload: 'asNeeded'
6
6
  }
7
7
 
8
+ page = json_ui_page json
8
9
  column_indexes = (1..3)
10
+
9
11
  if params[:section_only].present?
12
+ sleep 1
13
+
10
14
  json.nextPage next_page if page_index < 3
11
- json_ui_page json do |page|
12
- json.sections do
13
- json.child! do
14
- render 'json_ui/garage/tables/autoload_section', page: page, page_index: page_index, column_indexes: column_indexes
15
- end
15
+ json.sections do
16
+ json.child! do
17
+ render 'json_ui/garage/tables/autoload_section', page: page, page_index: page_index, column_indexes: column_indexes
16
18
  end
17
19
  end
18
20
  else
19
21
  json.title 'Tables'
20
22
 
21
- json_ui_page json do |page|
22
- render "#{@path_prefix}/nav_menu", json: json, page: page
23
+ render "#{@path_prefix}/nav_menu", json: json, page: page
23
24
 
24
- page.table nextPage: next_page, firstSection: ->(section) do
25
- section.header cellViews: ->(header) do
26
- column_indexes.each do |i|
27
- header.label text: "Heading#{i}"
28
- end
25
+ page.table nextPage: next_page, firstSection: ->(section) do
26
+ section.header cellViews: ->(header) do
27
+ column_indexes.each do |i|
28
+ header.label text: "Heading#{i}"
29
29
  end
30
-
31
- render "#{@path_prefix}/tables/autoload_section", page: page, page_index: page_index, column_indexes: column_indexes
32
- end, onScrollToBottom: ->(action) do
33
- action.snackbars_alert message: 'Scrolled to Bottom'
34
- end, onScrollToTop: ->(action) do
35
- action.snackbars_alert message: 'Scrolled to Top'
36
30
  end
31
+
32
+ render "#{@path_prefix}/tables/autoload_section", page: page, page_index: page_index, column_indexes: column_indexes
33
+ end, onScrollToBottom: ->(action) do
34
+ action.snackbars_alert message: 'Scrolled to Bottom'
35
+ end, onScrollToTop: ->(action) do
36
+ action.snackbars_alert message: 'Scrolled to Top'
37
37
  end
38
38
 
39
39
  end
@@ -8,3 +8,4 @@ require_relative './json_crawler/action_crawlers/windows_open'
8
8
  require_relative './json_crawler/action_crawlers/action_http'
9
9
  require_relative './json_crawler/action_crawlers/forms_submit'
10
10
  require_relative './json_crawler/action_crawlers/menu'
11
+ require_relative './json_crawler/action_crawlers/run_multiple'
@@ -14,7 +14,10 @@ module Glib
14
14
  click view
15
15
  end
16
16
  end
17
- end
18
17
 
18
+ def perform(action)
19
+ @http.router.process_action(@http, action)
20
+ end
21
+ end
19
22
  end
20
23
  end
@@ -4,11 +4,8 @@ module Glib
4
4
  def initialize(method, http, args, controller)
5
5
  @http = http
6
6
  json = @http.send(method, args['url'], controller, args.fetch('formData', {}))
7
-
8
- unless json.nil?
9
- click(json)
10
- end
7
+ perform(json['onResponse'])
11
8
  end
12
9
  end
13
10
  end
14
- end
11
+ end
@@ -41,7 +41,7 @@ module Glib
41
41
  end
42
42
 
43
43
  json = @http.patch url, action, params
44
- click(json)
44
+ perform(json['onResponse'])
45
45
  end
46
46
  end
47
47
  end
@@ -9,6 +9,8 @@ module Glib
9
9
  crawl left_drawer['header']&.[]('childViews')
10
10
  crawl left_drawer['rows']
11
11
  end
12
+
13
+ perform(json['onLoad'])
12
14
  end
13
15
  end
14
16
  end
@@ -0,0 +1,13 @@
1
+ module Glib
2
+ module JsonCrawler
3
+ class RunMultiple < ActionCrawler
4
+ def initialize(http, args, action)
5
+ @http = http
6
+
7
+ args['childActions']&.each do |button|
8
+ perform(button)
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -3,6 +3,7 @@ module Glib
3
3
  class WindowsOpen < ActionCrawler
4
4
  def initialize(http, args, action)
5
5
  @http = http
6
+
6
7
  if (url = args['url'])
7
8
  json = @http.get(url, action, args.except('url'))
8
9
 
@@ -20,6 +21,8 @@ module Glib
20
21
  click button
21
22
  end
22
23
  end
24
+
25
+ perform(json['onLoad'])
23
26
  end
24
27
  end
25
28
  end
@@ -19,6 +19,7 @@ module Glib
19
19
  end
20
20
 
21
21
  def step(http, args)
22
+ # TODO: Refactor
22
23
  case args['view']
23
24
  when 'fields/submit-v1', 'fields/submit'
24
25
  @depth += 1
@@ -29,40 +30,45 @@ module Glib
29
30
  end
30
31
 
31
32
  if args.is_a?(Hash) && args['rel'] != 'nofollow'
32
- if (onClick = (args.fetch('onClick', nil) || args.fetch('onResponse', nil)))
33
- action = onClick['action']
34
- params = onClick
33
+ if (onClick = (args.fetch('onClick', nil)))
34
+ process_action(http, onClick)
35
35
  end
36
+ end
37
+ end
36
38
 
37
- if action.present?
38
- @depth += 1
39
- case action
40
- when 'initiate_navigation'
41
- @read_only_actions.add([action, params['url']])
42
- JsonCrawler::NavInitiate.new(http, params, action)
43
- when 'windows/open-v1', 'dialogs/open-v1', 'windows/reload-v1', 'windows/open', 'dialogs/open', 'windows/reload'
39
+ def process_action(http, spec)
40
+ action = spec['action']
41
+ params = spec
42
+
43
+ if action.present?
44
+ @depth += 1
45
+ case action
46
+ when 'initiate_navigation'
47
+ @read_only_actions.add([action, params['url']])
48
+ JsonCrawler::NavInitiate.new(http, params, action)
49
+ when 'runMultiple-v1', 'runMultiple'
50
+ JsonCrawler::RunMultiple.new(http, params, action)
51
+ when 'windows/open-v1', 'dialogs/open-v1', 'windows/reload-v1', 'windows/open', 'dialogs/open', 'windows/reload'
52
+ @read_only_actions.add([action, params['url']])
53
+ JsonCrawler::WindowsOpen.new(http, params, action)
54
+ when 'sheets/select-v1', 'sheets/select'
55
+ JsonCrawler::Menu.new(http, params, action)
56
+ when 'http/post-v1', 'http/post'
57
+ JsonCrawler::ActionHttp.new(:post, http, params, action)
58
+ when 'forms/submit-v1', 'forms/submit'
59
+ forms = @visitor.forms
60
+ # raise 'Submit action needs to be inside a form' if forms.size < 1
61
+ JsonCrawler::FormsSubmit.new(http, forms.last)
62
+ else
63
+ unless [
64
+ 'http/delete-v1', 'dialogs/oauth-v1', 'windows/openWeb-v1',
65
+ 'http/delete', 'dialogs/oauth', 'windows/openWeb'
66
+ ].include?(action)
44
67
  @read_only_actions.add([action, params['url']])
45
- JsonCrawler::WindowsOpen.new(http, params, action)
46
- when 'sheets/select-v1', 'sheets/select'
47
- JsonCrawler::Menu.new(http, params, action)
48
- when 'http/post-v1', 'http/post'
49
- JsonCrawler::ActionHttp.new(:post, http, params, action)
50
- when 'forms/submit-v1', 'forms/submit'
51
- forms = @visitor.forms
52
- # raise 'Submit action needs to be inside a form' if forms.size < 1
53
- JsonCrawler::FormsSubmit.new(http, forms.last)
54
- else
55
- unless [
56
- 'http/delete-v1', 'dialogs/oauth-v1', 'windows/openWeb-v1',
57
- 'http/delete', 'dialogs/oauth', 'windows/openWeb'
58
- ].include?(action)
59
- @read_only_actions.add([action, params['url']])
60
- end
61
- self.log action, params['url']
62
68
  end
63
- @depth -= 1
64
- # child
69
+ self.log action, params['url']
65
70
  end
71
+ @depth -= 1
66
72
  end
67
73
  end
68
74
 
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.9
4
+ version: 0.5.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''
@@ -107,7 +107,6 @@ files:
107
107
  - app/validators/email_typo_validator.rb
108
108
  - app/validators/email_validator.rb
109
109
  - app/validators/url_validator.rb
110
- - app/views/app/views/json_ui/vue/renderer.html.erb
111
110
  - app/views/json_ui/garage/_nav_menu.json.jbuilder
112
111
  - app/views/json_ui/garage/actions/_dialogs.json.jbuilder
113
112
  - app/views/json_ui/garage/actions/_http.json.jbuilder
@@ -144,6 +143,7 @@ files:
144
143
  - app/views/json_ui/garage/home/index.json.jbuilder
145
144
  - app/views/json_ui/garage/home/slow.json.jbuilder
146
145
  - app/views/json_ui/garage/lists/_infinite_scroll_section.json.jbuilder
146
+ - app/views/json_ui/garage/lists/chat.json.jbuilder
147
147
  - app/views/json_ui/garage/lists/edit_actions.json.jbuilder
148
148
  - app/views/json_ui/garage/lists/fab.json.jbuilder
149
149
  - app/views/json_ui/garage/lists/index.json.jbuilder
@@ -214,6 +214,7 @@ files:
214
214
  - lib/glib/json_crawler/action_crawlers/forms_submit.rb
215
215
  - lib/glib/json_crawler/action_crawlers/menu.rb
216
216
  - lib/glib/json_crawler/action_crawlers/nav_initiate.rb
217
+ - lib/glib/json_crawler/action_crawlers/run_multiple.rb
217
218
  - lib/glib/json_crawler/action_crawlers/windows_open.rb
218
219
  - lib/glib/json_crawler/coverage.rb
219
220
  - lib/glib/json_crawler/http.rb
@@ -1,35 +0,0 @@
1
- <!-- Deprecated. Use layouts instead
2
- <!DOCTYPE html>
3
- <html>
4
-
5
- <head>
6
- <meta charset="utf-8" />
7
- <meta content="width=device-width, initial-scale=1, shrink-to-fit=no" name="viewport" />
8
-
9
- <title>App</title>
10
- <%= csrf_meta_tags %>
11
-
12
- <%= javascript_pack_tag 'vue_renderer', defer: true %>
13
- <%#= javascript_include_tag 'vue_renderer_extras', defer: true %>
14
-
15
- <%= stylesheet_pack_tag 'vue_renderer' %>
16
- <% if (custom_css_path = options[:custom_css_path]) %>
17
- <%= stylesheet_link_tag custom_css_path, media: 'all' %>
18
- <% end %>
19
-
20
- <link href="https://fonts.googleapis.com/css?family=Material+Icons" rel="stylesheet" />
21
- </head>
22
-
23
- <body>
24
- <noscript>Please enable JavaScript to view this web site.</noscript>
25
- <div id="app"></div>
26
-
27
- <script>
28
- var __page = <%= raw @__json_ui_orig_page%>;
29
- </script>
30
-
31
- <% locals[:footer_block]&.call %>
32
- </body>
33
-
34
- </html>
35
- -->