linked_rails 0.0.3 → 0.0.4.pre.g3e8f5731a

Sign up to get free protection for your applications and to get access to all the features.
Files changed (181) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +21 -674
  3. data/app/controllers/linked_rails/actions/objects_controller.rb +9 -0
  4. data/app/controllers/linked_rails/bulk_controller.rb +107 -22
  5. data/app/controllers/linked_rails/enum_values_controller.rb +0 -42
  6. data/app/models/linked_rails/actions/item.rb +64 -55
  7. data/app/models/linked_rails/actions/list.rb +6 -31
  8. data/app/models/linked_rails/actions/object.rb +38 -0
  9. data/app/models/linked_rails/collection/configuration.rb +55 -0
  10. data/app/models/linked_rails/collection/filter.rb +1 -1
  11. data/app/models/linked_rails/collection/filter_field.rb +19 -2
  12. data/app/models/linked_rails/collection/filter_option.rb +1 -1
  13. data/app/models/linked_rails/collection/filterable.rb +6 -9
  14. data/app/models/linked_rails/collection/infinite.rb +113 -0
  15. data/app/models/linked_rails/collection/infinite_view.rb +1 -90
  16. data/app/models/linked_rails/collection/iri.rb +47 -43
  17. data/app/models/linked_rails/collection/iri_mapping.rb +15 -7
  18. data/app/models/linked_rails/collection/paginated.rb +46 -0
  19. data/app/models/linked_rails/collection/paginated_view.rb +1 -33
  20. data/app/models/linked_rails/collection/sortable.rb +1 -9
  21. data/app/models/linked_rails/collection/sorting.rb +1 -1
  22. data/app/models/linked_rails/collection/view.rb +53 -15
  23. data/app/models/linked_rails/collection.rb +53 -85
  24. data/app/models/linked_rails/creative_work.rb +1 -1
  25. data/app/models/linked_rails/entry_point.rb +8 -5
  26. data/app/models/linked_rails/enum_value.rb +40 -2
  27. data/app/models/linked_rails/form/field/association_input.rb +7 -1
  28. data/app/models/linked_rails/form/field/file_input.rb +1 -0
  29. data/app/models/linked_rails/form/field/resource_field.rb +2 -0
  30. data/{lib/linked_rails/enhancements/indexable/model.rb → app/models/linked_rails/form/field/url_input.rb} +3 -3
  31. data/app/models/linked_rails/form/field.rb +37 -13
  32. data/app/models/linked_rails/form/field_factory.rb +48 -18
  33. data/app/models/linked_rails/form/group.rb +4 -6
  34. data/app/models/linked_rails/form/page.rb +8 -4
  35. data/app/models/linked_rails/form.rb +17 -21
  36. data/app/models/linked_rails/manifest.rb +102 -22
  37. data/app/models/linked_rails/menus/item.rb +10 -13
  38. data/app/models/linked_rails/menus/list.rb +16 -7
  39. data/app/models/linked_rails/ontology/base.rb +3 -1
  40. data/app/models/linked_rails/ontology/class.rb +3 -3
  41. data/app/models/linked_rails/ontology.rb +6 -5
  42. data/app/models/linked_rails/property_query.rb +2 -0
  43. data/app/models/linked_rails/sequence.rb +4 -13
  44. data/app/models/linked_rails/shacl/property_shape.rb +1 -1
  45. data/app/models/linked_rails/web_page.rb +0 -4
  46. data/app/models/linked_rails/web_site.rb +0 -4
  47. data/app/models/linked_rails/widget.rb +4 -11
  48. data/app/policies/linked_rails/actions/object_policy.rb +11 -0
  49. data/app/policies/linked_rails/collection_policy.rb +2 -2
  50. data/app/policies/linked_rails/form_policy.rb +13 -0
  51. data/app/policies/linked_rails/ontology_policy.rb +13 -0
  52. data/app/serializers/linked_rails/actions/item_serializer.rb +5 -5
  53. data/app/serializers/linked_rails/actions/object_serializer.rb +9 -0
  54. data/app/serializers/linked_rails/collection/filter_field_serializer.rb +3 -2
  55. data/app/serializers/linked_rails/collection/filter_option_serializer.rb +1 -1
  56. data/app/serializers/linked_rails/collection/filter_serializer.rb +1 -1
  57. data/app/serializers/linked_rails/collection/sorting_serializer.rb +1 -1
  58. data/app/serializers/linked_rails/collection/view_serializer.rb +3 -3
  59. data/app/serializers/linked_rails/collection_serializer.rb +8 -7
  60. data/app/serializers/linked_rails/condition_serializer.rb +3 -3
  61. data/app/serializers/linked_rails/entry_point_serializer.rb +3 -3
  62. data/app/serializers/linked_rails/enum_value_serializer.rb +1 -0
  63. data/app/serializers/linked_rails/form/field/association_input_serializer.rb +1 -0
  64. data/app/serializers/linked_rails/form/field/file_input_serializer.rb +11 -0
  65. data/app/serializers/linked_rails/form/field_serializer.rb +3 -1
  66. data/app/serializers/linked_rails/form/group_serializer.rb +1 -1
  67. data/app/serializers/linked_rails/form/page_serializer.rb +1 -1
  68. data/app/serializers/linked_rails/menus/item_serializer.rb +3 -3
  69. data/app/serializers/linked_rails/menus/list_serializer.rb +1 -1
  70. data/app/serializers/linked_rails/ontology_serializer.rb +2 -2
  71. data/app/serializers/linked_rails/property_query_serializer.rb +7 -0
  72. data/app/serializers/linked_rails/sequence_serializer.rb +2 -5
  73. data/app/serializers/linked_rails/shacl/node_shape_serializer.rb +1 -1
  74. data/app/serializers/linked_rails/shacl/property_shape_serializer.rb +1 -1
  75. data/app/serializers/linked_rails/shacl/shape_serializer.rb +5 -5
  76. data/app/serializers/linked_rails/web_page_serializer.rb +3 -3
  77. data/app/serializers/linked_rails/web_site_serializer.rb +1 -1
  78. data/app/serializers/linked_rails/widget_serializer.rb +3 -3
  79. data/app/workers/linked_rails/invalidation_stream_worker.rb +16 -0
  80. data/lib/generators/linked_rails/install/install_generator.rb +5 -8
  81. data/lib/generators/linked_rails/install/templates/README +2 -0
  82. data/lib/generators/linked_rails/install/templates/app_menu_list.rb +36 -7
  83. data/lib/generators/linked_rails/install/templates/application_menu_list.rb +40 -1
  84. data/lib/generators/linked_rails/install/templates/initializer.rb +1 -2
  85. data/lib/generators/linked_rails/install/templates/locales.yml +16 -0
  86. data/lib/generators/linked_rails/install/templates/rdf_serializers_initializer.rb +1 -1
  87. data/lib/generators/linked_rails/install/templates/vocab.rb +1 -0
  88. data/lib/generators/linked_rails/install/templates/vocab.yml +2 -2
  89. data/lib/generators/linked_rails/model/model_generator.rb +0 -1
  90. data/lib/generators/linked_rails/model/templates/controller.rb.tt +5 -1
  91. data/lib/generators/linked_rails/model/templates/form.rb.tt +3 -0
  92. data/lib/generators/linked_rails/model/templates/menu_list.rb.tt +15 -0
  93. data/lib/generators/linked_rails/model/templates/policy.rb.tt +13 -0
  94. data/lib/generators/linked_rails/model/templates/serializer.rb.tt +5 -1
  95. data/lib/linked_rails/active_response/controller/collections.rb +1 -1
  96. data/lib/linked_rails/active_response/controller/crud_defaults.rb +4 -4
  97. data/lib/linked_rails/active_response/controller/params.rb +10 -10
  98. data/lib/linked_rails/active_response/controller.rb +8 -18
  99. data/lib/linked_rails/active_response/responders/rdf.rb +19 -10
  100. data/lib/linked_rails/callable_variable.rb +1 -1
  101. data/lib/linked_rails/collection_params_parser.rb +93 -0
  102. data/lib/linked_rails/controller/actionable.rb +121 -0
  103. data/lib/linked_rails/controller/authorization.rb +6 -0
  104. data/lib/linked_rails/controller/default_actions/create.rb +52 -0
  105. data/lib/linked_rails/controller/default_actions/destroy.rb +42 -0
  106. data/lib/linked_rails/controller/default_actions/update.rb +43 -0
  107. data/lib/linked_rails/controller/delta.rb +58 -0
  108. data/lib/linked_rails/controller/error_handling.rb +12 -7
  109. data/lib/linked_rails/controller/rendering.rb +48 -0
  110. data/lib/linked_rails/controller.rb +24 -4
  111. data/lib/linked_rails/enhancements/creatable/controller.rb +1 -1
  112. data/lib/linked_rails/enhancements/destroyable/controller.rb +1 -1
  113. data/lib/linked_rails/enhancements/updatable/controller.rb +1 -1
  114. data/lib/linked_rails/enhancements.rb +0 -16
  115. data/lib/linked_rails/errors/forbidden.rb +37 -0
  116. data/lib/linked_rails/errors.rb +3 -0
  117. data/lib/linked_rails/helpers/delta_helper.rb +26 -57
  118. data/lib/linked_rails/helpers/ontola_actions_helper.rb +2 -2
  119. data/lib/linked_rails/helpers/resource_helper.rb +14 -2
  120. data/lib/linked_rails/iri_mapper.rb +18 -40
  121. data/lib/linked_rails/middleware/error_handling.rb +51 -0
  122. data/lib/linked_rails/middleware/linked_data_params.rb +30 -151
  123. data/lib/linked_rails/model/actionable.rb +68 -0
  124. data/lib/linked_rails/model/cacheable.rb +45 -0
  125. data/lib/linked_rails/model/collections.rb +201 -39
  126. data/lib/linked_rails/model/dirty.rb +6 -18
  127. data/lib/linked_rails/model/enhancements.rb +1 -6
  128. data/lib/linked_rails/model/filtering.rb +4 -6
  129. data/lib/linked_rails/model/indexable.rb +6 -16
  130. data/lib/linked_rails/model/iri.rb +29 -19
  131. data/lib/linked_rails/model/iri_mapping.rb +37 -8
  132. data/lib/linked_rails/model/menuable.rb +28 -0
  133. data/lib/linked_rails/model/serialization.rb +2 -15
  134. data/lib/linked_rails/model/singularable.rb +57 -0
  135. data/lib/linked_rails/model/sorting.rb +0 -5
  136. data/lib/linked_rails/model/tables.rb +26 -0
  137. data/lib/linked_rails/model.rb +18 -7
  138. data/lib/linked_rails/params_parser.rb +131 -54
  139. data/lib/linked_rails/policy/attribute_conditions.rb +2 -2
  140. data/lib/linked_rails/policy.rb +44 -46
  141. data/lib/linked_rails/railtie.rb +11 -0
  142. data/lib/linked_rails/rdf_error.rb +2 -2
  143. data/lib/linked_rails/renderers.rb +1 -0
  144. data/lib/linked_rails/routes.rb +38 -22
  145. data/lib/linked_rails/serializer/actionable.rb +27 -0
  146. data/lib/linked_rails/serializer/menuable.rb +31 -0
  147. data/lib/linked_rails/serializer/singularable.rb +26 -0
  148. data/lib/linked_rails/serializer.rb +28 -11
  149. data/lib/linked_rails/storage.rb +32 -0
  150. data/lib/linked_rails/test_methods.rb +114 -0
  151. data/lib/linked_rails/translate.rb +31 -9
  152. data/lib/linked_rails/types/iri_type.rb +37 -0
  153. data/lib/linked_rails/uri_template.rb +30 -0
  154. data/lib/linked_rails/url.rb +11 -0
  155. data/lib/linked_rails/version.rb +1 -1
  156. data/lib/linked_rails/vocab.rb +9 -0
  157. data/lib/linked_rails.rb +40 -14
  158. data/lib/rails/welcome_controller.rb +3 -3
  159. data/lib/rdf/list.rb +9 -0
  160. data/lib/rdf/query_fix.rb +15 -0
  161. metadata +79 -33
  162. data/app/models/linked_rails/actions/default_actions/create.rb +0 -60
  163. data/app/models/linked_rails/actions/default_actions/destroy.rb +0 -45
  164. data/app/models/linked_rails/actions/default_actions/update.rb +0 -50
  165. data/app/models/linked_rails/actions/default_actions.rb +0 -17
  166. data/lib/generators/linked_rails/install/templates/application_action_list.rb +0 -3
  167. data/lib/generators/linked_rails/model/templates/action_list.rb.tt +0 -6
  168. data/lib/linked_rails/enhancements/actionable/model.rb +0 -71
  169. data/lib/linked_rails/enhancements/actionable/serializer.rb +0 -25
  170. data/lib/linked_rails/enhancements/creatable/action.rb +0 -15
  171. data/lib/linked_rails/enhancements/destroyable/action.rb +0 -15
  172. data/lib/linked_rails/enhancements/destroyable/routing.rb +0 -19
  173. data/lib/linked_rails/enhancements/menuable/model.rb +0 -36
  174. data/lib/linked_rails/enhancements/menuable/serializer.rb +0 -33
  175. data/lib/linked_rails/enhancements/route_concerns.rb +0 -56
  176. data/lib/linked_rails/enhancements/singularable/controller.rb +0 -43
  177. data/lib/linked_rails/enhancements/singularable/model.rb +0 -47
  178. data/lib/linked_rails/enhancements/singularable/serializer.rb +0 -28
  179. data/lib/linked_rails/enhancements/tableable/model.rb +0 -28
  180. data/lib/linked_rails/enhancements/updatable/action.rb +0 -15
  181. data/lib/linked_rails/enhancements/updatable/routing.rb +0 -20
