glib-web 0.4.4 → 0.4.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. checksums.yaml +5 -5
  2. data/app/controllers/concerns/application/json/libs.rb +94 -94
  3. data/app/controllers/concerns/application/json/transformation.rb +10 -10
  4. data/app/controllers/concerns/application/json/ui.rb +57 -57
  5. data/app/controllers/concerns/application/json/validation.rb +13 -13
  6. data/app/controllers/concerns/glib/auth/policy.rb +1 -1
  7. data/app/controllers/concerns/glib/json/ui.rb +1 -1
  8. data/app/controllers/glib/home_controller.rb +0 -11
  9. data/app/helpers/glib/dynamic_texts_helper.rb +0 -0
  10. data/app/helpers/glib/json_ui/abstract_builder.rb +0 -0
  11. data/app/helpers/glib/json_ui/action_builder.rb +0 -0
  12. data/app/helpers/glib/json_ui/list_builders.rb +0 -0
  13. data/app/helpers/glib/json_ui/menu_builder.rb +0 -0
  14. data/app/helpers/glib/json_ui/page_helper.rb +1 -1
  15. data/app/helpers/glib/json_ui/response_helper.rb +0 -0
  16. data/app/helpers/glib/json_ui/split_builders.rb +0 -0
  17. data/app/helpers/glib/json_ui/styling_helper.rb +0 -0
  18. data/app/helpers/glib/json_ui/table_builders.rb +0 -0
  19. data/app/helpers/glib/json_ui/view_builder/banners.rb +0 -0
  20. data/app/helpers/glib/json_ui/view_builder/fields.rb +0 -0
  21. data/app/helpers/glib/json_ui/view_builder/panels.rb +0 -0
  22. data/app/helpers/glib/json_ui/view_builder.rb +4 -4
  23. data/app/models/glib/dynamic_text_record.rb +0 -0
  24. data/app/models/glib/text.rb +0 -0
  25. data/app/policies/glib/application_policy.rb +148 -148
  26. data/app/views/app/views/json_ui/vue/renderer.html.erb +0 -0
  27. data/app/views/json_ui/garage/_nav_menu.json.jbuilder +0 -0
  28. data/app/views/json_ui/garage/actions/index.json.jbuilder +5 -5
  29. data/app/views/json_ui/garage/forms/_alert_post_data.json.jbuilder +0 -0
  30. data/app/views/json_ui/garage/forms/basic.json.jbuilder +0 -0
  31. data/app/views/json_ui/garage/forms/basic_post.json.jbuilder +0 -0
  32. data/app/views/json_ui/garage/forms/checkboxes.json.jbuilder +0 -0
  33. data/app/views/json_ui/garage/forms/dynamic_select.json.jbuilder +0 -0
  34. data/app/views/json_ui/garage/forms/dynamic_select_data.json.jbuilder +0 -0
  35. data/app/views/json_ui/garage/forms/file_upload.json.jbuilder +0 -0
  36. data/app/views/json_ui/garage/forms/floating_submit.json.jbuilder +0 -0
  37. data/app/views/json_ui/garage/forms/generic_post.json.jbuilder +0 -0
  38. data/app/views/json_ui/garage/forms/get_request.json.jbuilder +0 -0
  39. data/app/views/json_ui/garage/forms/index.json.jbuilder +0 -0
  40. data/app/views/json_ui/garage/forms/pickers.json.jbuilder +0 -0
  41. data/app/views/json_ui/garage/forms/rich_text.json.jbuilder +0 -0
  42. data/app/views/json_ui/garage/forms/selects.json.jbuilder +0 -0
  43. data/app/views/json_ui/garage/forms/submission_flow.json.jbuilder +0 -0
  44. data/app/views/json_ui/garage/forms/submission_flow_post.json.jbuilder +0 -0
  45. data/app/views/json_ui/garage/forms/submission_indicator.json.jbuilder +0 -0
  46. data/app/views/json_ui/garage/forms/submission_indicator_post.json.jbuilder +0 -0
  47. data/app/views/json_ui/garage/forms/text_validation.json.jbuilder +0 -0
  48. data/app/views/json_ui/garage/home/blank.json.jbuilder +0 -0
  49. data/app/views/json_ui/garage/home/index.json.jbuilder +0 -0
  50. data/app/views/json_ui/garage/lists/_infinite_scroll_section.json.jbuilder +0 -0
  51. data/app/views/json_ui/garage/lists/edit_actions.json.jbuilder +0 -0
  52. data/app/views/json_ui/garage/lists/fab.json.jbuilder +0 -0
  53. data/app/views/json_ui/garage/lists/index.json.jbuilder +0 -0
  54. data/app/views/json_ui/garage/lists/infinite_scroll.json.jbuilder +0 -0
  55. data/app/views/json_ui/garage/lists/templating.json.jbuilder +0 -0
  56. data/app/views/json_ui/garage/pages/flat_centered.json.jbuilder +0 -0
  57. data/app/views/json_ui/garage/pages/full_width.json.jbuilder +0 -0
  58. data/app/views/json_ui/garage/pages/full_width_height.json.jbuilder +0 -0
  59. data/app/views/json_ui/garage/pages/index.json.jbuilder +0 -0
  60. data/app/views/json_ui/garage/pages/layout.json.jbuilder +0 -0
  61. data/app/views/json_ui/garage/pages/nav_buttons.json.jbuilder +0 -0
  62. data/app/views/json_ui/garage/pages/tab_bar.json.jbuilder +0 -0
  63. data/app/views/json_ui/garage/panels/card.json.jbuilder +0 -0
  64. data/app/views/json_ui/garage/panels/carousel.json.jbuilder +0 -0
  65. data/app/views/json_ui/garage/panels/custom.json.jbuilder +0 -0
  66. data/app/views/json_ui/garage/panels/horizontal.json.jbuilder +0 -0
  67. data/app/views/json_ui/garage/panels/index.json.jbuilder +0 -0
  68. data/app/views/json_ui/garage/panels/responsive.json.jbuilder +0 -0
  69. data/app/views/json_ui/garage/panels/split.json.jbuilder +0 -0
  70. data/app/views/json_ui/garage/panels/vertical.json.jbuilder +0 -0
  71. data/app/views/json_ui/garage/tables/_autoload_section.json.jbuilder +0 -0
  72. data/app/views/json_ui/garage/tables/autoload_all.json.jbuilder +0 -0
  73. data/app/views/json_ui/garage/tables/export_import.json.jbuilder +0 -0
  74. data/app/views/json_ui/garage/tables/horizontal_scroll.json.jbuilder +0 -0
  75. data/app/views/json_ui/garage/tables/index.json.jbuilder +0 -0
  76. data/app/views/json_ui/garage/views/banners.json.jbuilder +0 -0
  77. data/app/views/json_ui/garage/views/calendar_data.json.jbuilder +0 -0
  78. data/app/views/json_ui/garage/views/carousels.json.jbuilder +0 -0
  79. data/app/views/json_ui/garage/views/charts.json.jbuilder +0 -0
  80. data/app/views/json_ui/garage/views/images.json.jbuilder +0 -0
  81. data/app/views/json_ui/garage/views/index.json.jbuilder +0 -0
  82. data/app/views/json_ui/garage/views/links.json.jbuilder +0 -0
  83. data/app/views/json_ui/garage/views/map_data.json.jbuilder +0 -0
  84. data/app/views/json_ui/garage/views/misc.json.jbuilder +0 -0
  85. data/app/views/json_ui/garage/views/texts.json.jbuilder +0 -0
  86. data/config/routes.rb +0 -0
  87. data/lib/generators/glib/install_generator.rb +0 -0
  88. data/lib/generators/templates/20191017062519_create_texts.rb +0 -0
  89. data/lib/generators/templates/20191024063257_add_scope_to_texts.rb +0 -0
  90. data/lib/generators/templates/20191112095018_add_lang_to_texts.rb +0 -0
  91. data/lib/generators/templates/20191126071051_create_active_storage_tables.active_storage.rb +0 -0
  92. data/lib/generators/templates/database.yml +0 -0
  93. data/lib/generators/templates/dynamic_text.rb +0 -0
  94. data/lib/glib/engine.rb +0 -0
  95. data/lib/glib/json_crawler/action_crawler.rb +0 -0
  96. data/lib/glib/json_crawler/action_crawlers/action_http.rb +0 -0
  97. data/lib/glib/json_crawler/action_crawlers/forms_submit.rb +0 -0
  98. data/lib/glib/json_crawler/action_crawlers/nav_initiate.rb +0 -0
  99. data/lib/glib/json_crawler/action_crawlers/windows_open.rb +0 -0
  100. data/lib/glib/json_crawler/http.rb +0 -0
  101. data/lib/glib/json_crawler/router.rb +0 -0
  102. data/lib/glib/json_crawler.rb +0 -0
  103. data/lib/glib/value.rb +0 -0
  104. data/lib/glib/version.rb +0 -0
  105. data/lib/glib-web.rb +0 -0
  106. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 36ac8042a2934608affdfa3ac546ca2efd6caff2f03eb2a1a02d7c9e3c145443
