glib-web 0.4.10 → 0.4.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/app/controllers/concerns/application/json/libs.rb +0 -0
- data/app/controllers/concerns/application/json/transformation.rb +0 -0
- data/app/controllers/concerns/application/json/ui.rb +0 -0
- data/app/controllers/concerns/application/json/validation.rb +0 -0
- data/app/controllers/concerns/glib/auth/policy.rb +0 -0
- data/app/controllers/concerns/glib/json/libs.rb +4 -0
- data/app/controllers/concerns/glib/json/new_dynamic_text.rb +3 -0
- data/app/controllers/concerns/glib/json/traversal.rb +0 -4
- data/app/controllers/glib/home_controller.rb +0 -0
- data/app/helpers/glib/dynamic_texts_helper.rb +3 -2
- data/app/helpers/glib/json_ui/abstract_builder.rb +0 -0
- data/app/helpers/glib/json_ui/action_builder.rb +0 -0
- data/app/helpers/glib/json_ui/list_builders.rb +0 -0
- data/app/helpers/glib/json_ui/menu_builder.rb +0 -0
- data/app/helpers/glib/json_ui/page_helper.rb +17 -18
- data/app/helpers/glib/json_ui/response_helper.rb +0 -0
- data/app/helpers/glib/json_ui/split_builders.rb +0 -0
- data/app/helpers/glib/json_ui/styling_helper.rb +0 -0
- data/app/helpers/glib/json_ui/table_builders.rb +0 -0
- data/app/helpers/glib/json_ui/view_builder.rb +0 -0
- data/app/helpers/glib/json_ui/view_builder/banners.rb +0 -0
- data/app/helpers/glib/json_ui/view_builder/fields.rb +0 -0
- data/app/helpers/glib/json_ui/view_builder/panels.rb +0 -0
- data/app/models/glib/active_storage/attachment.rb +0 -0
- data/app/models/glib/active_storage/blob.rb +0 -0
- data/app/models/glib/dynamic_text_record.rb +0 -0
- data/app/models/glib/text.rb +0 -0
- data/app/policies/glib/application_policy.rb +148 -148
- data/app/views/app/views/json_ui/vue/renderer.html.erb +0 -0
- data/app/views/json_ui/garage/_nav_menu.json.jbuilder +0 -0
- data/app/views/json_ui/garage/actions/index.json.jbuilder +0 -0
- data/app/views/json_ui/garage/forms/_alert_post_data.json.jbuilder +0 -0
- data/app/views/json_ui/garage/forms/basic.json.jbuilder +0 -0
- data/app/views/json_ui/garage/forms/basic_post.json.jbuilder +0 -0
- data/app/views/json_ui/garage/forms/checkboxes.json.jbuilder +0 -0
- data/app/views/json_ui/garage/forms/dynamic_select.json.jbuilder +0 -0
- data/app/views/json_ui/garage/forms/dynamic_select_data.json.jbuilder +0 -0
- data/app/views/json_ui/garage/forms/file_upload.json.jbuilder +0 -0
- data/app/views/json_ui/garage/forms/floating_submit.json.jbuilder +0 -0
- data/app/views/json_ui/garage/forms/generic_post.json.jbuilder +0 -0
- data/app/views/json_ui/garage/forms/get_request.json.jbuilder +0 -0
- data/app/views/json_ui/garage/forms/index.json.jbuilder +0 -0
- data/app/views/json_ui/garage/forms/pickers.json.jbuilder +0 -0
- data/app/views/json_ui/garage/forms/rich_text.json.jbuilder +0 -0
- data/app/views/json_ui/garage/forms/selects.json.jbuilder +0 -0
- data/app/views/json_ui/garage/forms/submission_flow.json.jbuilder +0 -0
- data/app/views/json_ui/garage/forms/submission_flow_post.json.jbuilder +0 -0
- data/app/views/json_ui/garage/forms/submission_indicator.json.jbuilder +0 -0
- data/app/views/json_ui/garage/forms/submission_indicator_post.json.jbuilder +0 -0
- data/app/views/json_ui/garage/forms/text_validation.json.jbuilder +0 -0
- data/app/views/json_ui/garage/home/blank.json.jbuilder +0 -0
- data/app/views/json_ui/garage/home/index.json.jbuilder +0 -0
- data/app/views/json_ui/garage/lists/_infinite_scroll_section.json.jbuilder +0 -0
- data/app/views/json_ui/garage/lists/edit_actions.json.jbuilder +0 -0
- data/app/views/json_ui/garage/lists/fab.json.jbuilder +0 -0
- data/app/views/json_ui/garage/lists/index.json.jbuilder +0 -0
- data/app/views/json_ui/garage/lists/infinite_scroll.json.jbuilder +0 -0
- data/app/views/json_ui/garage/lists/templating.json.jbuilder +0 -0
- data/app/views/json_ui/garage/pages/flat_centered.json.jbuilder +0 -0
- data/app/views/json_ui/garage/pages/full_width.json.jbuilder +0 -0
- data/app/views/json_ui/garage/pages/full_width_height.json.jbuilder +0 -0
- data/app/views/json_ui/garage/pages/index.json.jbuilder +0 -0
- data/app/views/json_ui/garage/pages/layout.json.jbuilder +0 -0
- data/app/views/json_ui/garage/pages/nav_buttons.json.jbuilder +0 -0
- data/app/views/json_ui/garage/pages/tab_bar.json.jbuilder +0 -0
- data/app/views/json_ui/garage/panels/card.json.jbuilder +0 -0
- data/app/views/json_ui/garage/panels/carousel.json.jbuilder +0 -0
- data/app/views/json_ui/garage/panels/custom.json.jbuilder +0 -0
- data/app/views/json_ui/garage/panels/horizontal.json.jbuilder +0 -0
- data/app/views/json_ui/garage/panels/index.json.jbuilder +0 -0
- data/app/views/json_ui/garage/panels/responsive.json.jbuilder +0 -0
- data/app/views/json_ui/garage/panels/split.json.jbuilder +0 -0
- data/app/views/json_ui/garage/panels/vertical.json.jbuilder +0 -0
- data/app/views/json_ui/garage/tables/_autoload_section.json.jbuilder +0 -0
- data/app/views/json_ui/garage/tables/autoload_all.json.jbuilder +0 -0
- data/app/views/json_ui/garage/tables/export_import.json.jbuilder +0 -0
- data/app/views/json_ui/garage/tables/horizontal_scroll.json.jbuilder +0 -0
- data/app/views/json_ui/garage/tables/index.json.jbuilder +0 -0
- data/app/views/json_ui/garage/views/banners.json.jbuilder +0 -0
- data/app/views/json_ui/garage/views/calendar_data.json.jbuilder +0 -0
- data/app/views/json_ui/garage/views/carousels.json.jbuilder +0 -0
- data/app/views/json_ui/garage/views/charts.json.jbuilder +0 -0
- data/app/views/json_ui/garage/views/images.json.jbuilder +0 -0
- data/app/views/json_ui/garage/views/index.json.jbuilder +0 -0
- data/app/views/json_ui/garage/views/links.json.jbuilder +0 -0
- data/app/views/json_ui/garage/views/map_data.json.jbuilder +0 -0
- data/app/views/json_ui/garage/views/misc.json.jbuilder +0 -0
- data/app/views/json_ui/garage/views/texts.json.jbuilder +0 -0
- data/config/routes.rb +0 -0
- data/lib/generators/glib/install_generator.rb +0 -0
- data/lib/generators/templates/20191017062519_create_texts.rb +0 -0
- data/lib/generators/templates/20191024063257_add_scope_to_texts.rb +0 -0
- data/lib/generators/templates/20191112095018_add_lang_to_texts.rb +0 -0
- data/lib/generators/templates/20191126071051_create_active_storage_tables.active_storage.rb +0 -0
- data/lib/generators/templates/database.yml +0 -0
- data/lib/generators/templates/dynamic_text.rb +0 -0
- data/lib/glib-web.rb +0 -0
- data/lib/glib/engine.rb +0 -0
- data/lib/glib/json_crawler.rb +0 -0
- data/lib/glib/json_crawler/action_crawler.rb +0 -0
- data/lib/glib/json_crawler/action_crawlers/action_http.rb +0 -0
- data/lib/glib/json_crawler/action_crawlers/forms_submit.rb +0 -0
- data/lib/glib/json_crawler/action_crawlers/nav_initiate.rb +0 -0
- data/lib/glib/json_crawler/action_crawlers/windows_open.rb +0 -0
- data/lib/glib/json_crawler/http.rb +0 -0
- data/lib/glib/json_crawler/router.rb +0 -0
- data/lib/glib/value.rb +0 -0
- data/lib/glib/version.rb +0 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8dc0677c6f29166100884d7d415d3f85a5caaef4
|
4
|
+
data.tar.gz: 1d9ab884a48db31bc4957d86b43370938bc5fefc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f890e2878ee7d3ac12030008b81c703e3a2398b4ed22b829294ca33d28391a01e656fd7d5ae5362e81e50aeeaae80ab4ff2ea36bb4c101a85c83c77062c50d3
|
7
|
+
data.tar.gz: 3bb000732b8dcc373ee166cdd91bc0d6ef601ab9d74adc427d345e7daad9ca2a840026367059754178a4c2e1c22bda7ae9aa2bcdd09042ab96eced346f53334c
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# TODO: Remove old DynamicText
|
1
2
|
module Glib::Json::NewDynamicText
|
2
3
|
def __json_traversal_register_dynamic_text
|
3
4
|
@__specs = {}
|
@@ -30,6 +31,7 @@ module Glib::Json::NewDynamicText
|
|
30
31
|
examples_translations = {
|
31
32
|
'home.json_ui_garage.hello' => 'Hello {{name}}',
|
32
33
|
'home.json_ui_garage.greeting' => 'Good day!',
|
34
|
+
'home.json_ui_garage.greeting_with_image' => 'Good day! (with image)',
|
33
35
|
}
|
34
36
|
|
35
37
|
translated_texts = {}
|
@@ -105,6 +107,7 @@ module Glib::Json::NewDynamicText
|
|
105
107
|
}
|
106
108
|
end
|
107
109
|
|
110
|
+
# TODO: Reuse method from DynamicTextsHelper
|
108
111
|
def image_server_url(blob_key, w: 100, h: 100)
|
109
112
|
return unless blob_key.present?
|
110
113
|
|
@@ -64,10 +64,6 @@ module Glib::Json::Traversal
|
|
64
64
|
# Generic view children
|
65
65
|
traverse_multiple view['childViews'], block
|
66
66
|
|
67
|
-
# panels/split
|
68
|
-
# crawl_multiple view['leftViews'], block
|
69
|
-
# crawl_multiple view['rightViews'], block
|
70
|
-
|
71
67
|
# Split panel
|
72
68
|
traverse_vertical_content view['left'], block
|
73
69
|
traverse_vertical_content view['center'], block
|
File without changes
|
@@ -17,7 +17,7 @@ module Glib
|
|
17
17
|
if text_object.images.attached?
|
18
18
|
content = content.gsub(/\{\{image(\d)\}\}/) {
|
19
19
|
if image = text_object.images[$1.to_i - 1]
|
20
|
-
|
20
|
+
dt_image_server_url(image.blob.key)
|
21
21
|
else
|
22
22
|
"{{image#{$1}}}"
|
23
23
|
end
|
@@ -39,9 +39,10 @@ module Glib
|
|
39
39
|
}.merge(args)
|
40
40
|
end
|
41
41
|
|
42
|
-
def
|
42
|
+
def dt_image_server_url(blob_key, w: 100, h: 100)
|
43
43
|
return unless blob_key.present?
|
44
44
|
|
45
|
+
# TODO: This should probably be set as a parameter for json_libs
|
45
46
|
uri = URI::HTTPS.build(
|
46
47
|
host: 'imageserver-demo.herokuapp.com',
|
47
48
|
path: "/image/#{ENV['AWS_S3_BUCKET']}/#{blob_key}",
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -2,7 +2,7 @@ module Glib
|
|
2
2
|
module JsonUi
|
3
3
|
module PageHelper
|
4
4
|
def json_ui_garage_url(options = {})
|
5
|
-
|
5
|
+
Glib::Web::Engine.routes.url_helpers.json_ui_garage_url(options.merge(
|
6
6
|
protocol: request.protocol,
|
7
7
|
host: request.host,
|
8
8
|
port: request.port,
|
@@ -10,10 +10,11 @@ module Glib
|
|
10
10
|
)
|
11
11
|
end
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
# TODO: Remove the block
|
14
|
+
def json_ui_page(json, &block)
|
15
|
+
@__json_ui_page ||= Page.new(json, self)
|
16
|
+
block&.call @__json_ui_page
|
17
|
+
@__json_ui_page
|
17
18
|
end
|
18
19
|
|
19
20
|
class Page
|
@@ -23,7 +24,7 @@ module Glib
|
|
23
24
|
# See Panels::Form
|
24
25
|
attr_accessor :current_form
|
25
26
|
|
26
|
-
def initialize
|
27
|
+
def initialize(json, context)
|
27
28
|
@json = json
|
28
29
|
@context = context
|
29
30
|
|
@@ -36,7 +37,7 @@ module Glib
|
|
36
37
|
@table_section_builder = TableBuilders::Section.new(json, self, TableBuilders::Template.new(json, self))
|
37
38
|
@split_content_builder = SplitBuilders::Content.new(json, self, @view_builder)
|
38
39
|
end
|
39
|
-
|
40
|
+
|
40
41
|
def rightNavButtons
|
41
42
|
json.rightNavButtons do
|
42
43
|
yield @menu_builder
|
@@ -48,18 +49,16 @@ module Glib
|
|
48
49
|
end
|
49
50
|
|
50
51
|
def leftDrawer(options = {})
|
51
|
-
# json.leftDrawer do
|
52
|
-
# json.title options[:title]
|
53
|
-
# json.items do
|
54
|
-
# yield @menu_builder
|
55
|
-
# end
|
56
|
-
# end
|
57
|
-
|
58
52
|
json.leftDrawer do
|
53
|
+
[:styleClasses].each do |name|
|
54
|
+
if (value = options.delete(name))
|
55
|
+
json.set! name, value
|
56
|
+
end
|
57
|
+
end
|
59
58
|
options[:content]&.call drawer_content_builder
|
60
59
|
end
|
61
60
|
end
|
62
|
-
|
61
|
+
|
63
62
|
def navBar(options = {})
|
64
63
|
json.navBar do
|
65
64
|
json.rightItems do
|
@@ -85,7 +84,7 @@ module Glib
|
|
85
84
|
vertical_content(options)
|
86
85
|
end
|
87
86
|
end
|
88
|
-
|
87
|
+
|
89
88
|
def list(options = {})
|
90
89
|
json.body do
|
91
90
|
json.childViews do
|
@@ -93,7 +92,7 @@ module Glib
|
|
93
92
|
end
|
94
93
|
end
|
95
94
|
end
|
96
|
-
|
95
|
+
|
97
96
|
def table(options = {})
|
98
97
|
json.body do
|
99
98
|
json.childViews do
|
@@ -101,7 +100,7 @@ module Glib
|
|
101
100
|
end
|
102
101
|
end
|
103
102
|
end
|
104
|
-
|
103
|
+
|
105
104
|
def scroll(options = {})
|
106
105
|
json.body do
|
107
106
|
json.childViews do
|
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/app/models/glib/text.rb
CHANGED
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
|
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
|
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
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/lib/glib-web.rb
CHANGED
File without changes
|
data/lib/glib/engine.rb
CHANGED
File without changes
|
data/lib/glib/json_crawler.rb
CHANGED
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/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.
|
4
|
+
version: 0.4.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ''
|
@@ -201,7 +201,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
201
201
|
version: '0'
|
202
202
|
requirements: []
|
203
203
|
rubyforge_project:
|
204
|
-
rubygems_version: 2.
|
204
|
+
rubygems_version: 2.6.8
|
205
205
|
signing_key:
|
206
206
|
specification_version: 4
|
207
207
|
summary: ''
|