@@ -2,6 +2,8 @@
2
2
 
3
3
  module LinkedRails
4
4
  class PropertyQuery < SHACL::PropertyShape
5
+ attr_accessor :force_render
6
+
5
7
  class << self
6
8
  def iri
7
9
  Vocab.ontola[:PropertyQuery]
@@ -2,11 +2,10 @@
2
2
 
3
3
  module LinkedRails
4
4
  class Sequence
5
- attr_accessor :node, :member_includes, :parent, :raw_members, :scope, :user_context
5
+ attr_accessor :node, :parent, :raw_members, :scope, :user_context
6
6
  alias read_attribute_for_serialization send
7
7
 
8
- def initialize(members, opts = {})
9
- self.member_includes = opts[:member_includes]
8
+ def initialize(members, **opts)
10
9
  self.node = opts[:id] || RDF::Node.new
11
10
  self.parent = opts[:parent]
12
11
  self.raw_members = members
@@ -14,7 +13,7 @@ module LinkedRails
14
13
  self.user_context = opts[:user_context]
15
14
  end
16
15
 
17
- def iri(_opts = {})
16
+ def iri(**_opts)
18
17
  node
19
18
  end
20
19
  alias id iri
@@ -26,21 +25,13 @@ module LinkedRails
26
25
  end