4
- data.tar.gz: dbeaafdbf9ae36aeb6419cdba60c7676489eef6830076d8a9c84cdb26c98ef12
2
+ SHA1:
3
+ metadata.gz: 919e24aa78e80169bcf2f2b032b8145c01bd385c
4
+ data.tar.gz: 4230c28a6afcf2d6e4f72e38b5fbc6c8ac0cad13
5
5
  SHA512:
6
- metadata.gz: 3b528ad5eeb7613ae09e83f31e74951b7b40e64424e5086d75022039f66dc0a44624e4dc9818eddd7a205afe97d74ba298a4072ae0a568ea5b29f8ae28245c0f
7
- data.tar.gz: eda842d4c68a7c74b9d3d59c663c4725eae8c7342b5dc9f7bdacbb9769b26850ce7a6f8739316047265c031d8936ce2edc98887619e2c9c9475ab42876b90edb
6
+ metadata.gz: d24491fd6b6c200bce6d845a6af29c0ca4a43175dc120ca6ac35df385a5f0c9a64698d72d95c7ce760be3a0ee731887442973f7784245dda957ccc5b977d6757
7
+ data.tar.gz: 223bbe0bc42013949637b2cd0afe679bf1f80582310eb9f1a0850b13603dff401b451a165d195c8ffd92258da983946bf5715e36944c1f7187a4eb6d471cf93f
@@ -1,94 +1,94 @@
1
- # TODO: Deprecate
2
- module Application::Json::Libs
3
- extend ActiveSupport::Concern
4
-
5
- included do
6
- extend ClassMethods
7
-
8
- helper_method :json_ui_app_bundle_id, :json_ui_app_build_version, :json_ui_app_device_os
9
- helper_method :json_ui_app_is_android?, :json_ui_app_is_ios?, :json_ui_app_is_web?
10
- end
11
-
12
- def json_ui_app_bundle_id
13
- @json_ui_app_bundle_id ||= request.headers['JsonUiApp-Bundle-Id']
14
- end
15
-
16
- def json_ui_app_build_version
17
- @json_ui_app_build_version ||= request.headers['JsonUiApp-Build-Version']
18
- @json_ui_app_build_version = params[:build_version] if @json_ui_app_build_version.nil? && Rails.env.development? # For easy testing
19
- @json_ui_app_build_version
20
- end
21
-
22
- def json_ui_app_device_os
23
- @json_ui_app_device_os ||= request.headers['JsonUiApp-Device-Os']
24
- @json_ui_app_device_os = params[:device_os] if @json_ui_app_device_os.nil? && Rails.env.development? # For easy testing
25
- @json_ui_app_device_os || 'web'
26
- end
27
-
28
- def json_ui_app_is_android?
29
- json_ui_app_device_os == 'android'
30
- end
31
-
32
- def json_ui_app_is_ios?
33
- json_ui_app_device_os == 'ios'
34
- end
35
-
36
- def json_ui_app_is_web?
37
- json_ui_app_device_os == 'web'
38
- end
39
-
40
-
41
-
42
- module ClassMethods
43
-
44
- def json_libs_init(options)
45
- include Application::Json::Transformation
46
- include Application::Json::Validation
47
- include Application::Json::Ui
48
-
49
- before_action :__json_ui_start
50
-
51
- # Note that after_action gets executed in reverse
52
- after_action do
53
- __json_ui_commit(options)
54
- end
55
- after_action :__json_transformation_commit
56
- after_action :__json_validate_perform
57
- end
58
-
59
- def json_libs_set_locale
60
- before_action do
61
- # Need to explicitly fallback to EN
62
- I18n.locale = params[:_locale] || :en
63
- rescue
64
- I18n.locale = :en
65
- end
66
- end
67
-
68
- def json_libs_force_json_ui
69
- before_action do
70
- if params[:_render] != 'v1'
71
- redirect_to url_for(params.to_unsafe_h.merge(_render: 'v1'))
72
- end
73
- end
74
- end
75
-
76
- def json_libs_rescue_csrf
77
- rescue_from ActionController::InvalidAuthenticityToken do |exception|
78
- sign_out(:user)
79
-
80
- respond_to do |format|
81
- format.json do
82
- render json: {
83
- onResponse: {
84
- action: 'windows/open-v1',
85
- url: root_url
86
- }
87
- }
88
- end
89
- end
90
- end
91
- end
92
-
93
- end
94
- end
1
+ # # TODO: Deprecate
2
+ # module Application::Json::Libs
3
+ # extend ActiveSupport::Concern
4
+
5
+ # included do
6
+ # extend ClassMethods
7
+
8
+ # helper_method :json_ui_app_bundle_id, :json_ui_app_build_version, :json_ui_app_device_os
9
+ # helper_method :json_ui_app_is_android?, :json_ui_app_is_ios?, :json_ui_app_is_web?
10
+ # end
11
+
12
+ # def json_ui_app_bundle_id
13
+ # @json_ui_app_bundle_id ||= request.headers['JsonUiApp-Bundle-Id']
14
+ # end
15
+
16
+ # def json_ui_app_build_version
17
+ # @json_ui_app_build_version ||= request.headers['JsonUiApp-Build-Version']
18
+ # @json_ui_app_build_version = params[:build_version] if @json_ui_app_build_version.nil? && Rails.env.development? # For easy testing
19
+ # @json_ui_app_build_version
20
+ # end
21
+
22
+ # def json_ui_app_device_os
23
+ # @json_ui_app_device_os ||= request.headers['JsonUiApp-Device-Os']
24
+ # @json_ui_app_device_os = params[:device_os] if @json_ui_app_device_os.nil? && Rails.env.development? # For easy testing
25
+ # @json_ui_app_device_os || 'web'
26
+ # end
27
+
28
+ # def json_ui_app_is_android?
29
+ # json_ui_app_device_os == 'android'
30
+ # end
31
+
32
+ # def json_ui_app_is_ios?
33
+ # json_ui_app_device_os == 'ios'
34
+ # end
35
+
36
+ # def json_ui_app_is_web?
37
+ # json_ui_app_device_os == 'web'
38
+ # end
39
+
40
+
41
+
42
+ # module ClassMethods
43
+
44
+ # def json_libs_init(options)
45
+ # include Application::Json::Transformation
46
+ # include Application::Json::Validation
47
+ # include Application::Json::Ui
48
+
49
+ # before_action :__json_ui_start
50
+
51
+ # # Note that after_action gets executed in reverse
52
+ # after_action do
53
+ # __json_ui_commit(options)
54
+ # end
55
+ # after_action :__json_transformation_commit
56
+ # after_action :__json_validate_perform
57
+ # end
58
+
59
+ # def json_libs_set_locale
60
+ # before_action do
61
+ # # Need to explicitly fallback to EN
62
+ # I18n.locale = params[:_locale] || :en
63
+ # rescue
64
+ # I18n.locale = :en
65
+ # end
66
+ # end
67
+
68
+ # def json_libs_force_json_ui
69
+ # before_action do
70
+ # if params[:_render] != 'v1'
71
+ # redirect_to url_for(params.to_unsafe_h.merge(_render: 'v1'))
72
+ # end
73
+ # end
74
+ # end
75
+
76
+ # def json_libs_rescue_csrf
77
+ # rescue_from ActionController::InvalidAuthenticityToken do |exception|
78
+ # sign_out(:user)
79
+
80
+ # respond_to do |format|
81
+ # format.json do
82
+ # render json: {
83
+ # onResponse: {
84
+ # action: 'windows/open-v1',
85
+ # url: root_url
86
+ # }
87
+ # }
88
+ # end
89
+ # end
90
+ # end
91
+ # end
92
+
93
+ # end
94
+ # end
@@ -1,11 +1,11 @@
1
- module 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
1
+ # module 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
7
 
