glib-web 0.4.13 → 0.4.15

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. checksums.yaml +5 -5
  2. data/app/controllers/concerns/application/json/libs.rb +0 -0
  3. data/app/controllers/concerns/application/json/transformation.rb +0 -0
  4. data/app/controllers/concerns/application/json/ui.rb +0 -0
  5. data/app/controllers/concerns/application/json/validation.rb +0 -0
  6. data/app/controllers/concerns/glib/auth/policy.rb +0 -0
  7. data/app/controllers/concerns/glib/json/dynamic_text.rb +13 -1
  8. data/app/controllers/concerns/glib/json/new_dynamic_text.rb +13 -1
  9. data/app/controllers/concerns/glib/json/traversal.rb +0 -0
  10. data/app/controllers/glib/home_controller.rb +0 -0
  11. data/app/helpers/glib/dynamic_texts_helper.rb +0 -0
  12. data/app/helpers/glib/json_ui/abstract_builder.rb +0 -0
  13. data/app/helpers/glib/json_ui/action_builder.rb +0 -0
  14. data/app/helpers/glib/json_ui/list_builders.rb +0 -0
  15. data/app/helpers/glib/json_ui/menu_builder.rb +0 -0
  16. data/app/helpers/glib/json_ui/page_helper.rb +0 -0
  17. data/app/helpers/glib/json_ui/response_helper.rb +0 -0
  18. data/app/helpers/glib/json_ui/split_builders.rb +0 -0
  19. data/app/helpers/glib/json_ui/styling_helper.rb +0 -0
  20. data/app/helpers/glib/json_ui/table_builders.rb +0 -0
  21. data/app/helpers/glib/json_ui/view_builder.rb +0 -0
  22. data/app/helpers/glib/json_ui/view_builder/banners.rb +0 -0
  23. data/app/helpers/glib/json_ui/view_builder/fields.rb +0 -0
  24. data/app/helpers/glib/json_ui/view_builder/panels.rb +0 -0
  25. data/app/models/glib/active_storage/attachment.rb +0 -0
  26. data/app/models/glib/active_storage/blob.rb +0 -0
  27. data/app/models/glib/dynamic_text_record.rb +0 -0
  28. data/app/models/glib/text.rb +0 -0
  29. data/app/policies/glib/application_policy.rb +148 -148
  30. data/app/views/app/views/json_ui/vue/renderer.html.erb +0 -0
  31. data/app/views/json_ui/garage/_nav_menu.json.jbuilder +0 -0
  32. data/app/views/json_ui/garage/actions/index.json.jbuilder +0 -0
  33. data/app/views/json_ui/garage/forms/_alert_post_data.json.jbuilder +0 -0
  34. data/app/views/json_ui/garage/forms/basic.json.jbuilder +0 -0
  35. data/app/views/json_ui/garage/forms/basic_post.json.jbuilder +0 -0
  36. data/app/views/json_ui/garage/forms/checkboxes.json.jbuilder +0 -0
  37. data/app/views/json_ui/garage/forms/dynamic_select.json.jbuilder +0 -0
  38. data/app/views/json_ui/garage/forms/dynamic_select_data.json.jbuilder +0 -0
  39. data/app/views/json_ui/garage/forms/file_upload.json.jbuilder +0 -0
  40. data/app/views/json_ui/garage/forms/floating_submit.json.jbuilder +0 -0
  41. data/app/views/json_ui/garage/forms/generic_post.json.jbuilder +0 -0
  42. data/app/views/json_ui/garage/forms/get_request.json.jbuilder +0 -0
  43. data/app/views/json_ui/garage/forms/index.json.jbuilder +0 -0
  44. data/app/views/json_ui/garage/forms/pickers.json.jbuilder +0 -0
  45. data/app/views/json_ui/garage/forms/rich_text.json.jbuilder +0 -0
  46. data/app/views/json_ui/garage/forms/selects.json.jbuilder +0 -0
  47. data/app/views/json_ui/garage/forms/submission_flow.json.jbuilder +0 -0
  48. data/app/views/json_ui/garage/forms/submission_flow_post.json.jbuilder +0 -0
  49. data/app/views/json_ui/garage/forms/submission_indicator.json.jbuilder +0 -0
  50. data/app/views/json_ui/garage/forms/submission_indicator_post.json.jbuilder +0 -0
  51. data/app/views/json_ui/garage/forms/text_validation.json.jbuilder +0 -0
  52. data/app/views/json_ui/garage/home/blank.json.jbuilder +0 -0
  53. data/app/views/json_ui/garage/home/index.json.jbuilder +0 -0
  54. data/app/views/json_ui/garage/lists/_infinite_scroll_section.json.jbuilder +0 -0
  55. data/app/views/json_ui/garage/lists/edit_actions.json.jbuilder +0 -0
  56. data/app/views/json_ui/garage/lists/fab.json.jbuilder +0 -0
  57. data/app/views/json_ui/garage/lists/index.json.jbuilder +0 -0
  58. data/app/views/json_ui/garage/lists/infinite_scroll.json.jbuilder +0 -0
  59. data/app/views/json_ui/garage/lists/templating.json.jbuilder +0 -0
  60. data/app/views/json_ui/garage/pages/flat_centered.json.jbuilder +0 -0
  61. data/app/views/json_ui/garage/pages/full_width.json.jbuilder +0 -0
  62. data/app/views/json_ui/garage/pages/full_width_height.json.jbuilder +0 -0
  63. data/app/views/json_ui/garage/pages/index.json.jbuilder +0 -0
  64. data/app/views/json_ui/garage/pages/layout.json.jbuilder +0 -0
  65. data/app/views/json_ui/garage/pages/nav_buttons.json.jbuilder +0 -0
  66. data/app/views/json_ui/garage/pages/tab_bar.json.jbuilder +0 -0
  67. data/app/views/json_ui/garage/panels/card.json.jbuilder +0 -0
  68. data/app/views/json_ui/garage/panels/carousel.json.jbuilder +0 -0
  69. data/app/views/json_ui/garage/panels/custom.json.jbuilder +0 -0
  70. data/app/views/json_ui/garage/panels/horizontal.json.jbuilder +0 -0
  71. data/app/views/json_ui/garage/panels/index.json.jbuilder +0 -0
  72. data/app/views/json_ui/garage/panels/responsive.json.jbuilder +0 -0
  73. data/app/views/json_ui/garage/panels/split.json.jbuilder +0 -0
  74. data/app/views/json_ui/garage/panels/vertical.json.jbuilder +0 -0
  75. data/app/views/json_ui/garage/tables/_autoload_section.json.jbuilder +0 -0
  76. data/app/views/json_ui/garage/tables/autoload_all.json.jbuilder +0 -0
  77. data/app/views/json_ui/garage/tables/export_import.json.jbuilder +0 -0
  78. data/app/views/json_ui/garage/tables/horizontal_scroll.json.jbuilder +0 -0
  79. data/app/views/json_ui/garage/tables/index.json.jbuilder +0 -0
  80. data/app/views/json_ui/garage/views/banners.json.jbuilder +0 -0
  81. data/app/views/json_ui/garage/views/calendar_data.json.jbuilder +0 -0
  82. data/app/views/json_ui/garage/views/carousels.json.jbuilder +0 -0
  83. data/app/views/json_ui/garage/views/charts.json.jbuilder +0 -0
  84. data/app/views/json_ui/garage/views/images.json.jbuilder +0 -0
  85. data/app/views/json_ui/garage/views/index.json.jbuilder +0 -0
  86. data/app/views/json_ui/garage/views/links.json.jbuilder +0 -0
  87. data/app/views/json_ui/garage/views/map_data.json.jbuilder +0 -0
  88. data/app/views/json_ui/garage/views/misc.json.jbuilder +0 -0
  89. data/app/views/json_ui/garage/views/texts.json.jbuilder +0 -0
  90. data/config/routes.rb +0 -0
  91. data/lib/generators/glib/install_generator.rb +0 -0
  92. data/lib/generators/templates/20191017062519_create_texts.rb +0 -0
  93. data/lib/generators/templates/20191024063257_add_scope_to_texts.rb +0 -0
  94. data/lib/generators/templates/20191112095018_add_lang_to_texts.rb +0 -0
  95. data/lib/generators/templates/20191126071051_create_active_storage_tables.active_storage.rb +0 -0
  96. data/lib/generators/templates/database.yml +0 -0
  97. data/lib/generators/templates/dynamic_text.rb +0 -0
  98. data/lib/glib-web.rb +0 -0
  99. data/lib/glib/dynamic_text.rb +0 -0
  100. data/lib/glib/dynamic_text/config.rb +2 -2
  101. data/lib/glib/engine.rb +0 -0
  102. data/lib/glib/json_crawler.rb +0 -0
  103. data/lib/glib/json_crawler/action_crawler.rb +0 -0
  104. data/lib/glib/json_crawler/action_crawlers/action_http.rb +0 -0
  105. data/lib/glib/json_crawler/action_crawlers/forms_submit.rb +0 -0
  106. data/lib/glib/json_crawler/action_crawlers/nav_initiate.rb +0 -0
  107. data/lib/glib/json_crawler/action_crawlers/windows_open.rb +0 -0
  108. data/lib/glib/json_crawler/http.rb +0 -0
  109. data/lib/glib/json_crawler/router.rb +0 -0
  110. data/lib/glib/value.rb +0 -0
  111. data/lib/glib/version.rb +0 -0
  112. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: a5a76adac60e9d744d6b9e1fdd348ee233584c8e