27
26
 
28
27
  def preview_includes
29
- [members: member_includes]
28
+ [:members]
30
29
  end
31
30
 
32
31
  def rdf_type
33
32
  self.class.iri
34
33
  end
35
34
 
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
-
44
35
  private
45
36
 
46
37
  def apply_scope(association)
@@ -35,7 +35,7 @@ module LinkedRails
35
35
  )
36
36
  attr_writer :has_value, :sh_in
37
37
 
38
- def has_value # rubocop:disable Naming/PredicateName
38
+ def has_value
39
39
  @has_value.respond_to?(:call) ? @has_value.call : @has_value
40
40
  end
41
41
 
@@ -13,10 +13,6 @@ module LinkedRails
13
13
  def iri
14
14
  Vocab.schema.WebPage
15
15
  end
16
-
17
- def preview_includes
18
- super + [:includes, widget_sequence: {members: LinkedRails::Widget.preview_includes}]
19
- end
20
16
  end
21
17
  end
22
18
  end
@@ -8,10 +8,6 @@ module LinkedRails
8
8
  def iri
9
9
  Vocab.schema.WebSite
10
10
  end
11
-
12
- def preview_includes
13
- super + [homepage: LinkedRails::WebPage.preview_includes]
14
- end
15
11
  end
16
12
  end
