alchemy-json_api 1.1.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4897ce550da94a8b74c4facbba769effd9bc3876f72f12b722535276fbcd9212
4
- data.tar.gz: 69b8719ccfb637efdaf4dae98a2e20d42add379dcd186792cf9be1c042dcb6a9
3
+ metadata.gz: 529c7f7ab8ebaaf065cfdaf1e25441ef1453c5e179a10cd6e40caefdbbe58f1a
4
+ data.tar.gz: 6761266d21e3d9bba7678f86edc9f8372850845880ec8030c98d91d74752f8cd
5
5
  SHA512:
6
- metadata.gz: d2cd8b9d1bb8ad595167a76340bfbe728b13ae1f5bd8f3838025d0d0db2d522dc8ed57947d56bb62673694ae6012fdb205ae55f35122372f729c2c4ae279c642
7
- data.tar.gz: 8ad2b9ffb2adf5143b2329f62fe8bddc9cbcb1cc0f2920462d5782f09d604354e53d58a5622f039fdbc0b551086cc77c93d6d4f96731dd706467dde61ea4a657
6
+ metadata.gz: 8335a8178b3ffdffa04a7b4c637248387cf3b625d7e7b6db7ce02fc95faf456fd61a7ebd052af1c96accb5fce206e6c005c69a365c871ac5707b86a64fa37902
7
+ data.tar.gz: ed1ee154159e7b67262999db7539791b1b904ab860846042421a4f2e04a1e8f21643096adb9d5ddf478f73572da699323192628b204fdfd5cb523973175c4398
@@ -100,7 +100,6 @@ module Alchemy
100
100
  page_version_type => {
101
101
  elements: [
102
102
  :nested_elements,
103
- { contents: { essence: :ingredient_association } },
104
103
  { ingredients: :related_object },
105
104
  ],
106
105
  },
@@ -1,4 +1,10 @@
1
1
  module Alchemy
2
+ # With Ransack 4 we need to define the attributes
3
+ # that are allowed to be searched.
4
+ def Page.ransackable_attributes(_auth_object = nil)
5
+ %w[urlname page_layout]
6
+ end
7
+
2
8
  module JsonApi
3
9
  class Page < SimpleDelegator
4
10
  attr_reader :page_version_type, :page_version
@@ -16,10 +16,6 @@ module Alchemy
16
16
  !!element.definition[:deprecated]
17
17
  end
18
18
 
19
- has_many :essences, polymorphic: true do |element|
20
- element.contents.map(&:essence)
21
- end
22
-
23
19
  has_many :ingredients,
24
20
  serializer: ->(record) do
25
21
  "Alchemy::JsonApi::Ingredient#{record.type.demodulize}Serializer".constantize
@@ -8,6 +8,11 @@ module Alchemy
8
8
  include IngredientSerializer
9
9
 
10
10
  attributes :level, :size
11
+
12
+ # Introduced in Alchemy 6.1
13
+ if Alchemy::Ingredients::Headline.stored_attributes[:data].include?(:dom_id)
14
+ attribute :dom_id
15
+ end
11
16
  end
12
17
  end
13
18
  end
@@ -17,6 +17,11 @@ module Alchemy
17
17
  # maintain compatibility with EssenceText
18
18
  attribute :body, &:value
19
19
  attribute :link_url, &:link
20
+
21
+ # Introduced in Alchemy 6.1
22
+ if Alchemy::Ingredients::Text.stored_attributes[:data].include?(:dom_id)
23
+ attribute :dom_id
24
+ end
20
25
  end
21
26
  end
22
27
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  module Alchemy
3
3
  module JsonApi
4
- VERSION = "1.1.1"
4
+ VERSION = "2.0.0"
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alchemy-json_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Meyerhoff
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-09-16 00:00:00.000000000 Z
12
+ date: 2023-03-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: alchemy_cms
@@ -17,20 +17,20 @@ dependencies:
17
17
  requirements:
18
18
  - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: 6.0.a
