glib-web 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/concerns/application/json/ui.rb +5 -0
- data/app/helpers/glib/json_ui/list_builders.rb +12 -8
- data/app/helpers/glib/json_ui/page_helper.rb +8 -5
- data/app/helpers/glib/json_ui/split_builders.rb +39 -0
- data/app/helpers/glib/json_ui/view_builder/panels.rb +12 -4
- data/app/helpers/glib/json_ui/view_builder.rb +10 -16
- data/app/views/json_ui/garage/_nav_menu.json.jbuilder +6 -2
- data/app/views/json_ui/garage/actions/index.json.jbuilder +4 -4
- data/app/views/json_ui/garage/forms/basic.json.jbuilder +18 -5
- data/app/views/json_ui/garage/forms/get_request.json.jbuilder +8 -2
- data/app/views/json_ui/garage/notifications/index.json.jbuilder +13 -0
- data/app/views/json_ui/garage/panels/card.json.jbuilder +22 -6
- data/app/views/json_ui/garage/panels/index.json.jbuilder +2 -0
- data/app/views/json_ui/garage/panels/split.json.jbuilder +252 -84
- data/app/views/json_ui/garage/panels/vertical.json.jbuilder +5 -5
- data/app/views/json_ui/garage/views/index.json.jbuilder +66 -20
- data/app/views/json_ui/garage/views/markdowns.json.jbuilder +30 -0
- data/app/views/json_ui/garage/views/texts.json.jbuilder +0 -6
- data/lib/glib/json_crawler/action_crawler.rb +3 -20
- data/lib/glib/json_crawler/action_crawlers/forms_submit.rb +32 -0
- data/lib/glib/json_crawler/action_crawlers/windows_open.rb +2 -0
- data/lib/glib/json_crawler/http.rb +10 -9
- data/lib/glib/json_crawler/router.rb +71 -15
- data/lib/glib/json_crawler.rb +2 -1
- metadata +5 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 914905b67e8a3e6fa089723850360b7ff684a53f
|
4
|
+
data.tar.gz: 4fc3dfc87dce95a3b5d7b74555781fb75d362efe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a7ccc5a33d14a02abd8d849abc13ef3e53a9307866a167af012eb065b3ee7df13db117dc6939af7fd985a7cf03f7afd323a4f72c475d9c12bc784b25f85dcc55
|
7
|
+
data.tar.gz: 3602887b7f41295009a0b988a0ea97b9ec5d80d511e1d256de8c101c29cf38711d0a4d73140838e8bcec779ccb9e54996204c957a6faa906dffafccf80196ead
|
@@ -13,6 +13,11 @@ module Concerns::Application::Json::Ui
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
+
# Override
|
17
|
+
def form_authenticity_token
|
18
|
+
Rails.env.test? ? 'test_token' : super
|
19
|
+
end
|
20
|
+
|
16
21
|
# NOTE: Override default_url_options and call this method
|
17
22
|
def json_ui_url_options
|
18
23
|
options = {}
|
@@ -37,10 +37,12 @@ module Glib
|
|
37
37
|
|
38
38
|
def header(options = {})
|
39
39
|
json.header do
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
40
|
+
page.vertical_content(options)
|
41
|
+
|
42
|
+
# json.padding options[:padding]
|
43
|
+
# json.childViews do
|
44
|
+
# options[:childViews]&.call page.view_builder
|
45
|
+
# end
|
44
46
|
end
|
45
47
|
end
|
46
48
|
|
@@ -59,10 +61,12 @@ module Glib
|
|
59
61
|
|
60
62
|
def footer(options = {})
|
61
63
|
json.footer do
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
64
|
+
page.vertical_content(options)
|
65
|
+
|
66
|
+
# json.padding options[:padding]
|
67
|
+
# json.childViews do
|
68
|
+
# options[:childViews]&.call page.view_builder
|
69
|
+
# end
|
66
70
|
end
|
67
71
|
end
|
68
72
|
end
|
@@ -16,7 +16,7 @@ module Glib
|
|
16
16
|
|
17
17
|
class Page
|
18
18
|
attr_reader :json, :context, :view_builder, :action_builder, :menu_builder
|
19
|
-
attr_reader :list_section_builder, :drawer_content_builder, :
|
19
|
+
attr_reader :list_section_builder, :table_section_builder, :drawer_content_builder, :split_content_builder
|
20
20
|
|
21
21
|
# See Panels::Form
|
22
22
|
attr_accessor :current_form
|
@@ -32,7 +32,7 @@ module Glib
|
|
32
32
|
@list_section_builder = ListBuilders::Section.new(json, self, ListBuilders::Template.new(json, self))
|
33
33
|
@drawer_content_builder = ListBuilders::Section.new(json, self, @menu_builder)
|
34
34
|
@table_section_builder = TableBuilders::Section.new(json, self, TableBuilders::Template.new(json, self))
|
35
|
-
|
35
|
+
@split_content_builder = SplitBuilders::Content.new(json, self, @view_builder)
|
36
36
|
end
|
37
37
|
|
38
38
|
def rightNavButtons
|
@@ -106,18 +106,21 @@ module Glib
|
|
106
106
|
end
|
107
107
|
end
|
108
108
|
|
109
|
-
private
|
110
109
|
def vertical_content(options)
|
111
110
|
options = options.reverse_merge(width: 'matchParent')
|
112
111
|
|
113
112
|
[:padding, :backgroundColor, :width, :height, :align].each do |name|
|
114
|
-
if (value = options
|
113
|
+
if (value = options.delete(name))
|
115
114
|
json.set! name, value
|
116
115
|
end
|
117
116
|
end
|
118
117
|
json.childViews do
|
119
|
-
options
|
118
|
+
if (childViews = options.delete(:childViews))
|
119
|
+
childViews.call @view_builder
|
120
|
+
end
|
120
121
|
end
|
122
|
+
|
123
|
+
raise "Invalid properties: #{options.keys}" if options.size > 0
|
121
124
|
end
|
122
125
|
|
123
126
|
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Glib
|
2
|
+
module JsonUi
|
3
|
+
module SplitBuilders
|
4
|
+
|
5
|
+
class Content < AbstractBuilder
|
6
|
+
def initialize json, page, template
|
7
|
+
super json, page
|
8
|
+
@template = template
|
9
|
+
end
|
10
|
+
|
11
|
+
def left(options = {})
|
12
|
+
json.left do
|
13
|
+
page.vertical_content(options)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def center(options = {})
|
18
|
+
json.center do
|
19
|
+
page.vertical_content(options)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def right(options = {})
|
24
|
+
json.right do
|
25
|
+
page.vertical_content(options)
|
26
|
+
end
|
27
|
+
|
28
|
+
# json.right do
|
29
|
+
# json.padding options[:padding]
|
30
|
+
# json.childViews do
|
31
|
+
# options[:childViews]&.call page.view_builder
|
32
|
+
# end
|
33
|
+
# end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -75,8 +75,9 @@ class Glib::JsonUi::ViewBuilder
|
|
75
75
|
json.child! do
|
76
76
|
json.view 'fields/hidden-v1'
|
77
77
|
json.name 'authenticity_token'
|
78
|
+
json.value page.context.form_authenticity_token
|
78
79
|
# Produce consistent token for predictible test results
|
79
|
-
json.value Rails.env.test? ? 'test_token' : page.context.form_authenticity_token
|
80
|
+
# json.value Rails.env.test? ? 'test_token' : page.context.form_authenticity_token
|
80
81
|
end
|
81
82
|
end
|
82
83
|
|
@@ -140,10 +141,17 @@ class Glib::JsonUi::ViewBuilder
|
|
140
141
|
string :align
|
141
142
|
end
|
142
143
|
|
144
|
+
# class Split < View
|
145
|
+
# views :leftViews
|
146
|
+
# views :centerViews
|
147
|
+
# views :rightViews
|
148
|
+
# string :align
|
149
|
+
# end
|
150
|
+
|
143
151
|
class Split < View
|
144
|
-
|
145
|
-
|
146
|
-
|
152
|
+
def content(block)
|
153
|
+
block.call page.split_content_builder
|
154
|
+
end
|
147
155
|
end
|
148
156
|
|
149
157
|
class Responsive < View
|
@@ -41,34 +41,28 @@ module Glib
|
|
41
41
|
|
42
42
|
### View definitions
|
43
43
|
|
44
|
-
class
|
44
|
+
class AbstractText < View
|
45
|
+
string :textAlign
|
45
46
|
string :text
|
46
47
|
color :color
|
47
48
|
end
|
48
49
|
|
49
|
-
class
|
50
|
-
string :text
|
51
|
-
color :color
|
50
|
+
class H1 < AbstractText
|
52
51
|
end
|
53
52
|
|
54
|
-
class
|
55
|
-
string :text
|
56
|
-
color :color
|
53
|
+
class H2 < AbstractText
|
57
54
|
end
|
58
55
|
|
59
|
-
class
|
60
|
-
string :text
|
61
|
-
color :color
|
56
|
+
class H3 < AbstractText
|
62
57
|
end
|
63
58
|
|
64
|
-
class
|
65
|
-
|
66
|
-
|
59
|
+
class H4 < AbstractText
|
60
|
+
end
|
61
|
+
|
62
|
+
class P < AbstractText
|
67
63
|
end
|
68
64
|
|
69
|
-
class Label <
|
70
|
-
string :text
|
71
|
-
color :color
|
65
|
+
class Label < AbstractText
|
72
66
|
action :onClick
|
73
67
|
end
|
74
68
|
|
@@ -41,10 +41,14 @@ if local_assigns[:top_nav] || json_ui_app_is_web?
|
|
41
41
|
menu.divider
|
42
42
|
menu.label text: 'Misc Menu'
|
43
43
|
|
44
|
-
menu.button icon: '
|
45
|
-
action.windows_open url: json_ui_garage_url
|
44
|
+
menu.button icon: 'notifications', text: 'Notifications', onClick: ->(action) do
|
45
|
+
action.windows_open url: json_ui_garage_url(path: 'notifications/index')
|
46
46
|
end
|
47
47
|
|
48
|
+
menu.button icon: 'list', text: 'UI Elements', onClick: ->(action) do
|
49
|
+
action.windows_open url: json_ui_garage_url
|
50
|
+
end
|
51
|
+
|
48
52
|
menu.button icon: { name: 'zoom_in', badge: '!' }, text: 'Diagnostics', onClick: ->(action) do
|
49
53
|
action.dialogs_alert message: %{
|
50
54
|
Bundle ID: #{json_ui_app_bundle_id || '<unknown>'}
|
@@ -5,7 +5,7 @@ json_ui_page json do |page|
|
|
5
5
|
|
6
6
|
page.list sections: [
|
7
7
|
->(section) do
|
8
|
-
section.header padding:
|
8
|
+
section.header padding: glib_json_padding_list, childViews: ->(header) do
|
9
9
|
header.h3 text: 'Dialogs'
|
10
10
|
end
|
11
11
|
|
@@ -46,7 +46,7 @@ json_ui_page json do |page|
|
|
46
46
|
|
47
47
|
end
|
48
48
|
end, ->(section) do
|
49
|
-
section.header padding:
|
49
|
+
section.header padding: glib_json_padding_list, childViews: ->(header) do
|
50
50
|
header.h3 text: 'Snackbars'
|
51
51
|
end
|
52
52
|
|
@@ -83,7 +83,7 @@ json_ui_page json do |page|
|
|
83
83
|
|
84
84
|
end
|
85
85
|
end, ->(section) do
|
86
|
-
section.header padding:
|
86
|
+
section.header padding: glib_json_padding_list, childViews: ->(header) do
|
87
87
|
header.h3 text: 'Windows'
|
88
88
|
end
|
89
89
|
|
@@ -107,7 +107,7 @@ json_ui_page json do |page|
|
|
107
107
|
end
|
108
108
|
end
|
109
109
|
end, ->(section) do
|
110
|
-
section.header padding:
|
110
|
+
section.header padding: glib_json_padding_list, childViews: ->(header) do
|
111
111
|
header.h3 text: 'Reload'
|
112
112
|
header.spacer height: 6
|
113
113
|
header.label text: 'Reload does not open a new page/screen. Click reload a few times, then click back and notice that it goes back to the page before the reload.'
|
@@ -7,12 +7,25 @@ json_ui_page json do |page|
|
|
7
7
|
form.fields_text name: 'user[name]', width: 'matchParent', label: 'Name'
|
8
8
|
form.fields_password name: 'user[password]', width: 'matchParent', label: 'Password'
|
9
9
|
|
10
|
-
form.panels_split width: 'matchParent', leftViews: ->(split) do
|
11
|
-
|
12
|
-
|
10
|
+
# form.panels_split width: 'matchParent', leftViews: ->(split) do
|
11
|
+
# if params[:mode] == 'dialog'
|
12
|
+
# split.button styleClass: 'link', text: 'cancel', onClick: ->(action) { action.dialogs_close }
|
13
|
+
# end
|
14
|
+
# end, rightViews: ->(split) do
|
15
|
+
# split.button text: 'Submit', onClick: ->(action) { action.forms_submit }
|
16
|
+
# end
|
17
|
+
|
18
|
+
form.panels_split width: 'matchParent', content: ->(split) do
|
19
|
+
split.left childViews: ->(left) do
|
20
|
+
if params[:mode] == 'dialog'
|
21
|
+
left.button styleClass: 'link', text: 'cancel', onClick: ->(action) { action.dialogs_close }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
split.right childViews: ->(right) do
|
25
|
+
right.button text: 'Submit', onClick: ->(action) { action.forms_submit }
|
13
26
|
end
|
14
|
-
end, rightViews: ->(split) do
|
15
|
-
split.button text: 'Submit', onClick: ->(action) { action.forms_submit }
|
16
27
|
end
|
28
|
+
|
17
29
|
end
|
30
|
+
|
18
31
|
end
|
@@ -15,8 +15,14 @@ json_ui_page json do |page|
|
|
15
15
|
form.spacer height: 10
|
16
16
|
form.fields_text name: 'user[name]', width: 'matchParent', label: 'Name'
|
17
17
|
|
18
|
-
form.panels_split width: 'matchParent', rightViews: ->(split) do
|
19
|
-
|
18
|
+
# form.panels_split width: 'matchParent', rightViews: ->(split) do
|
19
|
+
# split.button text: 'Submit', onClick: ->(action) { action.forms_submit }
|
20
|
+
# end
|
21
|
+
|
22
|
+
form.panels_split width: 'matchParent', content: ->(split) do
|
23
|
+
split.right childViews: ->(right) do
|
24
|
+
right.button text: 'Submit', onClick: ->(action) { action.forms_submit }
|
25
|
+
end
|
20
26
|
end
|
21
27
|
end
|
22
28
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
json.title 'Notifications'
|
2
|
+
|
3
|
+
json_ui_page json do |page|
|
4
|
+
render "#{@path_prefix}/nav_menu", json: json, page: page, top_nav: true
|
5
|
+
|
6
|
+
page.list firstSection: ->(section) do
|
7
|
+
section.rows builder: ->(template) do
|
8
|
+
template.thumbnail title: 'Send Desktop Notification', onClick: ->(action) do
|
9
|
+
# TODO: Send and display desktop notification
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -44,16 +44,32 @@ json_ui_page json do |page|
|
|
44
44
|
panel.button text: 'Button3'
|
45
45
|
end
|
46
46
|
|
47
|
+
# scroll.spacer height: 20
|
48
|
+
# scroll.h2 text: 'Split panel'
|
49
|
+
# scroll.spacer height: 6
|
50
|
+
# scroll.panels_split styleClass: 'card', padding: glib_json_padding_body, width: 'matchParent', leftViews: ->(panel) do
|
51
|
+
# panel.button text: '1'
|
52
|
+
# end, centerViews: ->(panel) do
|
53
|
+
# panel.button width: 'matchParent', text: '2'
|
54
|
+
# end, rightViews: ->(panel) do
|
55
|
+
# panel.button text: '3'
|
56
|
+
# end
|
57
|
+
|
47
58
|
scroll.spacer height: 20
|
48
59
|
scroll.h2 text: 'Split panel'
|
49
60
|
scroll.spacer height: 6
|
50
|
-
scroll.panels_split styleClass: 'card', padding: glib_json_padding_body, width: 'matchParent',
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
61
|
+
scroll.panels_split styleClass: 'card', padding: glib_json_padding_body, width: 'matchParent', content: ->(split) do
|
62
|
+
split.left childViews: ->(left) do
|
63
|
+
left.button text: '1'
|
64
|
+
end
|
65
|
+
split.center childViews: ->(center) do
|
66
|
+
center.button width: 'matchParent', text: '2'
|
67
|
+
end
|
68
|
+
split.right childViews: ->(right) do
|
69
|
+
right.button text: '3'
|
70
|
+
end
|
56
71
|
end
|
72
|
+
|
57
73
|
|
58
74
|
scroll.spacer height: 20
|
59
75
|
scroll.h2 text: 'Responsive panel'
|
@@ -7,6 +7,8 @@ json_ui_page json do |page|
|
|
7
7
|
->(section) do
|
8
8
|
section.header padding: glib_json_padding_list, childViews: ->(header) do
|
9
9
|
header.h2 text: 'Layout for child components'
|
10
|
+
header.spacer height: 6
|
11
|
+
header.label text: 'May contain infinite number of child components'
|
10
12
|
end
|
11
13
|
|
12
14
|
section.rows builder: ->(template) do
|
@@ -5,136 +5,304 @@ json_ui_page json do |page|
|
|
5
5
|
|
6
6
|
page.scroll padding: glib_json_padding_body, childViews: ->(scroll) do
|
7
7
|
|
8
|
-
# TODO: Consider moving towards this
|
9
|
-
# scroll.panels_split width: 'matchParent', builder: ->(builder) do
|
10
|
-
# builder.left childViews: ->(left) do
|
11
|
-
# left.button text: '1'
|
12
|
-
# end
|
13
|
-
# builder.right childViews: ->(right) do
|
14
|
-
# right.button text: '2'
|
15
|
-
# end
|
16
|
-
# end
|
17
|
-
|
18
8
|
scroll.h1 text: '2 columns'
|
19
|
-
scroll.panels_split width: 'matchParent',
|
20
|
-
|
21
|
-
|
22
|
-
|
9
|
+
scroll.panels_split width: 'matchParent', content: ->(content) do
|
10
|
+
content.left childViews: ->(left) do
|
11
|
+
left.button text: '1'
|
12
|
+
end
|
13
|
+
content.right childViews: ->(right) do
|
14
|
+
right.button text: '2'
|
15
|
+
end
|
23
16
|
end
|
24
17
|
|
25
18
|
scroll.label text: "\n"
|
26
19
|
scroll.h1 text: '3 columns'
|
27
|
-
scroll.panels_split width: 'matchParent',
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
20
|
+
scroll.panels_split width: 'matchParent', content: ->(content) do
|
21
|
+
content.left childViews: ->(left) do
|
22
|
+
left.button text: '1'
|
23
|
+
end
|
24
|
+
content.center childViews: ->(center) do
|
25
|
+
center.button width: 'matchParent', text: '2'
|
26
|
+
end
|
27
|
+
content.right childViews: ->(right) do
|
28
|
+
right.button text: '3'
|
29
|
+
end
|
33
30
|
end
|
34
31
|
|
35
32
|
scroll.label text: "\n"
|
36
33
|
scroll.h1 text: 'Expandable left'
|
37
|
-
scroll.panels_split width: 'matchParent',
|
38
|
-
|
39
|
-
|
40
|
-
|
34
|
+
scroll.panels_split width: 'matchParent', content: ->(content) do
|
35
|
+
content.center childViews: ->(center) do
|
36
|
+
center.button width: 'matchParent', text: '1'
|
37
|
+
end
|
38
|
+
content.right childViews: ->(right) do
|
39
|
+
right.button text: '2'
|
40
|
+
end
|
41
41
|
end
|
42
42
|
|
43
43
|
scroll.label text: "\n"
|
44
44
|
scroll.h1 text: 'Expandable right'
|
45
|
-
scroll.panels_split width: 'matchParent',
|
46
|
-
|
47
|
-
|
48
|
-
|
45
|
+
scroll.panels_split width: 'matchParent', content: ->(content) do
|
46
|
+
content.left childViews: ->(left) do
|
47
|
+
left.button text: '1'
|
48
|
+
end
|
49
|
+
content.center childViews: ->(center) do
|
50
|
+
center.button width: 'matchParent', text: '2'
|
51
|
+
end
|
49
52
|
end
|
50
53
|
|
51
54
|
scroll.label text: "\n"
|
52
55
|
scroll.h1 text: 'Short center text'
|
53
|
-
scroll.panels_split width: 'matchParent',
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
56
|
+
scroll.panels_split width: 'matchParent', content: ->(content) do
|
57
|
+
content.left childViews: ->(left) do
|
58
|
+
left.button text: '1'
|
59
|
+
end
|
60
|
+
content.center childViews: ->(center) do
|
61
|
+
center.label text: 'short'
|
62
|
+
end
|
63
|
+
content.right childViews: ->(right) do
|
64
|
+
right.button text: '2'
|
65
|
+
end
|
59
66
|
end
|
60
67
|
|
61
68
|
scroll.label text: "\n"
|
62
69
|
scroll.h1 text: 'Long center text'
|
63
|
-
scroll.panels_split width: 'matchParent',
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
70
|
+
scroll.panels_split width: 'matchParent', content: ->(content) do
|
71
|
+
content.left childViews: ->(left) do
|
72
|
+
left.button text: '1'
|
73
|
+
end
|
74
|
+
content.center childViews: ->(center) do
|
75
|
+
center.label text: 'a very very very very very very very very very very very very very very very very very very very very very very very very very very very very long text'
|
76
|
+
end
|
77
|
+
content.right childViews: ->(right) do
|
78
|
+
right.button text: '2'
|
79
|
+
end
|
69
80
|
end
|
70
81
|
|
71
82
|
scroll.label text: "\n"
|
72
83
|
scroll.h1 text: 'Few center items'
|
73
|
-
scroll.panels_split width: 'matchParent',
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
84
|
+
scroll.panels_split width: 'matchParent', content: ->(content) do
|
85
|
+
content.left childViews: ->(left) do
|
86
|
+
left.button text: 'L'
|
87
|
+
end
|
88
|
+
content.center childViews: ->(center) do
|
89
|
+
center.panels_horizontal childViews: ->(h) do
|
90
|
+
h.button text: '1'
|
91
|
+
h.button text: '2'
|
92
|
+
h.button text: '3'
|
93
|
+
end
|
94
|
+
end
|
95
|
+
content.right childViews: ->(right) do
|
96
|
+
right.button text: 'R'
|
97
|
+
end
|
83
98
|
end
|
84
99
|
|
85
100
|
scroll.label text: "\n"
|
86
101
|
scroll.h1 text: 'Many center items'
|
87
|
-
scroll.panels_split width: 'matchParent',
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
102
|
+
scroll.panels_split width: 'matchParent', content: ->(content) do
|
103
|
+
content.left childViews: ->(left) do
|
104
|
+
left.button text: 'L'
|
105
|
+
end
|
106
|
+
content.center childViews: ->(center) do
|
107
|
+
center.panels_horizontal childViews: ->(h) do
|
108
|
+
(1..20).each do |index|
|
109
|
+
h.button text: index
|
110
|
+
end
|
93
111
|
end
|
94
112
|
end
|
95
|
-
|
96
|
-
|
113
|
+
content.right childViews: ->(right) do
|
114
|
+
right.button text: 'R'
|
115
|
+
end
|
97
116
|
end
|
98
117
|
|
99
118
|
scroll.label text: "\n"
|
100
119
|
scroll.h1 text: 'Center filled equally'
|
101
|
-
scroll.panels_split width: 'matchParent',
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
120
|
+
scroll.panels_split width: 'matchParent', content: ->(content) do
|
121
|
+
content.left childViews: ->(left) do
|
122
|
+
left.button text: 'L'
|
123
|
+
end
|
124
|
+
content.center childViews: ->(center) do
|
125
|
+
center.panels_horizontal width: 'matchParent', backgroundColor: '#b3bac2', distribution: 'fillEqually', childViews: ->(h) do
|
126
|
+
h.button text: '1'
|
127
|
+
h.button text: '2'
|
128
|
+
h.button text: '3'
|
129
|
+
end
|
130
|
+
end
|
131
|
+
content.right childViews: ->(right) do
|
132
|
+
right.button text: 'R'
|
133
|
+
end
|
111
134
|
end
|
112
135
|
|
113
136
|
scroll.label text: "\n"
|
114
137
|
scroll.h1 text: 'Center spaced equally'
|
115
|
-
scroll.panels_split width: 'matchParent',
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
138
|
+
scroll.panels_split width: 'matchParent', content: ->(content) do
|
139
|
+
content.left childViews: ->(left) do
|
140
|
+
left.button text: 'L'
|
141
|
+
end
|
142
|
+
content.center childViews: ->(center) do
|
143
|
+
center.panels_horizontal width: 'matchParent', backgroundColor: '#b3bac2', distribution: 'spaceEqually', childViews: ->(h) do
|
144
|
+
h.button text: '1'
|
145
|
+
h.button text: '2'
|
146
|
+
h.button text: '3'
|
147
|
+
end
|
148
|
+
end
|
149
|
+
content.right childViews: ->(right) do
|
150
|
+
right.button text: 'R'
|
151
|
+
end
|
125
152
|
end
|
126
153
|
|
127
154
|
scroll.label text: "\n"
|
128
155
|
scroll.h1 text: 'Combo 1'
|
129
|
-
scroll.panels_split width: 'matchParent',
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
156
|
+
scroll.panels_split width: 'matchParent', content: ->(content) do
|
157
|
+
content.left childViews: ->(left) do
|
158
|
+
left.label text: 'a very very very very very very very very very very very very very very very very very very very very very very very very very very very very long text'
|
159
|
+
end
|
160
|
+
content.right childViews: ->(right) do
|
161
|
+
right.panels_horizontal backgroundColor: '#b3bac2', distribution: 'spaceEqually', childViews: ->(h) do
|
162
|
+
h.label text: 'Label One'
|
163
|
+
h.label text: 'Label Two'
|
164
|
+
end
|
135
165
|
end
|
136
166
|
end
|
137
167
|
|
168
|
+
scroll.label text: "\n"
|
169
|
+
scroll.h1 text: 'Combo 2'
|
170
|
+
scroll.panels_split content: ->(content) do
|
171
|
+
content.left childViews: ->(left) do
|
172
|
+
left.button text: 'Big'
|
173
|
+
end
|
174
|
+
content.right childViews: ->(right) do
|
175
|
+
right.panels_horizontal height: 'matchParent', align: 'middle', childViews: ->(h) do
|
176
|
+
h.spacer width: 10
|
177
|
+
h.button text: 'small', styleClass: 'link'
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
|
186
|
+
# scroll.h1 text: '2 columns'
|
187
|
+
# scroll.panels_split width: 'matchParent', leftViews: ->(panel) do
|
188
|
+
# panel.button text: '1'
|
189
|
+
# end, rightViews: ->(panel) do
|
190
|
+
# panel.button text: '2'
|
191
|
+
# end
|
192
|
+
|
193
|
+
# scroll.label text: "\n"
|
194
|
+
# scroll.h1 text: '3 columns'
|
195
|
+
# scroll.panels_split width: 'matchParent', leftViews: ->(panel) do
|
196
|
+
# panel.button text: '1'
|
197
|
+
# end, centerViews: ->(panel) do
|
198
|
+
# panel.button width: 'matchParent', text: '2'
|
199
|
+
# end, rightViews: ->(panel) do
|
200
|
+
# panel.button text: '3'
|
201
|
+
# end
|
202
|
+
|
203
|
+
# scroll.label text: "\n"
|
204
|
+
# scroll.h1 text: 'Expandable left'
|
205
|
+
# scroll.panels_split width: 'matchParent', centerViews: ->(panel) do
|
206
|
+
# panel.button width: 'matchParent', text: '1'
|
207
|
+
# end, rightViews: ->(panel) do
|
208
|
+
# panel.button text: '2'
|
209
|
+
# end
|
210
|
+
|
211
|
+
# scroll.label text: "\n"
|
212
|
+
# scroll.h1 text: 'Expandable right'
|
213
|
+
# scroll.panels_split width: 'matchParent', leftViews: ->(panel) do
|
214
|
+
# panel.button text: '1'
|
215
|
+
# end, centerViews: ->(panel) do
|
216
|
+
# panel.button width: 'matchParent', text: '2'
|
217
|
+
# end
|
218
|
+
|
219
|
+
# scroll.label text: "\n"
|
220
|
+
# scroll.h1 text: 'Short center text'
|
221
|
+
# scroll.panels_split width: 'matchParent', leftViews: ->(panel) do
|
222
|
+
# panel.button text: '1'
|
223
|
+
# end, centerViews: ->(panel) do
|
224
|
+
# panel.label text: 'short'
|
225
|
+
# end, rightViews: ->(panel) do
|
226
|
+
# panel.button text: '2'
|
227
|
+
# end
|
228
|
+
|
229
|
+
# scroll.label text: "\n"
|
230
|
+
# scroll.h1 text: 'Long center text'
|
231
|
+
# scroll.panels_split width: 'matchParent', leftViews: ->(panel) do
|
232
|
+
# panel.button text: '1'
|
233
|
+
# end, centerViews: ->(panel) do
|
234
|
+
# panel.label text: 'a very very very very very very very very very very very very very very very very very very very very very very very very very very very very long text'
|
235
|
+
# end, rightViews: ->(panel) do
|
236
|
+
# panel.button text: '2'
|
237
|
+
# end
|
238
|
+
|
239
|
+
# scroll.label text: "\n"
|
240
|
+
# scroll.h1 text: 'Few center items'
|
241
|
+
# scroll.panels_split width: 'matchParent', leftViews: ->(panel) do
|
242
|
+
# panel.button text: 'L'
|
243
|
+
# end, centerViews: ->(panel) do
|
244
|
+
# panel.panels_horizontal childViews: ->(h) do
|
245
|
+
# h.button text: '1'
|
246
|
+
# h.button text: '2'
|
247
|
+
# h.button text: '3'
|
248
|
+
# end
|
249
|
+
# end, rightViews: ->(panel) do
|
250
|
+
# panel.button text: 'R'
|
251
|
+
# end
|
252
|
+
|
253
|
+
# scroll.label text: "\n"
|
254
|
+
# scroll.h1 text: 'Many center items'
|
255
|
+
# scroll.panels_split width: 'matchParent', leftViews: ->(panel) do
|
256
|
+
# panel.button text: 'L'
|
257
|
+
# end, centerViews: ->(panel) do
|
258
|
+
# panel.panels_horizontal childViews: ->(h) do
|
259
|
+
# (1..20).each do |index|
|
260
|
+
# h.button text: index
|
261
|
+
# end
|
262
|
+
# end
|
263
|
+
# end, rightViews: ->(panel) do
|
264
|
+
# panel.button text: 'R'
|
265
|
+
# end
|
266
|
+
|
267
|
+
# scroll.label text: "\n"
|
268
|
+
# scroll.h1 text: 'Center filled equally'
|
269
|
+
# scroll.panels_split width: 'matchParent', leftViews: ->(panel) do
|
270
|
+
# panel.button text: 'L'
|
271
|
+
# end, centerViews: ->(panel) do
|
272
|
+
# panel.panels_horizontal backgroundColor: '#b3bac2', distribution: 'fillEqually', childViews: ->(h) do
|
273
|
+
# h.button text: '1'
|
274
|
+
# h.button text: '2'
|
275
|
+
# h.button text: '3'
|
276
|
+
# end
|
277
|
+
# end, rightViews: ->(panel) do
|
278
|
+
# panel.button text: 'R'
|
279
|
+
# end
|
280
|
+
|
281
|
+
# scroll.label text: "\n"
|
282
|
+
# scroll.h1 text: 'Center spaced equally'
|
283
|
+
# scroll.panels_split width: 'matchParent', leftViews: ->(panel) do
|
284
|
+
# panel.button text: 'L'
|
285
|
+
# end, centerViews: ->(panel) do
|
286
|
+
# panel.panels_horizontal backgroundColor: '#b3bac2', distribution: 'spaceEqually', childViews: ->(h) do
|
287
|
+
# h.button text: '1'
|
288
|
+
# h.button text: '2'
|
289
|
+
# h.button text: '3'
|
290
|
+
# end
|
291
|
+
# end, rightViews: ->(panel) do
|
292
|
+
# panel.button text: 'R'
|
293
|
+
# end
|
294
|
+
|
295
|
+
# scroll.label text: "\n"
|
296
|
+
# scroll.h1 text: 'Combo 1'
|
297
|
+
# scroll.panels_split width: 'matchParent', leftViews: ->(panel) do
|
298
|
+
# panel.label text: 'a very very very very very very very very very very very very very very very very very very very very very very very very very very very very long text'
|
299
|
+
# end, rightViews: ->(panel) do
|
300
|
+
# panel.panels_horizontal backgroundColor: '#b3bac2', distribution: 'spaceEqually', childViews: ->(h) do
|
301
|
+
# h.label text: 'Label One'
|
302
|
+
# h.label text: 'Label Two'
|
303
|
+
# end
|
304
|
+
# end
|
305
|
+
|
138
306
|
end
|
139
307
|
end
|
140
308
|
|
@@ -4,7 +4,7 @@ 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
|
-
scroll.h1 text: '
|
7
|
+
scroll.h1 text: 'Basic'
|
8
8
|
scroll.panels_vertical backgroundColor: '#b3bac2', childViews: ->(panel) do
|
9
9
|
panel.button text: 'Button1'
|
10
10
|
panel.button text: 'Button2', width: 200
|
@@ -12,7 +12,7 @@ json_ui_page json do |page|
|
|
12
12
|
end
|
13
13
|
|
14
14
|
scroll.label text: "\n"
|
15
|
-
scroll.h1 text: '
|
15
|
+
scroll.h1 text: 'Equal filling'
|
16
16
|
scroll.panels_vertical backgroundColor: '#b3bac2', height: 300, distribution: 'fillEqually', childViews: ->(panel) do
|
17
17
|
panel.button text: 'Button1'
|
18
18
|
panel.button text: 'Button2'
|
@@ -20,7 +20,7 @@ json_ui_page json do |page|
|
|
20
20
|
end
|
21
21
|
|
22
22
|
scroll.label text: "\n"
|
23
|
-
scroll.h1 text: '
|
23
|
+
scroll.h1 text: 'Equal spacing'
|
24
24
|
scroll.panels_vertical backgroundColor: '#b3bac2', height: 300, distribution: 'spaceEqually', childViews: ->(panel) do
|
25
25
|
panel.button text: 'Button1'
|
26
26
|
panel.button text: 'Button2'
|
@@ -28,7 +28,7 @@ json_ui_page json do |page|
|
|
28
28
|
end
|
29
29
|
|
30
30
|
scroll.label text: "\n"
|
31
|
-
scroll.h1 text: '
|
31
|
+
scroll.h1 text: 'Alignments'
|
32
32
|
scroll.panels_vertical width: 'matchParent', backgroundColor: '#b3bac2', align: 'center', childViews: ->(panel) do
|
33
33
|
panel.button text: 'Center'
|
34
34
|
end
|
@@ -37,7 +37,7 @@ json_ui_page json do |page|
|
|
37
37
|
end
|
38
38
|
|
39
39
|
scroll.label text: "\n"
|
40
|
-
scroll.h1 text: '
|
40
|
+
scroll.h1 text: 'Spacers'
|
41
41
|
scroll.panels_vertical width: 'matchParent', childViews: ->(panel) do
|
42
42
|
panel.button text: '1'
|
43
43
|
panel.spacer height: 10
|
@@ -3,30 +3,76 @@ json.title 'Views'
|
|
3
3
|
json_ui_page json do |page|
|
4
4
|
render "#{@path_prefix}/nav_menu", json: json, page: page, top_nav: true
|
5
5
|
|
6
|
-
page.list
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
page.list sections: [
|
7
|
+
->(section) do
|
8
|
+
section.header padding: glib_json_padding_list, childViews: ->(header) do
|
9
|
+
header.h2 text: 'Components'
|
10
10
|
end
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
11
|
+
|
12
|
+
section.rows builder: ->(template) do
|
13
|
+
template.thumbnail title: 'Texts', onClick: ->(action) do
|
14
|
+
action.windows_open url: json_ui_garage_url(path: 'views/texts')
|
15
|
+
end
|
16
|
+
template.thumbnail title: 'Images', onClick: ->(action) do
|
17
|
+
action.windows_open url: json_ui_garage_url(path: 'views/images')
|
18
|
+
end
|
19
|
+
template.thumbnail title: 'Carousels', onClick: ->(action) do
|
20
|
+
action.windows_open url: json_ui_garage_url(path: 'views/carousels')
|
21
|
+
end
|
22
|
+
template.thumbnail title: 'Charts', onClick: ->(action) do
|
23
|
+
action.windows_open url: json_ui_garage_url(path: 'views/charts')
|
24
|
+
end
|
25
|
+
template.thumbnail title: 'Banners', onClick: ->(action) do
|
26
|
+
action.windows_open url: json_ui_garage_url(path: 'views/banners')
|
27
|
+
end
|
28
|
+
template.thumbnail title: 'Misc', onClick: ->(action) do
|
29
|
+
action.windows_open url: json_ui_garage_url(path: 'views/misc')
|
30
|
+
end
|
22
31
|
end
|
23
|
-
|
24
|
-
|
32
|
+
end,
|
33
|
+
->(section) do
|
34
|
+
section.header padding: glib_json_padding_list, childViews: ->(header) do
|
35
|
+
header.h2 text: 'Styling and Formatting'
|
25
36
|
end
|
26
|
-
|
27
|
-
|
37
|
+
|
38
|
+
section.rows builder: ->(template) do
|
39
|
+
template.thumbnail title: 'Markdowns', onClick: ->(action) do
|
40
|
+
action.windows_open url: json_ui_garage_url(path: 'views/markdowns')
|
41
|
+
end
|
42
|
+
template.thumbnail title: 'Links', onClick: ->(action) do
|
43
|
+
action.windows_open url: json_ui_garage_url(path: 'views/links')
|
44
|
+
end
|
28
45
|
end
|
29
46
|
end
|
47
|
+
]
|
48
|
+
|
49
|
+
# page.list firstSection: ->(section) do
|
50
|
+
# section.rows builder: ->(template) do
|
51
|
+
# template.thumbnail title: 'Texts', onClick: ->(action) do
|
52
|
+
# action.windows_open url: json_ui_garage_url(path: 'views/texts')
|
53
|
+
# end
|
54
|
+
# template.thumbnail title: 'Images', onClick: ->(action) do
|
55
|
+
# action.windows_open url: json_ui_garage_url(path: 'views/images')
|
56
|
+
# end
|
57
|
+
# template.thumbnail title: 'Carousels', onClick: ->(action) do
|
58
|
+
# action.windows_open url: json_ui_garage_url(path: 'views/carousels')
|
59
|
+
# end
|
60
|
+
# template.thumbnail title: 'Charts', onClick: ->(action) do
|
61
|
+
# action.windows_open url: json_ui_garage_url(path: 'views/charts')
|
62
|
+
# end
|
63
|
+
# template.thumbnail title: 'Banners', onClick: ->(action) do
|
64
|
+
# action.windows_open url: json_ui_garage_url(path: 'views/banners')
|
65
|
+
# end
|
66
|
+
# template.thumbnail title: 'Misc', onClick: ->(action) do
|
67
|
+
# action.windows_open url: json_ui_garage_url(path: 'views/misc')
|
68
|
+
# end
|
69
|
+
# template.thumbnail title: 'Markdowns', onClick: ->(action) do
|
70
|
+
# action.windows_open url: json_ui_garage_url(path: 'views/markdowns')
|
71
|
+
# end
|
72
|
+
# template.thumbnail title: 'Links', onClick: ->(action) do
|
73
|
+
# action.windows_open url: json_ui_garage_url(path: 'views/links')
|
74
|
+
# end
|
75
|
+
# end
|
30
76
|
|
31
|
-
end
|
77
|
+
# end
|
32
78
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
json.title 'Views'
|
2
|
+
|
3
|
+
json_ui_page json do |page|
|
4
|
+
render "#{@path_prefix}/nav_menu", json: json, page: page
|
5
|
+
|
6
|
+
page.scroll padding: glib_json_padding_body, childViews: ->(scroll) do
|
7
|
+
scroll.spacer height: 20
|
8
|
+
scroll.h2 text: 'Paragraph'
|
9
|
+
scroll.spacer height: 6
|
10
|
+
scroll.p format: 'markdown', text:
|
11
|
+
'# h1 Heading' + "\n" +
|
12
|
+
'## h2 Heading' + "\n" +
|
13
|
+
'### h3 Heading' + "\n" +
|
14
|
+
'#### h4 Heading' + "\n" +
|
15
|
+
'##### h5 Heading' + "\n" +
|
16
|
+
'###### h6 Heading' + "\n" +
|
17
|
+
"\n" +
|
18
|
+
'## Emphasis' + "\n" +
|
19
|
+
"\n" +
|
20
|
+
'**This is bold text**' + "\n" +
|
21
|
+
"\n" +
|
22
|
+
'__This is bold text__' + "\n" +
|
23
|
+
"\n" +
|
24
|
+
'*This is italic text*' + "\n" +
|
25
|
+
"\n" +
|
26
|
+
'_This is italic text_' + "\n" +
|
27
|
+
"\n" +
|
28
|
+
'~~Strikethrough~~' + "\n"
|
29
|
+
end
|
30
|
+
end
|
@@ -37,11 +37,5 @@ json_ui_page json do |page|
|
|
37
37
|
scroll.h2 text: 'Chip'
|
38
38
|
scroll.spacer height: 6
|
39
39
|
scroll.chip text: 'pending'
|
40
|
-
|
41
|
-
scroll.spacer height: 20
|
42
|
-
scroll.h2 text: 'Banner'
|
43
|
-
scroll.spacer height: 6
|
44
|
-
scroll.banners_alert icon: 'info', message: 'This is an alert banner'
|
45
|
-
|
46
40
|
end
|
47
41
|
end
|
@@ -6,28 +6,11 @@ module Glib
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def crawl views
|
9
|
-
|
10
|
-
|
11
|
-
click view
|
12
|
-
|
13
|
-
# Generic view children
|
14
|
-
crawl view['childViews']
|
15
|
-
|
16
|
-
# panels/split
|
17
|
-
crawl view['leftViews']
|
18
|
-
crawl view['rightViews']
|
19
|
-
|
20
|
-
# Table/List
|
21
|
-
if (sections = view['sections']).is_a? Array
|
22
|
-
sections.each do |section|
|
23
|
-
# Table
|
24
|
-
crawl section['rows']
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|
9
|
+
JsonCrawler::Router::crawl_multiple views, ->(view) do
|
10
|
+
click view
|
29
11
|
end
|
30
12
|
end
|
31
13
|
end
|
14
|
+
|
32
15
|
end
|
33
16
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Glib
|
2
|
+
module JsonCrawler
|
3
|
+
class FormsSubmit < ActionCrawler
|
4
|
+
def initialize http, params, action, form
|
5
|
+
@http = http
|
6
|
+
|
7
|
+
case form['method']
|
8
|
+
when 'patch', 'put'
|
9
|
+
submit_update(form, action)
|
10
|
+
else
|
11
|
+
JsonCrawler::Router.log action, params['url']
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def submit_update(view, action)
|
16
|
+
url = view['url']
|
17
|
+
fields = []
|
18
|
+
params = {}
|
19
|
+
JsonCrawler::Router.crawl_multiple view['childViews'], ->(child) do
|
20
|
+
if child['view'].start_with?('fields/')
|
21
|
+
fields << child
|
22
|
+
params[child['name']] = child['value']
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
json = @http.patch url, action, params
|
27
|
+
click(json)
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -50,21 +50,22 @@ module Glib
|
|
50
50
|
nil
|
51
51
|
end
|
52
52
|
end
|
53
|
-
|
54
|
-
# response_times << response.headers['X-Runtime'].to_f
|
55
|
-
# @context.assert_includes VALID_RESPONSE_CODES, response.code.to_i, "Expected a valid response but was [#{response.code}] #{Rack::Utils::HTTP_STATUS_CODES[response.code.to_i]}:\n#{url}"
|
56
|
-
# if response.content_type == 'application/json'
|
57
|
-
# return response, JSON.parse(response.body)
|
58
|
-
# else
|
59
|
-
# return response, nil
|
60
|
-
# end
|
61
53
|
end
|
54
|
+
|
62
55
|
end
|
63
56
|
|
64
57
|
def post(url, controller, params)
|
65
58
|
fetch(:post, url, controller, params)
|
66
59
|
end
|
67
60
|
|
61
|
+
def patch(url, controller, params)
|
62
|
+
fetch(:patch, url, controller, params)
|
63
|
+
end
|
64
|
+
|
65
|
+
def put(url, controller, params)
|
66
|
+
fetch(:put, url, controller, params)
|
67
|
+
end
|
68
|
+
|
68
69
|
def delete(url, controller, params = {})
|
69
70
|
fetch(:delete, url, controller, {})
|
70
71
|
end
|
@@ -74,7 +75,7 @@ module Glib
|
|
74
75
|
if url.blank? || history.include?(url)
|
75
76
|
nil
|
76
77
|
else
|
77
|
-
history << url
|
78
|
+
# history << url
|
78
79
|
@context.assert_match(URI_REGEXP, url)
|
79
80
|
|
80
81
|
http_header = {
|
@@ -1,43 +1,99 @@
|
|
1
|
+
|
1
2
|
module Glib
|
2
3
|
module JsonCrawler
|
3
4
|
class Router
|
4
|
-
|
5
|
-
cattr_accessor :logger
|
6
|
-
|
7
|
-
def self.log controller, url, response = nil
|
5
|
+
def self.log action, url, response = nil
|
8
6
|
@@logger.puts ' ' * @@depth + [
|
9
|
-
|
7
|
+
action,
|
10
8
|
response.present? ? response.code : nil,
|
11
9
|
url
|
12
10
|
].compact.join(' :: ')
|
13
11
|
end
|
12
|
+
|
13
|
+
def self.set_up(logger)
|
14
|
+
@@depth = -1
|
15
|
+
@@logger = logger
|
16
|
+
@@forms = []
|
17
|
+
end
|
14
18
|
|
15
19
|
def self.step(http, args)
|
16
20
|
if args.is_a?(Hash) && args['rel'] != 'nofollow'
|
17
21
|
if (onClick = (args.fetch('onClick', nil) || args.fetch('onResponse', nil)))
|
18
|
-
|
22
|
+
action = onClick['action']
|
19
23
|
params = onClick
|
20
24
|
end
|
21
25
|
|
22
|
-
if
|
26
|
+
if action.present?
|
23
27
|
@@depth += 1
|
24
|
-
child = case
|
28
|
+
child = case action
|
25
29
|
when 'initiate_navigation'
|
26
|
-
JsonCrawler::NavInitiate.new(http, params,
|
27
|
-
when 'windows/open-v1'
|
28
|
-
JsonCrawler::WindowsOpen.new(http, params,
|
30
|
+
JsonCrawler::NavInitiate.new(http, params, action)
|
31
|
+
when 'windows/open-v1', 'dialogs/open-v1'
|
32
|
+
JsonCrawler::WindowsOpen.new(http, params, action)
|
29
33
|
when 'http/delete-v1'
|
30
|
-
JsonCrawler::ActionHttp.new(:delete, http, params,
|
34
|
+
JsonCrawler::ActionHttp.new(:delete, http, params, action)
|
31
35
|
when 'http/post-v1'
|
32
|
-
JsonCrawler::ActionHttp.new(:post, http, params,
|
36
|
+
JsonCrawler::ActionHttp.new(:post, http, params, action)
|
37
|
+
when 'forms/submit-v1'
|
38
|
+
raise 'Submit action needs to be inside a form' if @@forms.size < 1
|
39
|
+
JsonCrawler::FormsSubmit.new(http, params, action, @@forms.last)
|
33
40
|
else
|
34
|
-
self.log
|
41
|
+
self.log action, params['url']
|
35
42
|
end
|
36
43
|
@@depth -= 1
|
37
44
|
return child
|
38
45
|
end
|
39
46
|
end
|
40
47
|
end
|
48
|
+
|
49
|
+
def self.tear_down
|
50
|
+
@@logger.close
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.crawl_multiple views, block
|
54
|
+
if views.is_a? Array
|
55
|
+
views.each do |view|
|
56
|
+
case view['view']
|
57
|
+
when 'panels/form-v1'
|
58
|
+
@@forms << view
|
59
|
+
crawl_single view, block
|
60
|
+
@@forms.pop
|
61
|
+
else
|
62
|
+
crawl_single view, block
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def self.crawl_vertical_content view, block
|
69
|
+
crawl_multiple view['childViews'], block if view
|
70
|
+
end
|
71
|
+
|
72
|
+
def self.crawl_single view, block
|
73
|
+
block.call view
|
74
|
+
|
75
|
+
# Generic view children
|
76
|
+
crawl_multiple view['childViews'], block
|
77
|
+
|
78
|
+
# panels/split
|
79
|
+
# crawl_multiple view['leftViews'], block
|
80
|
+
# crawl_multiple view['rightViews'], block
|
81
|
+
|
82
|
+
# Split panel
|
83
|
+
crawl_vertical_content view['left'], block
|
84
|
+
crawl_vertical_content view['center'], block
|
85
|
+
crawl_vertical_content view['right'], block
|
86
|
+
|
87
|
+
# TODO: crawl header and footer
|
88
|
+
# Table/List
|
89
|
+
if (sections = view['sections']).is_a? Array
|
90
|
+
sections.each do |section|
|
91
|
+
# Table
|
92
|
+
crawl_multiple section['rows'], block
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
41
97
|
end
|
42
98
|
end
|
43
|
-
end
|
99
|
+
end
|
data/lib/glib/json_crawler.rb
CHANGED
@@ -4,4 +4,5 @@ require_relative './json_crawler/action_crawler'
|
|
4
4
|
|
5
5
|
require_relative './json_crawler/action_crawlers/nav_initiate'
|
6
6
|
require_relative './json_crawler/action_crawlers/windows_open'
|
7
|
-
require_relative './json_crawler/action_crawlers/action_http'
|
7
|
+
require_relative './json_crawler/action_crawlers/action_http'
|
8
|
+
require_relative './json_crawler/action_crawlers/forms_submit'
|
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.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ''
|
@@ -41,6 +41,7 @@ files:
|
|
41
41
|
- app/helpers/glib/json_ui/menu_builder.rb
|
42
42
|
- app/helpers/glib/json_ui/page_helper.rb
|
43
43
|
- app/helpers/glib/json_ui/response_helper.rb
|
44
|
+
- app/helpers/glib/json_ui/split_builders.rb
|
44
45
|
- app/helpers/glib/json_ui/styling_helper.rb
|
45
46
|
- app/helpers/glib/json_ui/table_builders.rb
|
46
47
|
- app/helpers/glib/json_ui/view_builder.rb
|
@@ -77,6 +78,7 @@ files:
|
|
77
78
|
- app/views/json_ui/garage/lists/index.json.jbuilder
|
78
79
|
- app/views/json_ui/garage/lists/infinite_scroll.json.jbuilder
|
79
80
|
- app/views/json_ui/garage/lists/templating.json.jbuilder
|
81
|
+
- app/views/json_ui/garage/notifications/index.json.jbuilder
|
80
82
|
- app/views/json_ui/garage/pages/flat_centered.json.jbuilder
|
81
83
|
- app/views/json_ui/garage/pages/full_width.json.jbuilder
|
82
84
|
- app/views/json_ui/garage/pages/full_width_height.json.jbuilder
|
@@ -105,6 +107,7 @@ files:
|
|
105
107
|
- app/views/json_ui/garage/views/index.json.jbuilder
|
106
108
|
- app/views/json_ui/garage/views/links.json.jbuilder
|
107
109
|
- app/views/json_ui/garage/views/map_data.json.jbuilder
|
110
|
+
- app/views/json_ui/garage/views/markdowns.json.jbuilder
|
108
111
|
- app/views/json_ui/garage/views/misc.json.jbuilder
|
109
112
|
- app/views/json_ui/garage/views/texts.json.jbuilder
|
110
113
|
- config/routes.rb
|
@@ -113,6 +116,7 @@ files:
|
|
113
116
|
- lib/glib/json_crawler.rb
|
114
117
|
- lib/glib/json_crawler/action_crawler.rb
|
115
118
|
- lib/glib/json_crawler/action_crawlers/action_http.rb
|
119
|
+
- lib/glib/json_crawler/action_crawlers/forms_submit.rb
|
116
120
|
- lib/glib/json_crawler/action_crawlers/nav_initiate.rb
|
117
121
|
- lib/glib/json_crawler/action_crawlers/windows_open.rb
|
118
122
|
- lib/glib/json_crawler/http.rb
|