17
13
  end
@@ -8,7 +8,7 @@ module LinkedRails
8
8
  attr_writer :resources, :size
9
9
  attr_accessor :parent, :topology
10
10
 
11
- def iri(_opts = {})
11
+ def iri(**_opts)
12
12
  @iri ||= RDF::Node.new
13
13
  end
14
14
 
@@ -19,12 +19,9 @@ module LinkedRails
19
19
  end
20
20
 
21
21
  def resource_sequence
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
- )
22
+ @resource_sequence ||= @resources.map do |iri, predicate|
23
+ predicate.present? ? property_shape(iri, predicate) : RDF::URI(iri)
24
+ end
28
25
  end
29
26
 
30
27
  def size
@@ -46,10 +43,6 @@ module LinkedRails
46
43
  def iri
47
44
  Vocab.ontola[:Widget]
48
45
  end
49
-
50
- def preview_includes
51
- %i[resource_sequence property_shapes]
52
- end
53
46
  end
54
47
  end
55
48
  end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LinkedRails
4
+ module Actions
5
+ class ObjectPolicy < LinkedRails.policy_parent_class
6
+ def show?
7
+ parent_policy.blank? ? true : parent_policy.show?
8
+ end
9
+ end
10
+ end
11
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module LinkedRails
4
4
  class CollectionPolicy < LinkedRails.policy_parent_class
