alchemy-json_api 1.2.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/alchemy/json_api/pages_controller.rb +0 -1
- data/app/models/alchemy/json_api/page.rb +6 -0
- data/app/serializers/alchemy/json_api/element_serializer.rb +0 -4
- data/lib/alchemy/json_api/version.rb +1 -1
- metadata +7 -21
- data/app/serializers/alchemy/json_api/essence_audio_serializer.rb +0 -40
- data/app/serializers/alchemy/json_api/essence_boolean_serializer.rb +0 -10
- data/app/serializers/alchemy/json_api/essence_date_serializer.rb +0 -10
- data/app/serializers/alchemy/json_api/essence_file_serializer.rb +0 -32
- data/app/serializers/alchemy/json_api/essence_headline_serializer.rb +0 -13
- data/app/serializers/alchemy/json_api/essence_html_serializer.rb +0 -10
- data/app/serializers/alchemy/json_api/essence_link_serializer.rb +0 -14
- data/app/serializers/alchemy/json_api/essence_node_serializer.rb +0 -34
- data/app/serializers/alchemy/json_api/essence_page_serializer.rb +0 -24
- data/app/serializers/alchemy/json_api/essence_picture_serializer.rb +0 -78
- data/app/serializers/alchemy/json_api/essence_richtext_serializer.rb +0 -15
- data/app/serializers/alchemy/json_api/essence_select_serializer.rb +0 -10
- data/app/serializers/alchemy/json_api/essence_text_serializer.rb +0 -16
- data/app/serializers/alchemy/json_api/essence_video_serializer.rb +0 -42
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 529c7f7ab8ebaaf065cfdaf1e25441ef1453c5e179a10cd6e40caefdbbe58f1a
|
4
|
+
data.tar.gz: 6761266d21e3d9bba7678f86edc9f8372850845880ec8030c98d91d74752f8cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8335a8178b3ffdffa04a7b4c637248387cf3b625d7e7b6db7ce02fc95faf456fd61a7ebd052af1c96accb5fce206e6c005c69a365c871ac5707b86a64fa37902
|
7
|
+
data.tar.gz: ed1ee154159e7b67262999db7539791b1b904ab860846042421a4f2e04a1e8f21643096adb9d5ddf478f73572da699323192628b204fdfd5cb523973175c4398
|
@@ -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
|
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:
|
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: 2023-
|
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:
|
20
|
+
version: 7.0.0.a
|
21
21
|
- - "<"
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: '
|
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:
|
30
|
+
version: 7.0.0.a
|
31
31
|
- - "<"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
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.
|
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,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,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,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
|