alchemy-json_api 0.3.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +8 -0
- data/app/controllers/alchemy/json_api/base_controller.rb +17 -0
- data/app/serializers/alchemy/json_api/element_serializer.rb +22 -18
- data/app/serializers/alchemy/json_api/essence_boolean_serializer.rb +5 -3
- data/app/serializers/alchemy/json_api/essence_date_serializer.rb +5 -3
- data/app/serializers/alchemy/json_api/essence_file_serializer.rb +19 -17
- data/app/serializers/alchemy/json_api/essence_html_serializer.rb +5 -3
- data/app/serializers/alchemy/json_api/essence_link_serializer.rb +9 -7
- data/app/serializers/alchemy/json_api/essence_node_serializer.rb +21 -19
- data/app/serializers/alchemy/json_api/essence_page_serializer.rb +15 -13
- data/app/serializers/alchemy/json_api/essence_picture_serializer.rb +29 -27
- data/app/serializers/alchemy/json_api/essence_richtext_serializer.rb +9 -7
- data/app/serializers/alchemy/json_api/essence_select_serializer.rb +5 -3
- data/app/serializers/alchemy/json_api/essence_text_serializer.rb +11 -9
- data/app/serializers/alchemy/json_api/page_serializer.rb +3 -2
- data/lib/alchemy/json_api/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 280355f5754df05ef965218bd9a35fb6f83b654dc534b2fce7cc903c47422fc2
|
4
|
+
data.tar.gz: 8ad2aa010faba09069bddb9d466d602d1dbc5c34ce052d82e96187c7bb2daa7b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80bd161a6f0b2ff1a9f5d393aad8f2d628a6177cf41443d23f0fa8638a66189600a9f43f71e3b7205ca94a9af00b937a0ecf7645e29ea512132a714fe1a4a6bb
|
7
|
+
data.tar.gz: a71c19f108eff5b51468687ad628173aa32e2e08e0b471c939582f289cea7009690451a7eff0e1a3c2e94724fbd5c52bcd0f4f70a449a80b4d6b3b10ba0a21c3
|
data/Rakefile
CHANGED
@@ -26,3 +26,11 @@ task :test_setup do
|
|
26
26
|
exit($?.exitstatus) unless $?.success?
|
27
27
|
end
|
28
28
|
end
|
29
|
+
|
30
|
+
require "github_changelog_generator/task"
|
31
|
+
require "alchemy/json_api/version"
|
32
|
+
GitHubChangelogGenerator::RakeTask.new(:changelog) do |config|
|
33
|
+
config.user = "AlchemyCMS"
|
34
|
+
config.project = "alchemy-json_api"
|
35
|
+
config.future_release = "v#{Alchemy::JsonApi::VERSION}"
|
36
|
+
end
|
@@ -7,6 +7,23 @@ module Alchemy
|
|
7
7
|
include JSONAPI::Errors
|
8
8
|
include JSONAPI::Filtering
|
9
9
|
include JSONAPI::Pagination
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def render_jsonapi_internal_server_error(exception)
|
14
|
+
log_error(exception)
|
15
|
+
super
|
16
|
+
end
|
17
|
+
|
18
|
+
def log_error(exception)
|
19
|
+
logger = Rails.logger
|
20
|
+
return unless logger
|
21
|
+
|
22
|
+
message = +"\n#{exception.class} (#{exception.message}):\n"
|
23
|
+
message << exception.annotated_source_code.to_s if exception.respond_to?(:annotated_source_code)
|
24
|
+
message << " " << exception.backtrace.join("\n ")
|
25
|
+
logger.fatal("#{message}\n\n")
|
26
|
+
end
|
10
27
|
end
|
11
28
|
end
|
12
29
|
end
|
@@ -1,25 +1,29 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
module Alchemy
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
2
|
+
module Alchemy
|
3
|
+
module JsonApi
|
4
|
+
class ElementSerializer
|
5
|
+
include FastJsonapi::ObjectSerializer
|
6
|
+
attributes(
|
7
|
+
:name,
|
8
|
+
:fixed,
|
9
|
+
:position,
|
10
|
+
:created_at,
|
11
|
+
:updated_at,
|
12
|
+
)
|
13
|
+
belongs_to :parent_element, record_type: :element, serializer: self
|
12
14
|
|
13
|
-
|
14
|
-
|
15
|
-
element
|
16
|
-
|
15
|
+
belongs_to :page, record_type: :page, serializer: PageSerializer
|
16
|
+
|
17
|
+
has_many :essences, polymorphic: true do |element|
|
18
|
+
element.contents.map(&:essence)
|
19
|
+
end
|
17
20
|
|
18
|
-
|
21
|
+
has_many :nested_elements, record_type: :element, serializer: self
|
19
22
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
+
with_options if: ->(_, params) { params[:admin] == true } do
|
24
|
+
attribute :tag_list
|
25
|
+
attribute :display_name, &:display_name_with_preview_text
|
26
|
+
end
|
23
27
|
end
|
24
28
|
end
|
25
29
|
end
|
@@ -1,8 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
require "alchemy/json_api/essence_serializer"
|
3
3
|
|
4
|
-
module Alchemy
|
5
|
-
|
6
|
-
|
4
|
+
module Alchemy
|
5
|
+
module JsonApi
|
6
|
+
class EssenceBooleanSerializer
|
7
|
+
include EssenceSerializer
|
8
|
+
end
|
7
9
|
end
|
8
10
|
end
|
@@ -1,8 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
require "alchemy/json_api/essence_serializer"
|
3
3
|
|
4
|
-
module Alchemy
|
5
|
-
|
6
|
-
|
4
|
+
module Alchemy
|
5
|
+
module JsonApi
|
6
|
+
class EssenceDateSerializer
|
7
|
+
include EssenceSerializer
|
8
|
+
end
|
7
9
|
end
|
8
10
|
end
|
@@ -1,29 +1,31 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
require "alchemy/json_api/essence_serializer"
|
3
3
|
|
4
|
-
module Alchemy
|
5
|
-
|
6
|
-
|
4
|
+
module Alchemy
|
5
|
+
module JsonApi
|
6
|
+
class EssenceFileSerializer
|
7
|
+
include EssenceSerializer
|
7
8
|
|
8
|
-
|
9
|
+
attribute :link_title, &:title
|
9
10
|
|
10
|
-
|
11
|
+
attribute :ingredient, &:attachment_url
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
with_options if: proc { |essence| essence.attachment.present? } do
|
14
|
+
attribute :attachment_name do |essence|
|
15
|
+
essence.attachment.name
|
16
|
+
end
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
18
|
+
attribute :attachment_file_name do |essence|
|
19
|
+
essence.attachment.file_name
|
20
|
+
end
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
|
22
|
+
attribute :attachment_mime_type do |essence|
|
23
|
+
essence.attachment.file_mime_type
|
24
|
+
end
|
24
25
|
|
25
|
-
|
26
|
-
|
26
|
+
attribute :attachment_file_size do |essence|
|
27
|
+
essence.attachment.file_size
|
28
|
+
end
|
27
29
|
end
|
28
30
|
end
|
29
31
|
end
|
@@ -1,8 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
require "alchemy/json_api/essence_serializer"
|
3
3
|
|
4
|
-
module Alchemy
|
5
|
-
|
6
|
-
|
4
|
+
module Alchemy
|
5
|
+
module JsonApi
|
6
|
+
class EssenceHtmlSerializer
|
7
|
+
include EssenceSerializer
|
8
|
+
end
|
7
9
|
end
|
8
10
|
end
|
@@ -1,12 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
require "alchemy/json_api/essence_serializer"
|
3
3
|
|
4
|
-
module Alchemy
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
4
|
+
module Alchemy
|
5
|
+
module JsonApi
|
6
|
+
class EssenceLinkSerializer
|
7
|
+
include EssenceSerializer
|
8
|
+
attributes(
|
9
|
+
:link_title,
|
10
|
+
:link_target,
|
11
|
+
)
|
12
|
+
end
|
11
13
|
end
|
12
14
|
end
|
@@ -1,31 +1,33 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
require "alchemy/json_api/essence_serializer"
|
3
3
|
|
4
|
-
module Alchemy
|
5
|
-
|
6
|
-
|
4
|
+
module Alchemy
|
5
|
+
module JsonApi
|
6
|
+
class EssenceNodeSerializer
|
7
|
+
include EssenceSerializer
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
9
|
+
attribute :ingredient do |essence|
|
10
|
+
essence&.node&.name
|
11
|
+
end
|
11
12
|
|
12
|
-
|
13
|
+
belongs_to :node, record_type: :node, serializer: NodeSerializer
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
with_options if: proc { |essence| essence.node.present? } do
|
16
|
+
attribute :name do |essence|
|
17
|
+
essence.node.name
|
18
|
+
end
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
20
|
+
attribute :link_url do |essence|
|
21
|
+
essence.node.url
|
22
|
+
end
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
|
24
|
+
attribute :link_title do |essence|
|
25
|
+
essence.node.title
|
26
|
+
end
|
26
27
|
|
27
|
-
|
28
|
-
|
28
|
+
attribute :link_nofollow do |essence|
|
29
|
+
essence.node.nofollow
|
30
|
+
end
|
29
31
|
end
|
30
32
|
end
|
31
33
|
end
|
@@ -1,22 +1,24 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
require "alchemy/json_api/essence_serializer"
|
3
3
|
|
4
|
-
module Alchemy
|
5
|
-
|
6
|
-
|
4
|
+
module Alchemy
|
5
|
+
module JsonApi
|
6
|
+
class EssencePageSerializer
|
7
|
+
include EssenceSerializer
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
9
|
+
attribute :ingredient do |essence|
|
10
|
+
essence.page&.url_path
|
11
|
+
end
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
13
|
+
attribute :page_name do |essence|
|
14
|
+
essence.page&.name
|
15
|
+
end
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
17
|
+
attribute :page_url do |essence|
|
18
|
+
essence.page&.url_path
|
19
|
+
end
|
19
20
|
|
20
|
-
|
21
|
+
has_one :page, record_type: :page, serializer: PageSerializer
|
22
|
+
end
|
21
23
|
end
|
22
24
|
end
|
@@ -1,39 +1,41 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
require "alchemy/json_api/essence_serializer"
|
3
3
|
|
4
|
-
module Alchemy
|
5
|
-
|
6
|
-
|
4
|
+
module Alchemy
|
5
|
+
module JsonApi
|
6
|
+
class EssencePictureSerializer
|
7
|
+
include EssenceSerializer
|
7
8
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
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
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
with_options if: proc { |essence| essence.picture.present? } do
|
20
|
+
attribute :image_dimensions do |essence|
|
21
|
+
essence.sizes_from_string(essence.render_size)
|
22
|
+
end
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
|
24
|
+
attribute :image_name do |essence|
|
25
|
+
essence.picture.name
|
26
|
+
end
|
26
27
|
|
27
|
-
|
28
|
-
|
29
|
-
|
28
|
+
attribute :image_file_name do |essence|
|
29
|
+
essence.picture.image_file_name
|
30
|
+
end
|
30
31
|
|
31
|
-
|
32
|
-
|
33
|
-
|
32
|
+
attribute :image_mime_type do |essence|
|
33
|
+
"image/#{essence.picture.image_file_format}"
|
34
|
+
end
|
34
35
|
|
35
|
-
|
36
|
-
|
36
|
+
attribute :image_file_size do |essence|
|
37
|
+
essence.picture.image_file_size
|
38
|
+
end
|
37
39
|
end
|
38
40
|
end
|
39
41
|
end
|
@@ -1,12 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
require "alchemy/json_api/essence_serializer"
|
3
3
|
|
4
|
-
module Alchemy
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
4
|
+
module Alchemy
|
5
|
+
module JsonApi
|
6
|
+
class EssenceRichtextSerializer
|
7
|
+
include EssenceSerializer
|
8
|
+
attributes(
|
9
|
+
:body,
|
10
|
+
:stripped_body,
|
11
|
+
)
|
12
|
+
end
|
11
13
|
end
|
12
14
|
end
|
@@ -1,8 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
require "alchemy/json_api/essence_serializer"
|
3
3
|
|
4
|
-
module Alchemy
|
5
|
-
|
6
|
-
|
4
|
+
module Alchemy
|
5
|
+
module JsonApi
|
6
|
+
class EssenceSelectSerializer
|
7
|
+
include EssenceSerializer
|
8
|
+
end
|
7
9
|
end
|
8
10
|
end
|
@@ -1,14 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
require "alchemy/json_api/essence_serializer"
|
3
3
|
|
4
|
-
module Alchemy
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
4
|
+
module Alchemy
|
5
|
+
module JsonApi
|
6
|
+
class EssenceTextSerializer
|
7
|
+
include EssenceSerializer
|
8
|
+
attributes(
|
9
|
+
:body,
|
10
|
+
:link_title,
|
11
|
+
:link_target,
|
12
|
+
)
|
13
|
+
attribute :link_url, &:link
|
14
|
+
end
|
13
15
|
end
|
14
16
|
end
|
@@ -15,9 +15,10 @@ module Alchemy
|
|
15
15
|
:updated_at,
|
16
16
|
)
|
17
17
|
|
18
|
-
belongs_to :language
|
18
|
+
belongs_to :language, record_type: :language, serializer: LanguageSerializer
|
19
19
|
|
20
|
-
has_many :elements
|
20
|
+
has_many :elements, record_type: :element, serializer: ElementSerializer
|
21
|
+
has_many :fixed_elements, record_type: :element, serializer: ElementSerializer
|
21
22
|
|
22
23
|
has_many :all_elements, record_type: :element, serializer: ElementSerializer do |page|
|
23
24
|
page.all_elements.select { |e| e.public? && !e.trashed? }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alchemy-json_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Meyerhoff
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-11-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: alchemy_cms
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: github_changelog_generator
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: jsonapi-rspec
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|