5
- delegate :permitted_attributes, to: :child_policy
5
+ delegate :permitted_attributes, :permitted_attributes_from_filters, 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.build_child
32
+ record.child_resource
33
33
  end
34
34
 
35
35
  def parent_policy
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LinkedRails
4
+ class FormPolicy < LinkedRails.policy_parent_class
5
+ def show?
6
+ true
7
+ end
8
+
9
+ def public_resource?
10
+ true
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LinkedRails
4
+ class OntologyPolicy < LinkedRails.policy_parent_class
5
+ def show?
6
+ true
7
+ end
8
+
9
+ def public_resource?
10
+ true
11
+ end
12
+ end
13
+ end
@@ -12,17 +12,17 @@ module LinkedRails
12
12
  end
13
13
  attribute :action_status, predicate: Vocab.schema.actionStatus
14
14
  attribute :favorite, predicate: Vocab.ontola[:favoriteAction]
15
- attribute :url, predicate: Vocab.schema.url do |object|
15
+ attribute :one_click, predicate: Vocab.ontola[:oneClick]
16
+ attribute :target_url, predicate: Vocab.schema.url do |object|
16
17
  object.target[:id] if object.target.is_a?(Hash)
17
18
  end
18
19
  attribute :error, predicate: Vocab.schema.error
19
20
 
20
- has_one :parent, predicate: Vocab.schema.isPartOf, polymorphic: true do |object|
21
+ has_one :parent, predicate: Vocab.schema.isPartOf do |object|
21
22
  object.parent unless object.parent.try(:anonymous_iri?)
22
23
  end
23
- has_one :object, predicate: Vocab.schema.object, polymorphic: true
24
- has_one :target, predicate: Vocab.schema.target, polymorphic: true
25
- has_one :included_object, polymorphic: true
24
+ attribute :object_iri, predicate: Vocab.schema.object
25
+ has_one :target, predicate: Vocab.schema.target
26
26
  end
27
27
  end
28
28
  end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LinkedRails