4
- data.tar.gz: 19353084048592e6c0104e1f7201ed932f9928dd
2
+ SHA256:
3
+ metadata.gz: cb86f56770b733b9e6dffe8f2b2b1dce9786a5cff9609429832402f4883d505f
4
+ data.tar.gz: 6331df9c323c531df8ce4c8e1ca2b812d26e9f7fe7ff17e65b77c1bb15fcf77e
5
5
  SHA512:
6
- metadata.gz: ca0356a4a7914a86a6a922be89384f5a14a867d0b4c16f5dff254835373b9eaab4ab9bc8209ace2e85ef103c96cd39b9d106fdaf0f1f1ff99ca3bbe8620cea1c
7
- data.tar.gz: 36f955ab0f5c83d3b05c342f16ef6b4fe6fea60bf81a1933bddc23e1a88c79c1720753d5ad1c3f79f6af62494d61d16bf446d33663d3f9693ad64f854a96ba52
6
+ metadata.gz: 6c314405ef3d50d97ef4deb4056f3f2ff53d1d046c1f9c31c90503762597d80cb013863c2b3d55cc1bd5569ea6b79b9a1da94deb5405856f544f2a540084f704
7
+ data.tar.gz: a677e65a2b3338688be9f1c9b157da94edbd90a1b4b2507fe2c71f3b8fd36cac5205c30e81bf3fdb9a91d97f2809efb01f5208292950abb27388a1974888e57b
File without changes
File without changes
File without changes
@@ -34,7 +34,19 @@ module Glib::Json::DynamicText
34
34
  end