8
- def __json_transformation_commit
9
- response.body = @__transformed_json.to_json if @__transformed_json
10
- end
11
- end
8
+ # def __json_transformation_commit
9
+ # response.body = @__transformed_json.to_json if @__transformed_json
10
+ # end
11
+ # end
@@ -1,66 +1,66 @@
1
- module Application::Json::Ui
2
- extend ActiveSupport::Concern
1
+ # module Application::Json::Ui
2
+ # extend ActiveSupport::Concern
3
3
 
4
- included do
5
- rescue_from ActionController::UnknownFormat do |exception|
6
- if json_ui_activated?
7
- # Tell `__json_ui_start()` to avoid rendering this page while still retaining the `_render` param
8
- # so that the page remains linking to other json_ui pages.
9
- redirect_to url_for(format: nil, _skip_render: true)
10
- else
11
- raise exception
12
- end
13
- end
14
- end
4
+ # included do
5
+ # rescue_from ActionController::UnknownFormat do |exception|
6
+ # if json_ui_activated?
7
+ # # Tell `__json_ui_start()` to avoid rendering this page while still retaining the `_render` param
8
+ # # so that the page remains linking to other json_ui pages.
9
+ # redirect_to url_for(format: nil, _skip_render: true)
10
+ # else
11
+ # raise exception
12
+ # end
13
+ # end
14
+ # end
15
15
 