4
+ module Actions
5
+ class ObjectSerializer < LinkedRails.serializer_parent_class
6
+ has_one :object, predicate: Vocab.owl.sameAs
7
+ end
8
+ end
9
+ end
@@ -5,8 +5,9 @@ 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
- has_one :collection, predicate: Vocab.schema.isPartOf, polymorphic: true
9
- has_many :options, predicate: Vocab.ontola[:filterOptions], polymorphic: true
8
+ attribute :visible?, predicate: Vocab.ontola[:visible]
9
+ has_one :collection, predicate: Vocab.schema.isPartOf
10
+ has_many :options, predicate: Vocab.ontola[:filterOptions]
10
11
  end
11
12
  end
12
13
  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], polymorphic: true
9
+ has_one :collection, predicate: Vocab.schema[:isPartOf]
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, polymorphic: true
10
+ has_one :collection, predicate: Vocab.schema.isPartOf
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, polymorphic: true
10
+ has_one :collection, predicate: Vocab.schema.isPartOf
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, polymorphic: true
18
- has_one :unfiltered_collection, predicate: Vocab.ontola[:baseCollection], polymorphic: true
19
- has_one :member_sequence, predicate: Vocab.as.items, polymorphic: true
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
20
20
  end
21
21
  end
22
22
  end
@@ -11,12 +11,13 @@ 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 :iri_template, predicate: Vocab.ontola[:iriTemplate]
14
+ attribute :serialized_iri_template, predicate: Vocab.ontola[:iriTemplate]
15
15
  attribute :iri_template_opts, predicate: Vocab.ontola[:iriTemplateOpts]
16
16
  attribute :default_type, predicate: Vocab.ontola[:defaultType], &:type
17
17
  attribute :display, predicate: Vocab.ontola[:collectionDisplay] do |object|
18
18
  Vocab.ontola["collectionDisplay/#{object.display || :default}"]
19
19
  end
20
+ attribute :call_to_action, predicate: Vocab.ontola[:callToAction]
20
21
  attribute :columns, predicate: Vocab.ontola[:columns]
21
22
  attribute :collection_type, predicate: Vocab.ontola[:collectionType] do |object|
22
23
  Vocab.ontola["collectionType/#{object.type || :paginated}"]
@@ -25,17 +26,17 @@ module LinkedRails
25
26
  attribute :sort_options, predicate: Vocab.ontola[:sortOptions]
26
27
  attribute :view, predicate: Vocab.ll[:view]
27
28
 
28
- has_one :unfiltered_collection, predicate: Vocab.ontola[:baseCollection], polymorphic: true
29
- has_one :part_of, predicate: Vocab.schema.isPartOf, polymorphic: true do |object|
29
+ has_one :unfiltered_collection, predicate: Vocab.ontola[:baseCollection]
30
+ has_one :part_of, predicate: Vocab.schema.isPartOf do |object|
30
31
  object.part_of unless object.part_of.try(:anonymous_iri?)
31
32
  end
32
- has_one :default_view, predicate: Vocab.ontola[:pages], polymorphic: true
33
+ has_one :default_view, predicate: Vocab.ontola[:pages]
33
34
 
34
- has_many :filter_fields, predicate: Vocab.ontola[:filterFields], polymorphic: true, sequence: true
35
- has_many :filters, predicate: Vocab.ontola[:collectionFilter], polymorphic: true do |object|
35
+ has_many :filter_fields, predicate: Vocab.ontola[:filterFields], sequence: true
36
+ has_many :filters, predicate: Vocab.ontola[:activeFilters] do |object|
36
37
  object.filters.reject(&:default_filter)
37
38
  end
38
- has_many :sortings, polymorphic: true, predicate: Vocab.ontola[:collectionSorting]
39
+ has_many :sortings, predicate: Vocab.ontola[:collectionSorting]
39
40
 
40
41
  %i[first last].each do |attr|
41
42
  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], polymorphic: true
