glib-web 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +5 -5
  2. data/app/controllers/concerns/.keep +0 -0
  3. data/app/controllers/concerns/application/json/libs.rb +26 -0
  4. data/app/controllers/concerns/application/json/transformation.rb +11 -0
  5. data/app/controllers/concerns/application/json/ui.rb +61 -0
  6. data/app/controllers/concerns/application/json/validation.rb +13 -0
  7. data/app/controllers/home_controller.rb +20 -0
  8. data/app/helpers/glib/web/json_ui_helper.rb +58 -0
  9. data/app/views/_nav_menu.json.jbuilder +84 -0
  10. data/app/views/actions/index.json.jbuilder +25 -0
  11. data/app/views/app/views/json_ui/vue/renderer.html.slim +24 -0
  12. data/app/views/forms/basic.json.jbuilder +53 -0
  13. data/app/views/forms/basic_post.json.jbuilder +10 -0
  14. data/app/views/forms/file_upload.json.jbuilder +38 -0
  15. data/app/views/forms/floating_submit.json.jbuilder +48 -0
  16. data/app/views/forms/generic_post.json.jbuilder +6 -0
  17. data/app/views/forms/index.json.jbuilder +43 -0
  18. data/app/views/forms/submit_indicator.json.jbuilder +32 -0
  19. data/app/views/forms/submit_indicator_post.json.jbuilder +12 -0
  20. data/app/views/home/index.json.jbuilder +61 -0
  21. data/app/views/lists/_infinite_scroll_section.json.jbuilder +10 -0
  22. data/app/views/lists/index.json.jbuilder +25 -0
  23. data/app/views/lists/infinite_scroll.json.jbuilder +27 -0
  24. data/app/views/lists/templating.json.jbuilder +45 -0
  25. data/app/views/pages/full_width_height.json.jbuilder +39 -0
  26. data/app/views/pages/index.json.jbuilder +35 -0
  27. data/app/views/pages/layout.json.jbuilder +35 -0
  28. data/app/views/pages/nav_buttons.json.jbuilder +32 -0
  29. data/app/views/panels/horizontal.json.jbuilder +213 -0
  30. data/app/views/panels/index.json.jbuilder +34 -0
  31. data/app/views/panels/split.json.jbuilder +360 -0
  32. data/app/views/panels/vertical.json.jbuilder +94 -0
  33. data/app/views/views/basic.json.jbuilder +21 -0
  34. data/app/views/views/carousels.json.jbuilder +100 -0
  35. data/app/views/views/images.json.jbuilder +56 -0
  36. data/app/views/views/index.json.jbuilder +34 -0
  37. data/config/routes.rb +4 -0
  38. data/lib/glib-web.rb +2 -0
  39. data/lib/glib/engine.rb +7 -0
  40. data/lib/glib/version.rb +5 -0
  41. metadata +57 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 5f1ac6240d706daaa3e4855af5b67b1e077b1d9d
4
- data.tar.gz: e70d4713ddcb3ea3498046beb834da9c93f889bd
2
+ SHA256:
3
+ metadata.gz: 3252e95797df15a1e72061db9583704fbf49d55b62ba5389e4e275d8b9c949c7
4
+ data.tar.gz: 325e4ccb344878566840aaf9dd8051ff32b8382dc5c7fefef2a2d00f6f7b327a
5
5
  SHA512:
6
- metadata.gz: 2023ebcdce0666fec8f1bf02491691540373074a31de0deb1569239c4e85b67d0d142a4ef93832a80bab25a3aac41f25911f91723f172b196bcd91601979da8e
7
- data.tar.gz: 03fd0cfb0f069735878a8f17e92139b771cfe4c0102beaa028c0e54c44d461853287719fc7edaaca8565471f9c7deb9fb240df60c3ad42e6e3df6121d09b1ca2
6
+ metadata.gz: 0a608d6aa4fbf6d36f3ec05123b2a908fa982fc2370c4e9cc8bc214e7dfeb7a3e491af31a7ea507316fd8cdf37328532797a46450de7609877eb014027155a13
7
+ data.tar.gz: 60581c14e70e9a53ab273593cba687969f8cec04b81f9867cabbc7e806f64f431f047d536df6c4f6338bef3d99ae70eee1ef8b80e4976eaab6ab1d81280f4466
File without changes
@@ -0,0 +1,26 @@
1
+ module Concerns::Application::Json::Libs
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ extend ClassMethods
6
+ end
7
+
8
+ module ClassMethods
9
+
10
+ def json_libs_init(options)
11
+ include Concerns::Application::Json::Transformation
12
+ include Concerns::Application::Json::Validation
13
+ include Concerns::Application::Json::Ui
14
+
15
+ before_action :__json_ui_start
16
+
17
+ # Note that after_action gets executed in reverse
18
+ after_action do
19
+ __json_ui_commit(options[:renderer_path])
20
+ end
21
+ after_action :__json_transformation_commit
22
+ after_action :__json_validate_perform
23
+ end
24
+
25
+ end
26
+ end
@@ -0,0 +1,11 @@
1
+ module Concerns::Application::Json::Transformation
2
+ def json_transformation_start
3
+ if request.format == 'json'
4
+ @__transformed_json ||= JSON.parse(response.body) rescue nil
5
+ end
6
+ end
7
+
8
+ def __json_transformation_commit
9
+ response.body = @__transformed_json.to_json if @__transformed_json
10
+ end
11
+ end
@@ -0,0 +1,61 @@
1
+ module Concerns::Application::Json::Ui
2
+ extend ActiveSupport::Concern
3
+
4
+ # NOTE: Override default_url_options and call this method
5
+ def json_ui_url_options
6
+ options = {}
7
+ options[:_render] = params[:_render]
8
+ options[:format] = :json if request.format == :json
9
+ options
10
+ end
11
+
12
+ def json_ui_activated
13
+ @__json_ui_activated
14
+ end
15
+
16
+ def __json_ui_start
17
+ @__json_ui_activated = false
18
+ @__json_ui_rendering = false
19
+ if params[:_render].present?
20
+ @__json_ui_activated = true
21
+ request.variant = :ui
22
+
23
+ if request.format.html?
24
+ @__json_ui_rendering = true
25
+ request.format = 'json'
26
+ end
27
+ end
28
+ end
29
+
30
+ def __json_ui_commit(renderer_path)
31
+ if @__json_ui_rendering
32
+ if (hash = json_transformation_start).is_a?(Hash)
33
+ case params[:_render]
34
+ when 'v1'
35
+ __json_ui_vue(hash, renderer_path)
36
+ when 'mdc'
37
+ __json_ui_mdc(hash)
38
+ when 'vue'
39
+ __json_ui_vue(hash)
40
+ end
41
+ end
42
+ end
43
+ end
44
+
45
+ private
46
+
47
+ # TODO: Remove. Deprecated
48
+ def __json_ui_mdc(hash)
49
+ prepend_view_path 'app/views/json_ui/mdc'
50
+ if (next_action = hash['onResponse']).is_a?(Hash)
51
+ response.body = render_to_string(file: 'renderer.js', layout: false, content_type: 'text/javascript', locals: { response: next_action })
52
+ else
53
+ response.body = render_to_string(file: 'renderer.html', layout: false, content_type: 'text/html', locals: { page: hash })
54
+ end
55
+ end
56
+
57
+ def __json_ui_vue(hash, renderer_path)
58
+ @__json_ui_orig_page = response.body
59
+ response.body = render_to_string(file: renderer_path, layout: false, content_type: 'text/html', locals: { page: hash })
60
+ end
61
+ end
@@ -0,0 +1,13 @@
1
+ module Concerns::Application::Json::Validation
2
+ def __json_validate_perform
3
+ if Rails.env.development? && params[:_validate] == 'true'
4
+ if (hash = json_transformation_start).is_a?(Hash)
5
+ json_validate = JSONValidate.new(hash)
6
+ response_message = json_validate.valid?
7
+ hash[:_json] = {
8
+ validationErrors: response_message
9
+ }
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,20 @@
1
+ class HomeController < ApplicationController
2
+
3
+ def json_ui_garage
4
+ @sample_image_url = 'https://cdn-images-1.medium.com/max/1200/1*Qc0XxYm-qAZL-7tjjlNfrg.png'
5
+
6
+ # prepend_view_path 'app/views/json_ui/garage'
7
+ path = "#{params[:path] || 'index'}"
8
+ render path
9
+ end
10
+
11
+ def json_ui_garage_url(options = {})
12
+ Glib::Web::Engine.routes.url_helpers.json_ui_garage_url(options.merge(
13
+ host: request.host,
14
+ port: request.port,
15
+ _render: params[:_render], format: params[:format])
16
+ )
17
+ end
18
+
19
+ helper_method :json_ui_garage_url
20
+ end
@@ -0,0 +1,58 @@
1
+ module Glib
2
+ module Web
3
+ module JsonUiHelper
4
+ def json_body_with_list(json, header = nil, footer = nil, options = {})
5
+ json.header header
6
+ json.content do
7
+ json.subviews [1] do
8
+ json.view 'panels/list-v1'
9
+ json.width 'matchParent'
10
+ json.nextPage options[:nextPage]
11
+ json.sections [1] do
12
+ yield
13
+ end
14
+ end
15
+ end
16
+ json.footer footer
17
+ end
18
+
19
+ def json_body_with_scroll(json, header = nil, footer = nil, options = {})
20
+ json.header header
21
+ json.content do
22
+ json.subviews [1] do
23
+ json.view 'panels/scroll-v1'
24
+ json.width 'matchParent'
25
+ json.padding options[:padding]
26
+ json.subviews do
27
+ yield
28
+ end
29
+ end
30
+ end
31
+ json.footer footer
32
+ end
33
+
34
+ def json_body_with_form(json, header = nil, footer = nil, options = {})
35
+ json.header header
36
+ json_body_with_scroll json do
37
+ json.child! do
38
+ json.view 'panels/form-v1'
39
+ json.width 'matchParent'
40
+ json.(options, :url, :method)
41
+ json.padding options[:padding]
42
+ json.local options[:local]
43
+ json.subviews do
44
+ json.child! do
45
+ json.view 'fields/hidden-v1'
46
+ json.name 'authenticity_token'
47
+ json.value form_authenticity_token
48
+ end
49
+
50
+ yield
51
+ end
52
+ end
53
+ end
54
+ json.footer footer
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,84 @@
1
+ json.leftDrawer do
2
+ json.items do
3
+ json.child! do
4
+ json.icon do
5
+ json.materialName 'home'
6
+ end
7
+ json.text 'Home'
8
+ json.onClick do
9
+ json.action 'windows/open-v1'
10
+ json.url json_ui_garage_url
11
+ end
12
+ end
13
+ end
14
+
15
+ json.items do
16
+ json.child! do
17
+ json.text 'Pages'
18
+ json.onClick do
19
+ json.action 'windows/open-v1'
20
+ json.url json_ui_garage_url(path: 'pages/index')
21
+ end
22
+ end
23
+ end
24
+
25
+ json.items do
26
+ json.child! do
27
+ json.text 'Lists'
28
+ json.onClick do
29
+ json.action 'windows/open-v1'
30
+ json.url json_ui_garage_url(path: 'lists/index')
31
+ end
32
+ end
33
+ end
34
+
35
+ json.items do
36
+ json.child! do
37
+ json.text 'Forms'
38
+ json.onClick do
39
+ json.action 'windows/open-v1'
40
+ json.url json_ui_garage_url(path: 'forms/index')
41
+ end
42
+ end
43
+ end
44
+
45
+ json.items do
46
+ json.child! do
47
+ json.text 'Panels'
48
+ json.onClick do
49
+ json.action 'windows/open-v1'
50
+ json.url json_ui_garage_url(path: 'panels/index')
51
+ end
52
+ end
53
+ end
54
+
55
+ json.items do
56
+ json.child! do
57
+ json.text 'Views'
58
+ json.onClick do
59
+ json.action 'windows/open-v1'
60
+ json.url json_ui_garage_url(path: 'views/index')
61
+ end
62
+ end
63
+ end
64
+
65
+ json.items do
66
+ json.child! do
67
+ json.text 'Actions'
68
+ json.onClick do
69
+ json.action 'windows/open-v1'
70
+ json.url json_ui_garage_url(path: 'actions/index')
71
+ end
72
+ end
73
+ end
74
+
75
+ json.items do
76
+ json.child! do
77
+ json.text 'Diagnostics'
78
+ json.onClick do
79
+ json.action 'dialogs/alert-v1'
80
+ json.message 'JSON UI v1.0'
81
+ end
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,25 @@
1
+ json.title 'Components'
2
+
3
+ render './nav_menu', json: json
4
+
5
+ json_body_with_list json do
6
+ json.rows do
7
+ json.child! do
8
+ json.template 'default-v1'
9
+ json.title 'Alert'
10
+ json.onClick do
11
+ json.action 'dialogs/alert-v1'
12
+ json.message 'This is an alert'
13
+ end
14
+ end
15
+
16
+ # json.child! do
17
+ # json.template 'default-v1'
18
+ # json.title 'Remote Content'
19
+ # json.onClick do
20
+ # json.action 'dialogs/open-v1'
21
+ # json.url ''
22
+ # end
23
+ # end
24
+ end
25
+ end
@@ -0,0 +1,24 @@
1
+ doctype html
2
+ html
3
+ head
4
+ meta charset="utf-8"
5
+ meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"
6
+ title App
7
+ = csrf_meta_tags
8
+
9
+ = javascript_pack_tag 'vue_renderer', defer: true
10
+ /= javascript_include_tag 'vue_renderer_extras', defer: true
11
+
12
+ = stylesheet_pack_tag 'vue_renderer'
13
+ /= stylesheet_link_tag 'vue_renderer_extras', media: 'all'
14
+
15
+ link href="https://fonts.googleapis.com/css?family=Material+Icons" rel="stylesheet"
16
+
17
+ body
18
+ noscript
19
+ Please enable JavaScript to view this web site.
20
+
21
+ #app
22
+
23
+ javascript:
24
+ var __page = #{raw @__json_ui_orig_page};
@@ -0,0 +1,53 @@
1
+ json.title 'Forms'
2
+
3
+ render './nav_menu', json: json
4
+
5
+ options = {
6
+ url: json_ui_garage_url(path: 'forms/basic_post'),
7
+ method: 'post',
8
+ padding: { top: 12, left: 20, right: 20, bottom: 12 }
9
+ }
10
+ json_body_with_form json, nil, nil, options do
11
+ json.child! do
12
+ json.view 'fields/text-v1'
13
+ json.name 'user[name]'
14
+ json.width 'matchParent'
15
+ json.label 'Name'
16
+ end
17
+
18
+ json.child! do
19
+ json.view 'fields/email-v1'
20
+ json.name 'user[email]'
21
+ json.width 'matchParent'
22
+ json.label 'Email'
23
+ end
24
+
25
+ json.child! do
26
+ json.view 'fields/password-v1'
27
+ json.name 'user[password]'
28
+ json.width 'matchParent'
29
+ json.label 'Password'
30
+ end
31
+
32
+ json.child! do
33
+ json.view 'panels/split-v1'
34
+ json.width 'matchParent'
35
+
36
+ json.content do
37
+ json.right do
38
+ json.view 'button-v1'
39
+ json.text 'Submit'
40
+ json.onClick do
41
+ json.action 'forms/submit-v1'
42
+
43
+ # json.action 'forms/encode-v1'
44
+ # json.paramName 'formData'
45
+ # json.onEncoded do
46
+ # json.action 'http/post-v1'
47
+ # json.url json_ui_garage_url(path: 'forms/basic_post')
48
+ # end
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,10 @@
1
+ name, email, password = params.require(:user).values_at(:name, :email, :password)
2
+ json.onResponse do
3
+ if name.present? && email.present? && password.present?
4
+ json.action 'dialogs/alert-v1'
5
+ json.message "Submitted information: #{name}, #{email}, #{password}"
6
+ else
7
+ json.action 'dialogs/alert-v1'
8
+ json.message 'Please enter all required information'
9
+ end
10
+ end
@@ -0,0 +1,38 @@
1
+ json.title 'Forms'
2
+
3
+ render './nav_menu', json: json
4
+
5
+ options = {
6
+ url: json_ui_garage_url(path: 'forms/generic_post'),
7
+ method: 'post',
8
+ padding: { top: 12, left: 20, right: 20, bottom: 12 }
9
+ }
10
+ json_body_with_form json, nil, nil, options do
11
+ json.child! do
12
+ json.view 'fields/file-v1'
13
+ json.name 'user[photo]'
14
+ json.width 'matchParent'
15
+ json.label 'Photo'
16
+
17
+ json.value 'VALUE_OF_THE_PREVIOUS_IMAGE_WHICH_IS_USEFUL_WHEN_UPDATING_EXISTING_MODEL'
18
+
19
+ json.accepts "image/*"
20
+ # json.s3_bucket 'BUCKET_NAME'
21
+ # json.s3_path_prefix 'uploads/images'
22
+ json.s3_direct_upload_url rails_direct_uploads_path
23
+
24
+ # This is for security so we don't have to reveal key/secret in the json api
25
+ # json.s3_signature_url 'URL_TO_OUR_SERVER_TO_GET_GENERATED_SIGNATURE'
26
+
27
+ json.file_size_limit 5000 # 5 MB
28
+ json.file_size_limit_alert_text 'Too big!'
29
+ end
30
+
31
+ json.child! do
32
+ json.view 'button-v1'
33
+ json.text 'Submit'
34
+ json.onClick do
35
+ json.action 'forms/submit-v1'
36
+ end
37
+ end
38
+ end