35
35
 
36
36
  def retrieve_remote_texts(keys)
37
- response = RestClient.get(ENV['DTR_URL'], { params: { keys: keys } })
37
+ retries = 0
38
+
39
+ begin
40
+ response = RestClient.get(ENV['DTR_URL'], { params: { keys: keys } })
41
+ rescue Errno::ECONNREFUSED, RestClient::InternalServerError, RestClient::Exceptions::OpenTimeout, RestClient::Exceptions::ReadTimeout
42
+ if (retries += 1) <= 3
43
+ puts "Timeout, retrying..."
44
+ retry
45
+ else
46
+ raise
47
+ end
48
+ end
49
+
38
50
  JSON.parse(response)
39
51
  end
40
52
 
@@ -42,7 +42,19 @@ module Glib::Json::NewDynamicText
42
42
  end
43
43
 
44
44
  def retrieve_remote_texts(keys)
45
- response = RestClient.get(ENV['DTR_URL'], { params: { keys: keys } })
45
+ retries = 0
46
+
47
+ begin
48
+ response = RestClient.get(ENV['DTR_URL'], { params: { keys: keys } })
49
+ rescue Errno::ECONNREFUSED, RestClient::InternalServerError, RestClient::Exceptions::OpenTimeout, RestClient::Exceptions::ReadTimeout
50
+ if (retries += 1) <= 3
51
+ puts "Timeout, retrying..."
52
+ retry
53
+ else
54
+ raise
55
+ end
56
+ end
57
+
46
58
  JSON.parse(response)
47
59
  end
48
60
 
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
@@ -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
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
File without changes
data/config/routes.rb CHANGED
File without changes
File without changes
File without changes
File without changes
data/lib/glib-web.rb CHANGED
File without changes
File without changes
@@ -2,7 +2,7 @@ module Glib
2
2
  module DynamicText
3
3
  class Config
4
4
  @@redis = nil
5
- @@database_url = ENV['DT_DATABASE_URL']
5
+ @@database_url = nil
6
6
 
7
7
  def self.redis
8
8
  if @@redis.nil?
@@ -13,7 +13,7 @@ module Glib
13
13
  end
14
14
 
15
15
  def self.database_url
16
- @@database_url
16
+ @@database_url ||= ENV['DT_DATABASE_URL']
17
17
  end
18
18
  end
19
19
  end
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
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.13
4
+ version: 0.4.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - ''
@@ -203,7 +203,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
203
203
  version: '0'
204
204
  requirements: []
205
205
  rubyforge_project:
206
- rubygems_version: 2.6.8
206
+ rubygems_version: 2.7.6
207
207
  signing_key:
208
208
  specification_version: 4
209
209
  summary: ''