6
- has_one :pass, predicate: Vocab.ontola[:pass], polymorphic: true
7
- has_one :shape, predicate: Vocab.sh.node, polymorphic: true
5
+ has_one :fail, predicate: Vocab.ontola[:fail]
6
+ has_one :pass, predicate: Vocab.ontola[:pass]
7
+ has_one :shape, predicate: Vocab.sh.node
8
8
  end
9
9
  end
@@ -6,13 +6,13 @@ module LinkedRails
6
6
 
7
7
  attribute :label, predicate: Vocab.schema.name
8
8
  attribute :description, predicate: Vocab.schema.text
9
- attribute :url, predicate: Vocab.schema.url
9
+ attribute :target_url, predicate: Vocab.schema.url
10
10
  attribute :http_method, key: :method, predicate: Vocab.schema.httpMethod do |object|
11
11
  object.http_method.upcase
12
12
  end
13
13
 
14
- has_one :parent, predicate: Vocab.schema.isPartOf, polymorphic: true
15
- attribute :action_body, predicate: Vocab.ll[:actionBody], polymorphic: true
14
+ has_one :parent, predicate: Vocab.schema.isPartOf
15
+ attribute :action_body, predicate: Vocab.ll[:actionBody]
16
16
  attribute :image, predicate: Vocab.schema.image do |object|
17
17
  serialize_image(object.image)
18
18
  end
@@ -8,5 +8,6 @@ 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
11
12
  end
12
13
  end
@@ -7,6 +7,7 @@ module LinkedRails
7
7
  attribute :nested_form, predicate: Vocab.form[:form] do |object|
8
8
  object.nested_form.form_iri
9
9
  end
10
+ has_one :target_class, predicate: Vocab.sh.targetClass
10
11
  end
11
12
  end
12
13
  end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LinkedRails
4
+ class Form
5
+ class Field
6
+ class FileInputSerializer < FieldSerializer
7
+ attribute :max_size, predicate: Vocab.form[:maxFileSize]
8
+ end
9
+ end
10
+ end
11
+ end
@@ -5,7 +5,9 @@ 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.ontola[:helperText]
8
+ attribute :helper_text, predicate: Vocab.form[:helperText]
9
+ attribute :start_adornment, predicate: Vocab.form[:startAdornment]
10
+ attribute :placeholder, predicate: Vocab.form[:placeholder]
9
11
  attribute :default_value, predicate: Vocab.form[:defaultValue]
10
12
 
11
13
  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, polymorphic: true
11
+ has_many :fields, predicate: Vocab.form[:fields], sequence: 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, predicate: Vocab.form[:footerGroup], serializer: Form::GroupSerializer
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], polymorphic: true do |object|
16
+ has_one :action, predicate: Vocab.ontola[:action] 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) }, polymorphic: true
24
- has_one :resource, predicate: Vocab.schema.isPartOf, 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
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], polymorphic: true do |object|
8
+ has_many :menus, predicate: Vocab.ontola[:menus] do |object|
9
9
  object.menus&.compact
10
10
  end
11
11
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module LinkedRails
4
4
  class OntologySerializer < LinkedRails.serializer_parent_class
5
- has_many :classes
6
- has_many :properties
5
+ has_many :classes, serializer: LinkedRails::Ontology::ClassSerializer
6
+ has_many :properties, serializer: LinkedRails::Ontology::PropertySerializer
7
7
  end
8
8
  end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LinkedRails
4
+ class PropertyQuerySerializer < SHACL::PropertyShapeSerializer
5
+ attribute :force_render, predicate: Vocab.ll[:forceRender]
6
+ end
7
+ end
@@ -4,11 +4,8 @@ module LinkedRails
4
4
  class SequenceSerializer < LinkedRails.serializer_parent_class
5
5
  include LinkedRails::Serializer
6
6
 
7
- statements :sequence
8
- has_many :members, polymorphic: true
9
-
10
- def self.sequence(object, _params)
11
- object.sequence
7
+ has_many :members, predicate: ->(relationship, index) do
8
+ RDF["_#{index}"]
12
9
  end
13
10
  end