16
- # Override
17
- def form_authenticity_token(*args)
18
- Rails.env.test? ? 'test_token' : super
19
- end
16
+ # # Override
17
+ # def form_authenticity_token(*args)
18
+ # Rails.env.test? ? 'test_token' : super
19
+ # end
20
20
 
21
- # NOTE: Override default_url_options and call this method
22
- def json_ui_url_options
23
- options = {}
24
- options[:_render] = params[:_render]
25
- options[:_locale] = params[:_locale]
26
- options[:format] = :json if request.format == :json
27
- options
28
- end
21
+ # # NOTE: Override default_url_options and call this method
22
+ # def json_ui_url_options
23
+ # options = {}
24
+ # options[:_render] = params[:_render]
25
+ # options[:_locale] = params[:_locale]
26
+ # options[:format] = :json if request.format == :json
27
+ # options
28
+ # end
29
29
 
30
- def json_ui_activated?
31
- @__json_ui_activated
32
- end
30
+ # def json_ui_activated?
31
+ # @__json_ui_activated
32
+ # end
33
33
 
34
- def __json_ui_start
35
- @__json_ui_activated = false
36
- @__json_ui_rendering = false
37
- if params[:_render].present?
38
- @__json_ui_activated = true
39
- request.variant = :ui
34
+ # def __json_ui_start
35
+ # @__json_ui_activated = false
36
+ # @__json_ui_rendering = false
37
+ # if params[:_render].present?
38
+ # @__json_ui_activated = true
39
+ # request.variant = :ui
40
40
 