20
+ version: 7.0.0.a
21
21
  - - "<"
22
22
  - !ruby/object:Gem::Version
23
- version: '6.1'
23
+ version: '8'
24
24
  type: :runtime
25
25
  prerelease: false
26
26
  version_requirements: !ruby/object:Gem::Requirement
27
27
  requirements:
28
28
  - - ">="
29
29
  - !ruby/object:Gem::Version
30
- version: 6.0.a
30
+ version: 7.0.0.a
31
31
  - - "<"
32
32
  - !ruby/object:Gem::Version
33
- version: '6.1'
33
+ version: '8'
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: jsonapi.rb
36
36
  requirement: !ruby/object:Gem::Requirement
@@ -134,20 +134,6 @@ files:
134
134
  - app/models/alchemy/json_api/page.rb
135
135
  - app/serializers/alchemy/json_api/base_serializer.rb
136
136
  - app/serializers/alchemy/json_api/element_serializer.rb
137
- - app/serializers/alchemy/json_api/essence_audio_serializer.rb
138
- - app/serializers/alchemy/json_api/essence_boolean_serializer.rb
139
- - app/serializers/alchemy/json_api/essence_date_serializer.rb
140
- - app/serializers/alchemy/json_api/essence_file_serializer.rb
141
- - app/serializers/alchemy/json_api/essence_headline_serializer.rb
142
- - app/serializers/alchemy/json_api/essence_html_serializer.rb
143
- - app/serializers/alchemy/json_api/essence_link_serializer.rb
144
- - app/serializers/alchemy/json_api/essence_node_serializer.rb
145
- - app/serializers/alchemy/json_api/essence_page_serializer.rb
146
- - app/serializers/alchemy/json_api/essence_picture_serializer.rb
147
- - app/serializers/alchemy/json_api/essence_richtext_serializer.rb
148
- - app/serializers/alchemy/json_api/essence_select_serializer.rb
149
- - app/serializers/alchemy/json_api/essence_text_serializer.rb
150
- - app/serializers/alchemy/json_api/essence_video_serializer.rb
151
137
  - app/serializers/alchemy/json_api/ingredient_audio_serializer.rb
152
138
  - app/serializers/alchemy/json_api/ingredient_boolean_serializer.rb
153
139
  - app/serializers/alchemy/json_api/ingredient_datetime_serializer.rb
@@ -193,7 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
193
179
  - !ruby/object:Gem::Version
194
180
  version: '0'
195
181
  requirements: []
196
- rubygems_version: 3.3.7
182
+ rubygems_version: 3.4.6
197
183
  signing_key:
198
184
  specification_version: 4
199
185
  summary: A JSONAPI compliant API for AlchemyCMS