14
11
  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, polymorphic: true
9
+ has_many :property, predicate: Vocab.sh.property
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, polymorphic: true
35
+ has_many :path, predicate: Vocab.sh.path, sequence: 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, 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|
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|
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], polymorphic: true
6
- has_one :widget_sequence, predicate: Vocab.ontola[:widgets], polymorphic: true
7
- has_many :includes, polymorphic: true
5
+ has_one :cover_photo, predicate: Vocab.ontola[:coverPhoto]
6
+ has_one :widget_sequence, predicate: Vocab.ontola[:widgets]
7
+ has_many :includes
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, polymorphic: true
5
+ has_one :homepage, predicate: Vocab.foaf.homepage
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 :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|
9
+ has_one :parent, predicate: Vocab.schema.isPartOf
10
+ has_many :resource_sequence, predicate: Vocab.ontola[:widgetResource], sequence: true
11
+ has_many :property_shapes do |object|
12
12
  object.property_shapes.values
13
13
  end
14
14
  end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LinkedRails
4
+ class InvalidationStreamWorker < ActiveJob::Base
5
+ def perform(type, iri, resource_type)
6
+ entry = {
7
+ type: type,
8
+ resource: iri,
9
+ resourceType: resource_type
10
+ }
11
+ id = Storage.xadd(:stream, LinkedRails.cache_stream, entry)
12
+
13
+ raise('No message id returned, implies failure') if id.blank?
14
+ end
15
+ end
16
+ end
@@ -12,7 +12,6 @@ module LinkedRails
12
12
  def install # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
13
13
  template 'vocab.rb', 'lib/vocab.rb'
14
14
  template 'initializer.rb', 'config/initializers/linked_rails.rb'
15
- template 'application_action_list.rb', 'app/actions/application_action_list.rb'
16
15
  template 'application_form.rb', 'app/forms/application_form.rb'
17
16
  template 'application_menu_list.rb', 'app/menus/application_menu_list.rb'
18
17
  template 'application_policy.rb', 'app/policies/application_policy.rb'
@@ -22,9 +21,12 @@ module LinkedRails
22
21
  template 'rdf_serializers_initializer.rb', 'config/initializers/rdf_serializers.rb'
23
22
  template 'locales.yml', 'config/locales/linked_rails.en.yml'
24
23
  template 'vocab.yml', 'config/locales/vocab.en.yml'
24
+ route 'find_tenant_route'
25
25
  route 'use_linked_rails'
26
26
  application 'config.middleware.use LinkedRails::Middleware::LinkedDataParams'
27
27
  application 'config.jwt_encryption_method = :hs512'
28
+ gsub_file('config/environments/development.rb', 'config.eager_load = false', 'config.eager_load = true')
29
+ gsub_file('config/environments/development.rb', 'config.cache_classes = false', 'config.cache_classes = true')
28
30
  inject_includes
29
31
 
30
32
  readme 'README'
@@ -37,17 +39,12 @@ module LinkedRails
37
39
  inject_model_include
38
40
  end
39
41
 
40
- def inject_controller_include# rubocop:disable Metrics/MethodLength
42
+ def inject_controller_include
41
43
  sentinel = /class ApplicationController < ActionController::API\n/m
42
44
  in_root do
43
45
  inject_into_file(
44
46
  'app/controllers/application_controller.rb',
45
- optimize_indentation(
46
- "include ActionController::MimeResponds\n"\
47
- "include ActiveResponse::Controller\n"\
48
- 'include LinkedRails::Controller',
49
- 2
50
- ),
47
+ optimize_indentation('include LinkedRails::Controller', 2),
51
48
  after: sentinel
52
49
  )
53
50
  end
@@ -2,4 +2,6 @@ Add the following to config/development.rb
2
2
  config.hosts = []
3
3
  config.hosts << 'localhost'
4
4
  config.hosts << '.svc.cluster.local'
5
+ config.hosts << [YOUR_LOCAL_HOSTNAME]
5
6
 
7
+ And update the host in config/initializers/linked_rails.rb