linked_rails 0.0.4.pre.gfe77aae19 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +674 -21
- data/app/controllers/linked_rails/bulk_controller.rb +16 -81
- data/app/models/linked_rails/actions/item.rb +30 -23
- data/app/models/linked_rails/actions/list.rb +6 -0
- data/app/models/linked_rails/collection/filter_field.rb +3 -16
- data/app/models/linked_rails/collection/filterable.rb +4 -6
- data/app/models/linked_rails/collection/infinite.rb +6 -17
- data/app/models/linked_rails/collection/iri.rb +2 -25
- data/app/models/linked_rails/collection/iri_mapping.rb +1 -1
- data/app/models/linked_rails/collection/paginated.rb +3 -4
- data/app/models/linked_rails/collection/view.rb +10 -38
- data/app/models/linked_rails/collection.rb +25 -27
- data/app/models/linked_rails/enum_value.rb +1 -1
- data/app/models/linked_rails/form/field/association_input.rb +1 -7
- data/app/models/linked_rails/form/field/file_input.rb +0 -1
- data/app/models/linked_rails/form/field.rb +5 -31
- data/app/models/linked_rails/form/field_factory.rb +16 -29
- data/app/models/linked_rails/form/group.rb +4 -2
- data/app/models/linked_rails/form/page.rb +0 -4
- data/app/models/linked_rails/form.rb +6 -4
- data/app/models/linked_rails/manifest.rb +20 -94
- data/app/models/linked_rails/menus/item.rb +13 -10
- data/app/models/linked_rails/menus/list.rb +5 -13
- data/app/models/linked_rails/ontology/base.rb +0 -2
- data/app/models/linked_rails/ontology.rb +0 -1
- data/app/models/linked_rails/property_query.rb +0 -2
- data/app/models/linked_rails/sequence.rb +11 -2
- data/app/models/linked_rails/web_page.rb +4 -0
- data/app/models/linked_rails/web_site.rb +4 -0
- data/app/models/linked_rails/widget.rb +10 -3
- data/app/policies/linked_rails/collection_policy.rb +2 -2
- data/app/serializers/linked_rails/actions/item_serializer.rb +4 -3
- data/app/serializers/linked_rails/collection/filter_field_serializer.rb +2 -3
- data/app/serializers/linked_rails/collection/filter_option_serializer.rb +1 -1
- data/app/serializers/linked_rails/collection/filter_serializer.rb +1 -1
- data/app/serializers/linked_rails/collection/sorting_serializer.rb +1 -1
- data/app/serializers/linked_rails/collection/view_serializer.rb +3 -3
- data/app/serializers/linked_rails/collection_serializer.rb +13 -9
- data/app/serializers/linked_rails/condition_serializer.rb +3 -3
- data/app/serializers/linked_rails/entry_point_serializer.rb +2 -2
- data/app/serializers/linked_rails/enum_value_serializer.rb +0 -1
- data/app/serializers/linked_rails/form/field/association_input_serializer.rb +0 -1
- data/app/serializers/linked_rails/form/field_serializer.rb +1 -3
- data/app/serializers/linked_rails/form/group_serializer.rb +1 -1
- data/app/serializers/linked_rails/form/page_serializer.rb +1 -1
- data/app/serializers/linked_rails/menus/item_serializer.rb +3 -3
- data/app/serializers/linked_rails/menus/list_serializer.rb +1 -1
- data/app/serializers/linked_rails/sequence_serializer.rb +5 -2
- data/app/serializers/linked_rails/shacl/node_shape_serializer.rb +1 -1
- data/app/serializers/linked_rails/shacl/property_shape_serializer.rb +1 -1
- data/app/serializers/linked_rails/shacl/shape_serializer.rb +5 -5
- data/app/serializers/linked_rails/web_page_serializer.rb +3 -3
- data/app/serializers/linked_rails/web_site_serializer.rb +1 -1
- data/app/serializers/linked_rails/widget_serializer.rb +3 -3
- data/lib/generators/linked_rails/install/templates/locales.yml +0 -4
- data/lib/generators/linked_rails/install/templates/rdf_serializers_initializer.rb +1 -1
- data/lib/generators/linked_rails/model/templates/form.rb.tt +1 -1
- data/lib/generators/linked_rails/model/templates/policy.rb.tt +1 -1
- data/lib/generators/linked_rails/model/templates/serializer.rb.tt +1 -5
- data/lib/linked_rails/active_response/controller/collections.rb +1 -1
- data/lib/linked_rails/active_response/controller/crud_defaults.rb +1 -1
- data/lib/linked_rails/active_response/controller/params.rb +6 -6
- data/lib/linked_rails/active_response/controller.rb +22 -1
- data/lib/linked_rails/collection_params_parser.rb +1 -1
- data/lib/linked_rails/controller/actionable.rb +2 -5
- data/lib/linked_rails/controller/default_actions/create.rb +2 -2
- data/lib/linked_rails/controller/error_handling.rb +7 -12
- data/lib/linked_rails/controller.rb +1 -4
- data/lib/linked_rails/helpers/delta_helper.rb +58 -4
- data/lib/linked_rails/helpers/resource_helper.rb +1 -13
- data/lib/linked_rails/iri_mapper.rb +1 -1
- data/lib/linked_rails/middleware/linked_data_params.rb +27 -26
- data/lib/linked_rails/model/actionable.rb +8 -7
- data/lib/linked_rails/model/collections.rb +4 -10
- data/lib/linked_rails/model/dirty.rb +18 -6
- data/lib/linked_rails/model/filtering.rb +2 -2
- data/lib/linked_rails/model/indexable.rb +1 -1
- data/lib/linked_rails/model/iri.rb +2 -14
- data/lib/linked_rails/model/iri_mapping.rb +3 -3
- data/lib/linked_rails/model/menuable.rb +7 -1
- data/lib/linked_rails/model/serialization.rb +6 -2
- data/lib/linked_rails/model/singularable.rb +5 -7
- data/lib/linked_rails/model/tables.rb +1 -1
- data/lib/linked_rails/model.rb +2 -5
- data/lib/linked_rails/params_parser.rb +47 -48
- data/lib/linked_rails/policy.rb +30 -21
- data/lib/linked_rails/renderers.rb +0 -1
- data/lib/linked_rails/routes.rb +0 -1
- data/lib/linked_rails/serializer/singularable.rb +1 -1
- data/lib/linked_rails/serializer.rb +2 -6
- data/lib/linked_rails/translate.rb +0 -12
- data/lib/linked_rails/vocab.rb +0 -1
- data/lib/linked_rails.rb +3 -16
- data/lib/rdf/query_fix.rb +1 -1
- metadata +10 -59
- data/app/controllers/linked_rails/actions/objects_controller.rb +0 -9
- data/app/models/linked_rails/actions/object.rb +0 -38
- data/app/models/linked_rails/form/field/url_input.rb +0 -10
- data/app/policies/linked_rails/actions/object_policy.rb +0 -11
- data/app/policies/linked_rails/form_policy.rb +0 -13
- data/app/policies/linked_rails/ontology_policy.rb +0 -13
- data/app/serializers/linked_rails/actions/object_serializer.rb +0 -9
- data/app/serializers/linked_rails/form/field/file_input_serializer.rb +0 -11
- data/app/serializers/linked_rails/property_query_serializer.rb +0 -7
- data/app/workers/linked_rails/invalidation_stream_worker.rb +0 -16
- data/lib/linked_rails/controller/delta.rb +0 -58
- data/lib/linked_rails/controller/rendering.rb +0 -48
- data/lib/linked_rails/errors/forbidden.rb +0 -37
- data/lib/linked_rails/errors.rb +0 -3
- data/lib/linked_rails/middleware/error_handling.rb +0 -51
- data/lib/linked_rails/model/cacheable.rb +0 -45
- data/lib/linked_rails/railtie.rb +0 -11
- data/lib/linked_rails/storage.rb +0 -32
- data/lib/linked_rails/types/iri_type.rb +0 -37
- data/lib/linked_rails/url.rb +0 -11
- data/lib/rdf/list.rb +0 -9
@@ -2,10 +2,11 @@
|
|
2
2
|
|
3
3
|
module LinkedRails
|
4
4
|
class Sequence
|
5
|
-
attr_accessor :node, :parent, :raw_members, :scope, :user_context
|
5
|
+
attr_accessor :node, :member_includes, :parent, :raw_members, :scope, :user_context
|
6
6
|
alias read_attribute_for_serialization send
|
7
7
|
|
8
8
|
def initialize(members, **opts)
|
9
|
+
self.member_includes = opts[:member_includes]
|
9
10
|
self.node = opts[:id] || RDF::Node.new
|
10
11
|
self.parent = opts[:parent]
|
11
12
|
self.raw_members = members
|
@@ -25,13 +26,21 @@ module LinkedRails
|
|
25
26
|
end
|
26
27
|
|
27
28
|
def preview_includes
|
28
|
-
[:
|
29
|
+
[members: member_includes]
|
29
30
|
end
|
30
31
|
|
31
32
|
def rdf_type
|
32
33
|
self.class.iri
|
33
34
|
end
|
34
35
|
|
36
|
+
def sequence
|
37
|
+
return [] unless members
|
38
|
+
|
39
|
+
members.map.with_index do |item, index|
|
40
|
+
[iri, RDF["_#{index}"], item_iri(item), Vocab.ll[:supplant]]
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
35
44
|
private
|
36
45
|
|
37
46
|
def apply_scope(association)
|
@@ -19,9 +19,12 @@ module LinkedRails
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def resource_sequence
|
22
|
-
@resource_sequence ||=
|
23
|
-
|
24
|
-
|
22
|
+
@resource_sequence ||=
|
23
|
+
LinkedRails::Sequence.new(
|
24
|
+
@resources.map { |iri, predicate| predicate.present? ? property_shape(iri, predicate).iri : RDF::URI(iri) },
|
25
|
+
parent: self,
|
26
|
+
scope: false
|
27
|
+
)
|
25
28
|
end
|
26
29
|
|
27
30
|
def size
|
@@ -43,6 +46,10 @@ module LinkedRails
|
|
43
46
|
def iri
|
44
47
|
Vocab.ontola[:Widget]
|
45
48
|
end
|
49
|
+
|
50
|
+
def preview_includes
|
51
|
+
%i[resource_sequence property_shapes]
|
52
|
+
end
|
46
53
|
end
|
47
54
|
end
|
48
55
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module LinkedRails
|
4
4
|
class CollectionPolicy < LinkedRails.policy_parent_class
|
5
|
-
delegate :permitted_attributes,
|
5
|
+
delegate :permitted_attributes, to: :child_policy
|
6
6
|
|
7
7
|
def create_child?
|
8
8
|
policy = Pundit.policy!(user_context, child_resource)
|
@@ -29,7 +29,7 @@ module LinkedRails
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def child_resource
|
32
|
-
record.
|
32
|
+
record.build_child
|
33
33
|
end
|
34
34
|
|
35
35
|
def parent_policy
|
@@ -18,11 +18,12 @@ module LinkedRails
|
|
18
18
|
end
|
19
19
|
attribute :error, predicate: Vocab.schema.error
|
20
20
|
|
21
|
-
has_one :parent, predicate: Vocab.schema.isPartOf do |object|
|
21
|
+
has_one :parent, predicate: Vocab.schema.isPartOf, polymorphic: true do |object|
|
22
22
|
object.parent unless object.parent.try(:anonymous_iri?)
|
23
23
|
end
|
24
|
-
|
25
|
-
has_one :target, predicate: Vocab.schema.target
|
24
|
+
has_one :object, predicate: Vocab.schema.object, polymorphic: true
|
25
|
+
has_one :target, predicate: Vocab.schema.target, polymorphic: true
|
26
|
+
has_one :included_object, polymorphic: true
|
26
27
|
end
|
27
28
|
end
|
28
29
|
end
|
@@ -5,9 +5,8 @@ module LinkedRails
|
|
5
5
|
class FilterFieldSerializer < LinkedRails.serializer_parent_class
|
6
6
|
attribute :key, predicate: Vocab.ontola[:filterKey]
|
7
7
|
attribute :options_in, predicate: Vocab.ontola[:filterOptionsIn]
|
8
|
-
|
9
|
-
|
10
|
-
has_many :options, predicate: Vocab.ontola[:filterOptions]
|
8
|
+
has_one :collection, predicate: Vocab.schema.isPartOf, polymorphic: true
|
9
|
+
has_many :options, predicate: Vocab.ontola[:filterOptions], polymorphic: true
|
11
10
|
end
|
12
11
|
end
|
13
12
|
end
|
@@ -6,7 +6,7 @@ module LinkedRails
|
|
6
6
|
attribute :count, predicate: Vocab.ontola[:filterCount]
|
7
7
|
attribute :key, predicate: Vocab.ontola[:filterKey]
|
8
8
|
attribute :value, predicate: Vocab.ontola[:filterValue]
|
9
|
-
has_one :collection, predicate: Vocab.schema[:isPartOf]
|
9
|
+
has_one :collection, predicate: Vocab.schema[:isPartOf], polymorphic: true
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
@@ -7,7 +7,7 @@ module LinkedRails
|
|
7
7
|
|
8
8
|
attribute :key, predicate: Vocab.ontola[:filterKey]
|
9
9
|
attribute :value, predicate: Vocab.ontola[:filterValue]
|
10
|
-
has_one :collection, predicate: Vocab.schema.isPartOf
|
10
|
+
has_one :collection, predicate: Vocab.schema.isPartOf, polymorphic: true
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
@@ -7,7 +7,7 @@ module LinkedRails
|
|
7
7
|
|
8
8
|
attribute :key, predicate: Vocab.ontola[:sortKey]
|
9
9
|
attribute :direction, predicate: Vocab.ontola[:sortDirection]
|
10
|
-
has_one :collection, predicate: Vocab.schema.isPartOf
|
10
|
+
has_one :collection, predicate: Vocab.schema.isPartOf, polymorphic: true
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
@@ -14,9 +14,9 @@ module LinkedRails
|
|
14
14
|
attribute attr, predicate: Vocab.as[attr]
|
15
15
|
end
|
16
16
|
|
17
|
-
has_one :collection, predicate: Vocab.as.partOf
|
18
|
-
has_one :unfiltered_collection, predicate: Vocab.ontola[:baseCollection]
|
19
|
-
has_one :member_sequence, predicate: Vocab.as.items
|
17
|
+
has_one :collection, predicate: Vocab.as.partOf, polymorphic: true
|
18
|
+
has_one :unfiltered_collection, predicate: Vocab.ontola[:baseCollection], polymorphic: true
|
19
|
+
has_one :member_sequence, predicate: Vocab.as.items, polymorphic: true
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
@@ -11,13 +11,17 @@ module LinkedRails
|
|
11
11
|
attribute :total_count, predicate: Vocab.as.totalItems do |object|
|
12
12
|
object.total_count if object.type == :paginated
|
13
13
|
end
|
14
|
-
attribute :
|
15
|
-
|
14
|
+
attribute :iri_template, predicate: Vocab.ontola[:iriTemplate] do |object|
|
15
|
+
object
|
16
|
+
.iri_template
|
17
|
+
.to_s
|
18
|
+
.gsub('{route_key}', object.route_key.to_s)
|
19
|
+
.gsub('{/parent_iri*}', object.parent&.iri&.to_s&.split('?')&.first || LinkedRails.iri)
|
20
|
+
end
|
16
21
|
attribute :default_type, predicate: Vocab.ontola[:defaultType], &:type
|
17
22
|
attribute :display, predicate: Vocab.ontola[:collectionDisplay] do |object|
|
18
23
|
Vocab.ontola["collectionDisplay/#{object.display || :default}"]
|
19
24
|
end
|
20
|
-
attribute :call_to_action, predicate: Vocab.ontola[:callToAction]
|
21
25
|
attribute :columns, predicate: Vocab.ontola[:columns]
|
22
26
|
attribute :collection_type, predicate: Vocab.ontola[:collectionType] do |object|
|
23
27
|
Vocab.ontola["collectionType/#{object.type || :paginated}"]
|
@@ -26,17 +30,17 @@ module LinkedRails
|
|
26
30
|
attribute :sort_options, predicate: Vocab.ontola[:sortOptions]
|
27
31
|
attribute :view, predicate: Vocab.ll[:view]
|
28
32
|
|
29
|
-
has_one :unfiltered_collection, predicate: Vocab.ontola[:baseCollection]
|
30
|
-
has_one :part_of, predicate: Vocab.schema.isPartOf do |object|
|
33
|
+
has_one :unfiltered_collection, predicate: Vocab.ontola[:baseCollection], polymorphic: true
|
34
|
+
has_one :part_of, predicate: Vocab.schema.isPartOf, polymorphic: true do |object|
|
31
35
|
object.part_of unless object.part_of.try(:anonymous_iri?)
|
32
36
|
end
|
33
|
-
has_one :default_view, predicate: Vocab.ontola[:pages]
|
37
|
+
has_one :default_view, predicate: Vocab.ontola[:pages], polymorphic: true
|
34
38
|
|
35
|
-
has_many :filter_fields, predicate: Vocab.ontola[:filterFields], sequence: true
|
36
|
-
has_many :filters, predicate: Vocab.ontola[:
|
39
|
+
has_many :filter_fields, predicate: Vocab.ontola[:filterFields], polymorphic: true, sequence: true
|
40
|
+
has_many :filters, predicate: Vocab.ontola[:collectionFilter], polymorphic: true do |object|
|
37
41
|
object.filters.reject(&:default_filter)
|
38
42
|
end
|
39
|
-
has_many :sortings, predicate: Vocab.ontola[:collectionSorting]
|
43
|
+
has_many :sortings, polymorphic: true, predicate: Vocab.ontola[:collectionSorting]
|
40
44
|
|
41
45
|
%i[first last].each do |attr|
|
42
46
|
attribute attr, predicate: Vocab.as[attr]
|
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
module LinkedRails
|
4
4
|
class ConditionSerializer < LinkedRails.serializer_parent_class
|
5
|
-
has_one :fail, predicate: Vocab.ontola[:fail]
|
6
|
-
has_one :pass, predicate: Vocab.ontola[:pass]
|
7
|
-
has_one :shape, predicate: Vocab.sh.node
|
5
|
+
has_one :fail, predicate: Vocab.ontola[:fail], polymorphic: true
|
6
|
+
has_one :pass, predicate: Vocab.ontola[:pass], polymorphic: true
|
7
|
+
has_one :shape, predicate: Vocab.sh.node, polymorphic: true
|
8
8
|
end
|
9
9
|
end
|
@@ -11,8 +11,8 @@ module LinkedRails
|
|
11
11
|
object.http_method.upcase
|
12
12
|
end
|
13
13
|
|
14
|
-
has_one :parent, predicate: Vocab.schema.isPartOf
|
15
|
-
attribute :action_body, predicate: Vocab.ll[:actionBody]
|
14
|
+
has_one :parent, predicate: Vocab.schema.isPartOf, polymorphic: true
|
15
|
+
attribute :action_body, predicate: Vocab.ll[:actionBody], polymorphic: true
|
16
16
|
attribute :image, predicate: Vocab.schema.image do |object|
|
17
17
|
serialize_image(object.image)
|
18
18
|
end
|
@@ -8,6 +8,5 @@ module LinkedRails
|
|
8
8
|
attribute :close_match, predicate: Vocab.skos.closeMatch
|
9
9
|
attribute :exact_match, predicate: Vocab.skos.exactMatch
|
10
10
|
attribute :group_by, predicate: Vocab.ontola[:groupBy]
|
11
|
-
attribute :identifier, predicate: Vocab.schema.identifier
|
12
11
|
end
|
13
12
|
end
|
@@ -5,9 +5,7 @@ module LinkedRails
|
|
5
5
|
class FieldSerializer < LinkedRails.serializer_parent_class
|
6
6
|
attribute :name, predicate: Vocab.schema.name
|
7
7
|
attribute :description, predicate: Vocab.schema.text
|
8
|
-
attribute :helper_text, predicate: Vocab.
|
9
|
-
attribute :start_adornment, predicate: Vocab.form[:startAdornment]
|
10
|
-
attribute :placeholder, predicate: Vocab.form[:placeholder]
|
8
|
+
attribute :helper_text, predicate: Vocab.ontola[:helperText]
|
11
9
|
attribute :default_value, predicate: Vocab.form[:defaultValue]
|
12
10
|
|
13
11
|
attribute :datatype, predicate: Vocab.sh.datatype
|
@@ -8,7 +8,7 @@ module LinkedRails
|
|
8
8
|
attribute :collapsible, predicate: Vocab.form[:collapsible]
|
9
9
|
attribute :hidden, predicate: Vocab.form[:hidden]
|
10
10
|
|
11
|
-
has_many :fields, predicate: Vocab.form[:fields], sequence: true
|
11
|
+
has_many :fields, predicate: Vocab.form[:fields], sequence: true, polymorphic: true
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
@@ -7,7 +7,7 @@ module LinkedRails
|
|
7
7
|
attribute :description, predicate: Vocab.schema.text
|
8
8
|
|
9
9
|
has_many :groups, predicate: Vocab.form[:groups], sequence: true, serializer: Form::GroupSerializer
|
10
|
-
has_one :footer_group
|
10
|
+
has_one :footer_group, predicate: Vocab.form[:footerGroup], serializer: Form::GroupSerializer
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
@@ -13,15 +13,15 @@ module LinkedRails
|
|
13
13
|
attribute :image, predicate: Vocab.schema.image do |object|
|
14
14
|
serialize_image(object.image)
|
15
15
|
end
|
16
|
-
has_one :action, predicate: Vocab.ontola[:action] do |object|
|
16
|
+
has_one :action, predicate: Vocab.ontola[:action], polymorphic: true do |object|
|
17
17
|
object.action unless object.action.is_a?(RDF::Resource)
|
18
18
|
end
|
19
19
|
has_one :menu_sequence,
|
20
20
|
predicate: Vocab.ontola[:menuItems],
|
21
21
|
if: ->(o, p) { menus_present?(o, p) },
|
22
22
|
polymorphic: true
|
23
|
-
has_one :parent, predicate: Vocab.ontola[:parentMenu], if: ->(o, p) { parent_menu?(o, p) }
|
24
|
-
has_one :resource, predicate: Vocab.schema.isPartOf
|
23
|
+
has_one :parent, predicate: Vocab.ontola[:parentMenu], if: ->(o, p) { parent_menu?(o, p) }, polymorphic: true
|
24
|
+
has_one :resource, predicate: Vocab.schema.isPartOf, polymorphic: true
|
25
25
|
|
26
26
|
def self.parent_menu?(object, _params)
|
27
27
|
object.parent.is_a?(LinkedRails.menus_item_class)
|
@@ -5,7 +5,7 @@ module LinkedRails
|
|
5
5
|
class ListSerializer < LinkedRails.serializer_parent_class
|
6
6
|
include LinkedRails::Serializer
|
7
7
|
|
8
|
-
has_many :menus, predicate: Vocab.ontola[:menus] do |object|
|
8
|
+
has_many :menus, predicate: Vocab.ontola[:menus], polymorphic: true do |object|
|
9
9
|
object.menus&.compact
|
10
10
|
end
|
11
11
|
end
|
@@ -4,8 +4,11 @@ module LinkedRails
|
|
4
4
|
class SequenceSerializer < LinkedRails.serializer_parent_class
|
5
5
|
include LinkedRails::Serializer
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
statements :sequence
|
8
|
+
has_many :members, polymorphic: true
|
9
|
+
|
10
|
+
def self.sequence(object, _params)
|
11
|
+
object.sequence
|
9
12
|
end
|
10
13
|
end
|
11
14
|
end
|
@@ -6,7 +6,7 @@ module LinkedRails
|
|
6
6
|
attribute :closed, predicate: Vocab.sh.closed
|
7
7
|
attribute :ignored_properties, predicate: Vocab.sh.ignoredProperties
|
8
8
|
attribute :sparql, predicate: Vocab.sh.sparql
|
9
|
-
has_many :property, predicate: Vocab.sh.property
|
9
|
+
has_many :property, predicate: Vocab.sh.property, polymorphic: true
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
@@ -32,7 +32,7 @@ module LinkedRails
|
|
32
32
|
attribute :qualified_min_count, predicate: Vocab.sh.qualifiedMinCount
|
33
33
|
attribute :qualified_value_shape, predicate: Vocab.sh.qualifiedValueShape
|
34
34
|
|
35
|
-
has_many :path, predicate: Vocab.sh.path, sequence: true
|
35
|
+
has_many :path, predicate: Vocab.sh.path, sequence: true, polymorphic: true
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
@@ -13,11 +13,11 @@ module LinkedRails
|
|
13
13
|
attribute :target_node, predicate: Vocab.sh.targetNode
|
14
14
|
attribute :target_objects_of, predicate: Vocab.sh.targetObjectsOf
|
15
15
|
attribute :target_subjects_of, predicate: Vocab.sh.targetSubjectsOf
|
16
|
-
has_one :sh_not, predicate: Vocab.sh.not
|
17
|
-
has_many :and, predicate: Vocab.sh.and
|
18
|
-
has_many :or, predicate: Vocab.sh.or
|
19
|
-
has_many :xone, predicate: Vocab.sh.xone
|
20
|
-
has_many :nested_shapes do |object|
|
16
|
+
has_one :sh_not, predicate: Vocab.sh.not, polymorphic: true
|
17
|
+
has_many :and, predicate: Vocab.sh.and, polymorphic: true
|
18
|
+
has_many :or, predicate: Vocab.sh.or, polymorphic: true
|
19
|
+
has_many :xone, predicate: Vocab.sh.xone, polymorphic: true
|
20
|
+
has_many :nested_shapes, polymorphic: true do |object|
|
21
21
|
[object.and, object.or, object.sh_not, object.xone].flatten.compact
|
22
22
|
end
|
23
23
|
end
|
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
module LinkedRails
|
4
4
|
class WebPageSerializer < CreativeWorkSerializer
|
5
|
-
has_one :cover_photo, predicate: Vocab.ontola[:coverPhoto]
|
6
|
-
has_one :widget_sequence, predicate: Vocab.ontola[:widgets]
|
7
|
-
has_many :includes
|
5
|
+
has_one :cover_photo, predicate: Vocab.ontola[:coverPhoto], polymorphic: true
|
6
|
+
has_one :widget_sequence, predicate: Vocab.ontola[:widgets], polymorphic: true
|
7
|
+
has_many :includes, polymorphic: true
|
8
8
|
attribute :hide_header, predicate: Vocab.ontola[:hideHeader]
|
9
9
|
end
|
10
10
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module LinkedRails
|
4
4
|
class WebSiteSerializer < CreativeWorkSerializer
|
5
|
-
has_one :homepage, predicate: Vocab.foaf.homepage
|
5
|
+
has_one :homepage, predicate: Vocab.foaf.homepage, polymorphic: true
|
6
6
|
attribute :image, predicate: Vocab.schema.image do |object|
|
7
7
|
serialize_image(object.image)
|
8
8
|
end
|
@@ -6,9 +6,9 @@ module LinkedRails
|
|
6
6
|
|
7
7
|
attribute :size, predicate: Vocab.ontola[:widgetSize]
|
8
8
|
attribute :topology, predicate: Vocab.ontola[:topology]
|
9
|
-
has_one :
|
10
|
-
|
11
|
-
has_many :property_shapes do |object|
|
9
|
+
has_one :resource_sequence, predicate: Vocab.ontola[:widgetResource], polymorphic: true
|
10
|
+
has_one :parent, predicate: Vocab.schema.isPartOf, polymorphic: true
|
11
|
+
has_many :property_shapes, polymorphic: true do |object|
|
12
12
|
object.property_shapes.values
|
13
13
|
end
|
14
14
|
end
|
@@ -11,8 +11,6 @@ en:
|
|
11
11
|
update:
|
12
12
|
label: "Edit"
|
13
13
|
success: 'Updated successfully'
|
14
|
-
errors:
|
15
|
-
access_denied: "You're not authorized for this action. (%{action})"
|
16
14
|
linked_rails:
|
17
15
|
status:
|
18
16
|
400: "Error in request"
|
@@ -24,5 +22,3 @@ en:
|
|
24
22
|
menus:
|
25
23
|
home: "Home"
|
26
24
|
sign_out: "Sign out"
|
27
|
-
add_otp: "Enable 2fa"
|
28
|
-
delete_otp: "Remove 2fa"
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
<% module_namespacing do -%>
|
4
4
|
class <%= class_name %>Policy < ApplicationPolicy
|
5
|
-
permit_attributes %i[<%= attributes.
|
5
|
+
permit_attributes %i[<%= attributes.map { |attribute| attribute.name }.join(' ') %>]
|
6
6
|
|
7
7
|
def create?
|
8
8
|
false
|
@@ -3,11 +3,7 @@
|
|
3
3
|
<% module_namespacing do -%>
|
4
4
|
class <%= class_name %>Serializer < ApplicationSerializer
|
5
5
|
<% attributes.each do |attribute| -%>
|
6
|
-
|
7
|
-
has_one :<%= attribute.name %>, predicate: Vocab.app[:<%= attribute.name.camelize(:lower) %>]
|
8
|
-
<% else -%>
|
9
|
-
attribute :<%= attribute.name %>, predicate: Vocab.app[:<%= attribute.name.camelize(:lower) %>]
|
10
|
-
<% end -%>
|
6
|
+
attribute :<%= attribute.name %>, predicate: Vocab.app[:<%= attribute.name %>]
|
11
7
|
<% end -%>
|
12
8
|
end
|
13
9
|
<% end -%>
|
@@ -14,10 +14,12 @@ module LinkedRails
|
|
14
14
|
@params_parser ||= LinkedRails::ParamsParser.new(params: params, user_context: user_context)
|
15
15
|
end
|
16
16
|
|
17
|
+
def parsed_filter_params
|
18
|
+
params_parser.attributes_from_filters(controller_class)
|
19
|
+
end
|
20
|
+
|
17
21
|
def permit_filter_params
|
18
|
-
@permit_filter_params ||=
|
19
|
-
policy(requested_resource || new_resource)
|
20
|
-
.permitted_attributes_from_filters(params_parser.filter_params)
|
22
|
+
@permit_filter_params ||= parsed_filter_params.permit(*permit_param_keys)
|
21
23
|
end
|
22
24
|
|
23
25
|
def permit_params
|
@@ -39,9 +41,7 @@ module LinkedRails
|
|
39
41
|
end
|
40
42
|
|
41
43
|
def resource_params
|
42
|
-
|
43
|
-
|
44
|
-
return ActionController::Parameters.new if empty_params && allow_empty_params?
|
44
|
+
return ActionController::Parameters.new if !params.key?(permit_param_key) && allow_empty_params?
|
45
45
|
|
46
46
|
params.require(permit_param_key)
|
47
47
|
end
|
@@ -8,11 +8,32 @@ require_relative 'controller/params'
|
|
8
8
|
|
9
9
|
module LinkedRails
|
10
10
|
module Controller
|
11
|
-
include Pundit
|
11
|
+
include Pundit
|
12
12
|
include LinkedRails::ActiveResponse::Controller::Collections
|
13
13
|
include LinkedRails::ActiveResponse::Controller::CrudDefaults
|
14
14
|
include LinkedRails::ActiveResponse::Controller::Params
|
15
15
|
|
16
|
+
def _render_with_renderer_json(record, options)
|
17
|
+
self.content_type = Mime[:json]
|
18
|
+
|
19
|
+
return record if record.is_a?(String)
|
20
|
+
return record.to_json if record.is_a?(Hash)
|
21
|
+
|
22
|
+
serializer_opts = RDF::Serializers::Renderers.transform_opts(
|
23
|
+
options,
|
24
|
+
serializer_params
|
25
|
+
)
|
26
|
+
|
27
|
+
serializer = RDF::Serializers.serializer_for(record)&.new(record, serializer_opts)
|
28
|
+
return record.to_json unless serializer
|
29
|
+
|
30
|
+
Oj.dump(serializer.serializable_hash, mode: :compat)
|
31
|
+
end
|
32
|
+
|
33
|
+
def serializer_params
|
34
|
+
{}
|
35
|
+
end
|
36
|
+
|
16
37
|
def success_message_translation_key
|
17
38
|
"actions.#{Translate.translation_key(controller_class)}.#{action_name}.success"
|
18
39
|
end
|
@@ -12,7 +12,7 @@ module LinkedRails
|
|
12
12
|
def collection_params
|
13
13
|
return @collection_params if instance_variable_defined?(:@collection_params)
|
14
14
|
|
15
|
-
values = permit_params(:display, :page_size, :
|
15
|
+
values = permit_params(:display, :page_size, :title, :type)
|
16
16
|
|
17
17
|
filter = filter_params
|
18
18
|
values[:filter] = filter if filter
|
@@ -58,7 +58,6 @@ module LinkedRails
|
|
58
58
|
# Defaults to false
|
59
59
|
# @option opts [proc<string>, string] :label The label of the action
|
60
60
|
# @option opts [LinkedRails::Model] :object The object on which the action will be executed
|
61
|
-
# Defaults to the resource
|
62
61
|
# @option opts [symbol] :on_failure Callback when the execute method failed.
|
63
62
|
# Defaults to "#{action}_failure"
|
64
63
|
# @option opts [symbol] :on_success Callback when the execute method succeeded.
|
@@ -66,17 +65,15 @@ module LinkedRails
|
|
66
65
|
# @option opts [symbol] :policy The method to be called on the policy of the policy_resource
|
67
66
|
# @option opts [Array<symbol>] :policy_arguments The arguments passed to the policy method
|
68
67
|
# @option opts [proc<LinkedRails::Model>, LinkedRails::Model] :policy_resource
|
69
|
-
# The resource on which a policy needs to be authorized
|
70
|
-
# Defaults to the object
|
68
|
+
# The resource on which a policy needs to be authorized
|
71
69
|
# @option opts [proc<RDF::URI>, RDF::URI] :predicate The relation between the resource and the action
|
72
70
|
# @option opts [proc<LinkedRails::Model>, LinkedRails::Model] :result
|
73
71
|
# @option opts [proc<string>, string] :submit_label The label for the submit button of the action
|
74
72
|
# @option opts [proc<string>, string] :target_url The url whereto the request will be made.
|
75
|
-
# Use target_path
|
73
|
+
# Use target_path when the url starts with the iri of the resource, so a route can be generated.
|
76
74
|
# @option opts [string] :target_path The path appended to the iri of the resource to determine
|
77
75
|
# the url whereto the request will be made. A route is automatically generated.
|
78
76
|
# Defaults to the action key
|
79
|
-
# @option opts [hash] :target_query The query appended to the iri of the resource to determine
|
80
77
|
# @option opts [array<RDF::URI>, RDF::URI] :type The rdf type of the action.
|
81
78
|
# Defaults to schema.UpdateAction
|
82
79
|
def has_action(type, action_key, opts)
|
@@ -17,8 +17,8 @@ module LinkedRails
|
|
17
17
|
def create_collection_options(**overwrite)
|
18
18
|
default_create_options(
|
19
19
|
form: -> { resource.association_class.try(:form_class) },
|
20
|
-
object: -> { resource.
|
21
|
-
policy: :
|
20
|
+
object: -> { resource.build_child },
|
21
|
+
policy: :create_child?
|
22
22
|
).merge(overwrite)
|
23
23
|
end
|
24
24
|
|