41
- if request.format.html? && params[:_skip_render] != 'true'
42
- @__json_ui_rendering = true
43
- request.format = 'json'
44
- end
45
- end
46
- end
41
+ # if request.format.html? && params[:_skip_render] != 'true'
42
+ # @__json_ui_rendering = true
43
+ # request.format = 'json'
44
+ # end
45
+ # end
46
+ # end
47
47
 
48
- def __json_ui_commit(options)
49
- if @__json_ui_rendering
50
- if (hash = json_transformation_start).is_a?(Hash)
51
- case params[:_render]
52
- when 'v1'
53
- __json_ui_vue(hash, options)
54
- end
55
- end
56
- end
57
- end
48
+ # def __json_ui_commit(options)
49
+ # if @__json_ui_rendering
50
+ # if (hash = json_transformation_start).is_a?(Hash)
51
+ # case params[:_render]
52
+ # when 'v1'
53
+ # __json_ui_vue(hash, options)
54
+ # end
55
+ # end
56
+ # end
57
+ # end
58
58
 
59
- private
59
+ # private
60
60
 
61
- def __json_ui_vue(hash, options)
62
- renderer_path = options[:renderer_path]
63
- @__json_ui_orig_page = response.body
64
- response.body = render_to_string(template: renderer_path, layout: false, content_type: 'text/html', locals: { page: hash, options: options })
65
- end
66
- end
61
+ # def __json_ui_vue(hash, options)
62
+ # renderer_path = options[:renderer_path]
63
+ # @__json_ui_orig_page = response.body
64
+ # response.body = render_to_string(template: renderer_path, layout: false, content_type: 'text/html', locals: { page: hash, options: options })
65
+ # end
66
+ # end
@@ -1,13 +1,13 @@
1
- module 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
1
+ # module 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
@@ -12,7 +12,7 @@ module Glib::Auth
12
12
  # TODO: Ultimately we want to uncomment this line, but:
13
13
  # - Need to be able to set aside some time to run rspec tests to ensure nothing gets broken
14
14
  # - Need to find a solution where we can reuse a single public policy
15
- # after_action :verify_authorized
15
+ # after_action :verify_authorized
16
16
 
17
17
  helper_method :policy, :can?, :cannot?
18
18
 
@@ -14,7 +14,7 @@ module Glib::Json::Ui
14
14
  end
15
15
 
16
16
  # Override
17
- def form_authenticity_token
17
+ def form_authenticity_token(*args)
18
18
  Rails.env.test? ? 'test_token' : super