@@ -1,40 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "alchemy/json_api/essence_serializer"
4
-
5
- module Alchemy
6
- module JsonApi
7
- class EssenceAudioSerializer < BaseSerializer
8
- include EssenceSerializer
9
-
10
- attributes(
11
- :autoplay,
12
- :controls,
13
- :muted,
14
- :loop,
15
- )
16
-
17
- attribute :ingredient do |essence|
18
- essence.attachment&.url
19
- end
20
-
21
- with_options if: ->(essence) { essence.attachment } do
22
- attribute :audio_name do |essence|
23
- essence.attachment.name
24
- end
25
-
26
- attribute :audio_file_name do |essence|
27
- essence.attachment.file_name
28
- end
29
-
30
- attribute :audio_mime_type do |essence|
31
- essence.attachment.file_mime_type
32
- end
33
-
34
- attribute :audio_file_size do |essence|
35
- essence.attachment.file_size
36
- end
37
- end
38
- end
39
- end
40
- end
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
- require "alchemy/json_api/essence_serializer"
3
-
4
- module Alchemy
5
- module JsonApi
6
- class EssenceBooleanSerializer < BaseSerializer
7
- include EssenceSerializer
8
- end
9
- end
10
- end
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
- require "alchemy/json_api/essence_serializer"
3
-
4
- module Alchemy
5
- module JsonApi
6
- class EssenceDateSerializer < BaseSerializer
7
- include EssenceSerializer
8
- end
9
- end
10
- end
@@ -1,32 +0,0 @@
1
- # frozen_string_literal: true
2
- require "alchemy/json_api/essence_serializer"
3
-
4
- module Alchemy
5
- module JsonApi
6
- class EssenceFileSerializer < BaseSerializer
7
- include EssenceSerializer
8
-
9
- attribute :link_title, &:title
10
-
11
- attribute :ingredient, &:attachment_url
12
-
13
- with_options if: proc { |essence| essence.attachment.present? } do
14
- attribute :attachment_name do |essence|
15
- essence.attachment.name
16
- end
17
-
18
- attribute :attachment_file_name do |essence|
19
- essence.attachment.file_name
20
- end
21
-
22
- attribute :attachment_mime_type do |essence|
23
- essence.attachment.file_mime_type
24
- end
25
-
26
- attribute :attachment_file_size do |essence|
27
- essence.attachment.file_size
28
- end
29
- end
30
- end
31
- end
32
- end
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "alchemy/json_api/essence_serializer"
4
-
5
- module Alchemy
6
- module JsonApi
7
- class EssenceHeadlineSerializer < BaseSerializer
8
- include EssenceSerializer
9
-
10
- attributes :level, :size
11
- end
12
- end
13
- end
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
- require "alchemy/json_api/essence_serializer"
3
-
4
- module Alchemy
5
- module JsonApi
6
- class EssenceHtmlSerializer < BaseSerializer
7
- include EssenceSerializer
8
- end
9
- end
10
- end
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
- require "alchemy/json_api/essence_serializer"
3
-
4
- module Alchemy
5
- module JsonApi
6
- class EssenceLinkSerializer < BaseSerializer
7
- include EssenceSerializer
8
- attributes(
9
- :link_title,
10
- :link_target,
11
- )
12
- end
13
- end
14
- end
@@ -1,34 +0,0 @@
1
- # frozen_string_literal: true
2
- require "alchemy/json_api/essence_serializer"
3
-
4
- module Alchemy
5
- module JsonApi
6
- class EssenceNodeSerializer < BaseSerializer
7
- include EssenceSerializer
8
-
9
- attribute :ingredient do |essence|
10
- essence&.node&.name
11
- end
12
-
13
- belongs_to :node, record_type: :node, serializer: ::Alchemy::JsonApi::NodeSerializer
14
-
15
- with_options if: proc { |essence| essence.node.present? } do
16
- attribute :name do |essence|
17
- essence.node.name
18
- end
19
-
20
- attribute :link_url do |essence|
21
- essence.node.url
22
- end
23
-
24
- attribute :link_title do |essence|
25
- essence.node.title
26
- end
27
-
28
- attribute :link_nofollow do |essence|
29
- essence.node.nofollow
30
- end
31
- end
32
- end
33
- end
34
- end
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
- require "alchemy/json_api/essence_serializer"
3
-
4
- module Alchemy
5
- module JsonApi
6
- class EssencePageSerializer < BaseSerializer
7
- include EssenceSerializer
8
-
9
- attribute :ingredient do |essence|
10
- essence.page&.url_path
11
- end
12
-
13
- attribute :page_name do |essence|
14
- essence.page&.name
15
- end
16
-
17
- attribute :page_url do |essence|
18
- essence.page&.url_path
19
- end
20
-
21
- has_one :page, record_type: :page, serializer: ::Alchemy::JsonApi::PageSerializer
22
- end
23
- end
24
- end
@@ -1,78 +0,0 @@
1
- # frozen_string_literal: true
2
- require "alchemy/json_api/essence_serializer"
3
-
4
- module Alchemy
5
- module JsonApi
6
- class EssencePictureSerializer < BaseSerializer
7
- include EssenceSerializer
8
-
9
- attributes(
10
- :title,
11
- :caption,
12
- :link_title,
13
- :link_target,
14
- )
15
- attribute :ingredient, &:picture_url
16
- attribute :alt_text, &:alt_tag
17
- attribute :link_url, &:link
18
-
19
- with_options if: proc { |essence| essence.picture.present? } do
20
- attribute :image_dimensions do |essence|
21
- sizes = essence.content.settings[:size]&.split("x", 2)&.map(&:to_i) || [
22
- essence.image_file_width,
23
- essence.image_file_height,
24
- ]
25
-
26
- ratio = essence.image_file_width.to_f / essence.image_file_height
27
- width = sizes[0].zero? ? sizes[1] * ratio : sizes[0]
28
- height = sizes[1].zero? ? sizes[0] / ratio : sizes[1]
29
-
30
- {
31
- width: width,
32
- height: height,
33
- }
34
- end
35
-
36
- attribute :srcset do |essence|
37
- essence.content.settings.fetch(:srcset, []).map do |src|
38
- case src
39
- when Hash
40
- url = essence.picture_url(src)
41
- size = src[:size]
42
- type = Mime::Type.lookup_by_extension(src[:format] || essence.picture.default_render_format)
43
- else
44
- url = essence.picture_url(size: src)
45
- size = src
46
- type = Mime::Type.lookup_by_extension(essence.picture.default_render_format)
47
- end
48
- width, height = size.split("x", 2)
49
-
50
- {
51
- url: url,
52
- desc: "#{width}w",
53
- width: width,
54
- height: height,
55
- type: type.to_s,
56
- }
57
- end
58
- end
59
-
60
- attribute :image_name do |essence|
61
- essence.picture.name
62
- end
63
-
64
- attribute :image_file_name do |essence|
65
- essence.picture.image_file_name
66
- end
67
-
68
- attribute :image_mime_type do |essence|
69
- "image/#{essence.picture.image_file_format}"
70
- end
71
-
72
- attribute :image_file_size do |essence|
73
- essence.picture.image_file_size
74
- end
75
- end
76
- end
77
- end
78
- end
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
- require "alchemy/json_api/essence_serializer"
3
-
4
- module Alchemy
5
- module JsonApi
6
- class EssenceRichtextSerializer < BaseSerializer
7
- include EssenceSerializer
8
- attributes(
9
- :body,
10
- :sanitized_body,
11
- :stripped_body,
12
- )
13
- end
14
- end
15
- end
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
- require "alchemy/json_api/essence_serializer"
3
-
4
- module Alchemy
5
- module JsonApi
6
- class EssenceSelectSerializer < BaseSerializer
7
- include EssenceSerializer
8
- end
9
- end
10
- end
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
- require "alchemy/json_api/essence_serializer"
3
-
4
- module Alchemy
5
- module JsonApi
6
- class EssenceTextSerializer < BaseSerializer
7
- include EssenceSerializer
8
- attributes(
9
- :body,
10
- :link_title,
11
- :link_target,
12
- )
13
- attribute :link_url, &:link
14
- end
15
- end
16
- end
@@ -1,42 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "alchemy/json_api/essence_serializer"
4
-
5
- module Alchemy
6
- module JsonApi
7
- class EssenceVideoSerializer < BaseSerializer
8
- include EssenceSerializer
9
-
10
- attributes(
11
- :width,
12
- :height,
13
- :allow_fullscreen,
14
- :autoplay,
15
- :controls,
16
- :preload,
17
- )
18
-
19
- attribute :ingredient do |essence|
20
- essence.attachment&.url
21
- end
22
-
23
- with_options if: ->(essence) { essence.attachment } do
24
- attribute :video_name do |essence|
25
- essence.attachment.name
26
- end
27
-
28
- attribute :video_file_name do |essence|
29
- essence.attachment.file_name
30
- end
31
-
32
- attribute :video_mime_type do |essence|
33
- essence.attachment.file_mime_type
34
- end
35
-
36
- attribute :video_file_size do |essence|
37
- essence.attachment.file_size
38
- end
39
- end
40
- end
41
- end
42
- end