19
19
  end
20
20
 
@@ -8,16 +8,5 @@ module Glib
8
8
  path = "#{@path_prefix}/#{params[:path] || 'home/index'}"
9
9
  render path
10
10
  end
11
-
12
- # def json_ui_garage_url(options = {})
13
- # Glib::Web::Engine.routes.url_helpers.json_ui_garage_url(options.merge(
14
- # protocol: (Rails.application.config.force_ssl ? 'https' : 'http'),
15
- # host: request.host,
16
- # port: request.port,
17
- # _render: params[:_render], format: params[:format])
18
- # )
19
- # end
20
-
21
- # helper_method :json_ui_garage_url
22
11
  end
23
12
  end
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -3,7 +3,7 @@ module Glib
3
3
  module PageHelper
4
4
  def json_ui_garage_url(options = {})
5
5
  return Glib::Web::Engine.routes.url_helpers.json_ui_garage_url(options.merge(
6
- protocol: (Rails.application.config.force_ssl ? 'https' : 'http'),
6
+ protocol: request.protocol,
7
7
  host: request.host,
8
8
  port: request.port,
9
9
  _render: params[:_render], format: params[:format])
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,13 +1,13 @@
1
1
  module Glib
2
2
  module JsonUi
3
3
  class ViewBuilder < AbstractBuilder
4
- def initialize json, page, multiple
4
+ def initialize(json, page, multiple)
5
5
  super(json, page)
6
6
 
7
7
  @multiple = multiple
8
8
  end
9
9
 
10
- def add_view name, *args
10
+ def add_view(name, *args)
11
11
  if @multiple
12
12
  add_element_to_array_v1 'view', name, *args
13
13
  else
@@ -15,7 +15,7 @@ module Glib
15
15
  end
16
16
  end
17
17
 
18
- def method_missing m, *args
18
+ def method_missing(m, *args)
19
19
  add_view m, *args
20
20
  end
21
21
 
@@ -72,7 +72,7 @@ module Glib
72
72
 
73
73
  class H5 < AbstractText
74
74
  end
75
-
75
+
76
76
  class H6 < AbstractText
77
77
  end
78
78
 
File without changes
File without changes
@@ -1,148 +1,148 @@
1
- # The main purpose of this is for security. If it is important to display useful error message or to provide a "banana", then
2
- # it's better to perform an explicit check (e.g. as a validation in the model or using a before_action).
3
- module Glib
4
- class ApplicationPolicy
5
- attr_reader :user, :record, :controller, :request, :params
6
-
7
- private
8
- def initialize(user, record, controller, request, params)
9
- @user = user
10
- @record = record
11
- @controller = controller
12
- @request = request
13
- # Don't get params from request because we might not have a proper request object. This might execute in Sidekiq.
14
- # See Presenter::Model::inside_mock_controller()
15
- @params = params
16
- end
17
-
18
- class << self
19
- attr_reader :catch_all
20
-
21
- # This is to define the authorization logic for an action (or a group of actions). It's different from controller's
22
- # authorize().
23
- private # Used by child
24
- def authorize(*actions, &block)
25
- actions.each do |action|
26
- if action == :manage
27
- # Serve as a catch-all to all actions that have not been specified in the policy.
28
- @catch_all = block
29
- else
30
- method_name = "#{action}?"
31
- # Avoid accidentally redefining multiple times from child policies. But it's okay if the child policy
32
- # wants to override the parent's authorization method.
33
- raise "Action authorization has been declared: #{action}" if instance_methods(false).include?(method_name.to_sym)
34
- define_method method_name, &block
35
- end
36
- end
37
- end
38
- end
39
-
40
- private
41
- def catch_all
42
- self.class.catch_all
43
- end
44
-
45
- private
46
- # To ensure the block is called on the policy's instance instead class.
47
- def call_catch_all
48
- instance_eval(&catch_all)
49
- end
50
-
51
- authorize :index do
52
- # We need this line because in `index` action, this method will be called instead of method_missing().
53
- # Having this line ensures that the catch_all behaviour works according to the priority below:
54
- # - child_policy#index?
55
- # - child_policy#manage? -- catch_all
56
- # - application_policy@index?
57
- return call_catch_all if catch_all
58
-
59
- false
60
- end
61
-
62
- authorize :show do
63
- return call_catch_all if catch_all
64
-
65
- scope.where(id: record.id).exists?
66
- end
67
-
68
- authorize :create do
69
- return call_catch_all if catch_all
70
-
71
- false
72
- end
73
-
74
- authorize :new do
75
- return call_catch_all if catch_all
76
-
77
- create?
78
- end
79
-
80
- authorize :update do
81
- return call_catch_all if catch_all
82
-
83
- false
84
- end
85
-
86
- authorize :edit do
87
- return call_catch_all if catch_all
88
-
89
- update?
90
- end
91
-
92
- authorize :destroy do
93
- return call_catch_all if catch_all
94
-
95
- false
96
- end
97
-
98
- public
99
- def method_missing(name, *args, &block)
100
- if name.to_s.end_with?('?') && catch_all
101
- call_catch_all
102
- else
103
- super
104
- end
105
- end
106
-
107
- public
108
- def scope
109
- Pundit.policy_scope!(user, record.class)
110
- end
111
-
112
- private # Used by child
113
- def public?
114
- true
115
- end
116
-
117
- # # TODO: Revise because it seems there is no justification for allowing owner to see any of the deleted entities, which include User, Guild, and Post
118
- # private # Used by child
119
- # def not_deleted_unless_owner_or_moderator?(&block)
120
- # block ||= lambda { |unused_arg| @user.moderator? }
121
- # !@record.deleted? || (@user && (@user.id == @record.user_owner_id || block.call(@record)))
122
- # end
123
-
124
- # private # Used by child
125
- # def not_deleted_unless_moderator?(&block)
126
- # block ||= lambda { |unused_arg| @user.moderator? }
127
- # !@record.deleted? || (@user && block.call(@record))
128
- # end
129
-
130
- public
131
- def self.args_builder
132
- Proc.new { |controller| [] }
133
- end
134
-
135
- class Scope
136
- attr_reader :user, :scope
137
-
138
- def initialize(user, scope)
139
- @user = user
140
- @scope = scope
141
- end
142
-
143
- def resolve
144
- scope
145
- end
146
- end
147
- end
148
- end
1
+ # The main purpose of this is for security. If it is important to display useful error message or to provide a "banana", then
2
+ # it's better to perform an explicit check (e.g. as a validation in the model or using a before_action).
3
+ module Glib
4
+ class ApplicationPolicy
5
+ attr_reader :user, :record, :controller, :request, :params
6
+
7
+ private
8
+ def initialize(user, record, controller, request, params)
9
+ @user = user
10
+ @record = record
11
+ @controller = controller
12
+ @request = request
13
+ # Don't get params from request because we might not have a proper request object. This might execute in Sidekiq.
14
+ # See Presenter::Model::inside_mock_controller()
15
+ @params = params
16
+ end
17
+
18
+ class << self
19
+ attr_reader :catch_all
20
+
21
+ # This is to define the authorization logic for an action (or a group of actions). It's different from controller's
22
+ # authorize().
23
+ private # Used by child
24
+ def authorize(*actions, &block)
25
+ actions.each do |action|
26
+ if action == :manage
27
+ # Serve as a catch-all to all actions that have not been specified in the policy.
28
+ @catch_all = block
29
+ else
30
+ method_name = "#{action}?"
31
+ # Avoid accidentally redefining multiple times from child policies. But it's okay if the child policy
32
+ # wants to override the parent's authorization method.
33
+ raise "Action authorization has been declared: #{action}" if instance_methods(false).include?(method_name.to_sym)
34
+ define_method method_name, &block
35
+ end
36
+ end
37
+ end
38
+ end
39
+
40
+ private
41
+ def catch_all
42
+ self.class.catch_all
43
+ end
44
+
45
+ private
46
+ # To ensure the block is called on the policy's instance instead class.
47
+ def call_catch_all
48
+ instance_eval(&catch_all)
49
+ end
50
+
51
+ authorize :index do
52
+ # We need this line because in `index` action, this method will be called instead of method_missing().
53
+ # Having this line ensures that the catch_all behaviour works according to the priority below:
54
+ # - child_policy#index?
55
+ # - child_policy#manage? -- catch_all
56
+ # - application_policy@index?
57
+ return call_catch_all if catch_all
58
+
59
+ false
60
+ end
61
+
62
+ authorize :show do
63
+ return call_catch_all if catch_all
64
+
65
+ scope.where(id: record.id).exists?
66
+ end
67
+
68
+ authorize :create do
69
+ return call_catch_all if catch_all
70
+
71
+ false
72
+ end
73
+
74
+ authorize :new do
75
+ return call_catch_all if catch_all
76
+
77
+ create?
78
+ end
79
+
80
+ authorize :update do
81
+ return call_catch_all if catch_all
82
+
83
+ false
84
+ end
85
+
86
+ authorize :edit do
87
+ return call_catch_all if catch_all
88
+
89
+ update?
90
+ end
91
+
92
+ authorize :destroy do
93
+ return call_catch_all if catch_all
94
+
95
+ false
96
+ end
97
+
98
+ public
99
+ def method_missing(name, *args, &block)
100
+ if name.to_s.end_with?('?') && catch_all
101
+ call_catch_all
102
+ else
103
+ super
104
+ end
105
+ end
106
+
107
+ public
108
+ def scope
109
+ Pundit.policy_scope!(user, record.class)
110
+ end
111
+
112
+ private # Used by child
113
+ def public?
114
+ true
115
+ end
116
+
117
+ # # TODO: Revise because it seems there is no justification for allowing owner to see any of the deleted entities, which include User, Guild, and Post
118
+ # private # Used by child
119
+ # def not_deleted_unless_owner_or_moderator?(&block)
120
+ # block ||= lambda { |unused_arg| @user.moderator? }
121
+ # !@record.deleted? || (@user && (@user.id == @record.user_owner_id || block.call(@record)))
122
+ # end
123
+
124
+ # private # Used by child
125
+ # def not_deleted_unless_moderator?(&block)
126
+ # block ||= lambda { |unused_arg| @user.moderator? }
127
+ # !@record.deleted? || (@user && block.call(@record))
128
+ # end
129
+
130
+ public
131
+ def self.args_builder
132
+ Proc.new { |controller| [] }
133
+ end
134
+
135
+ class Scope
136
+ attr_reader :user, :scope
137
+
138
+ def initialize(user, scope)
139
+ @user = user
140
+ @scope = scope
141
+ end
142
+
143
+ def resolve
144
+ scope
145
+ end
146
+ end
147
+ end
148
+ end
File without changes
File without changes
@@ -56,7 +56,7 @@ json_ui_page json do |page|
56
56
  action.dialogs_alert message: 'Closed'
57
57
  end
58
58
  end
59
-
59
+
60
60
  # template.thumbnail title: 'snackbars/confirm (Experimental)', onClick: ->(action) do
61
61
  # action.snackbars_confirm message: 'This is a confirm dialog', onCancel: ->(action) do
62
62
  # action.dialogs_alert message: 'Canceled'
@@ -64,7 +64,7 @@ json_ui_page json do |page|
64
64
  # action.dialogs_alert message: 'Confirmed'
65
65
  # end
66
66
  # end
67
-
67
+
68
68
  template.thumbnail title: 'snackbars/options', onClick: ->(action) do
69
69
  action.snackbars_options message: 'Select one', buttons: ->(menu) do
70
70
  menu.button text: 'Option1', onClick: ->(action) do
@@ -94,7 +94,7 @@ json_ui_page json do |page|
94
94
  end
95
95
  end
96
96
  end
97
-
97
+
98
98
  section.rows builder: ->(template) do
99
99
  template.thumbnail title: 'windows/open', onClick: ->(action) do
100
100
  action.windows_open url: json_ui_garage_url(path: 'home/blank')
@@ -117,7 +117,7 @@ json_ui_page json do |page|
117
117
  template.thumbnail title: "windows/reload (timestamp: #{DateTime.current.to_i})", onClick: ->(action) do
118
118
  action.windows_reload
119
119
  end
120
-
120
+
121
121
  reload_counter = params[:reload_counter].to_i
122
122
  template.thumbnail title: "windows/reload with URL (counter: #{reload_counter})", onClick: ->(action) do
123
123
  action.windows_reload url: json_ui_garage_url(path: 'actions/index', reload_counter: reload_counter + 1)
@@ -126,4 +126,4 @@ json_ui_page json do |page|
126
126
  end
127
127
  end
128
128
  ]
129
- end
129
+ end
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
data/config/routes.rb CHANGED
File without changes
File without changes
File without changes
File without changes
data/lib/glib/engine.rb CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
data/lib/glib/value.rb CHANGED
File without changes
data/lib/glib/version.rb CHANGED
File without changes
data/lib/glib-web.rb CHANGED
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.4.4
4
+ version: 0.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''
@@ -197,7 +197,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
197
197
  version: '0'
198
198
  requirements: []
199
199
  rubyforge_project:
200
- rubygems_version: 2.7.6
200
+ rubygems_version: 2.6.8
201
201
  signing_key:
202
202
  specification_version: 4
203
203
  summary: ''