alchemy-json_api 0.2.0 → 0.3.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 +2 -3
- data/app/serializers/alchemy/json_api/essence_file_serializer.rb +0 -1
- data/app/serializers/alchemy/json_api/essence_node_serializer.rb +0 -1
- data/app/serializers/alchemy/json_api/essence_page_serializer.rb +22 -0
- data/app/serializers/alchemy/json_api/essence_picture_serializer.rb +0 -1
- data/config/routes.rb +4 -2
- data/lib/alchemy/json_api/test_support/essence_serializer_behaviour.rb +18 -0
- data/lib/alchemy/json_api/version.rb +1 -1
- metadata +7 -6
- data/lib/alchemy/json_api/link_helper.rb +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3046cd47b8e5d362917e2c8b595bc25c338e4bdf94a71dabb21794c1aabf913a
|
4
|
+
data.tar.gz: 0670ad88fa25050738ce80692e1004b8b0016b3c25df8596f76fe0b054ed4e51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d48b6c6692e7330db7daeaedc03c177a89ec55225f0f3c96145fd42f7eccf972cc757a47120279f3cf34dffdb3b92aba9b8974a420743a7c0f2f35454fd5f68
|
7
|
+
data.tar.gz: 9071f12da6fe44f21971cb85d53890691f0702f73396ec2e5ef08e7d6439d601aaa6625815c1a6867f15c25cdd23f1c69af67d1111769368df2d2b902e602407
|
@@ -34,12 +34,11 @@ module Alchemy
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def load_page_by_id
|
37
|
-
page_scope.find_by(id: params[:
|
37
|
+
page_scope.find_by(id: params[:path])
|
38
38
|
end
|
39
39
|
|
40
40
|
def load_page_by_urlname
|
41
|
-
|
42
|
-
page_scope.find_by(urlname: params[:id])
|
41
|
+
page_scope.find_by(urlname: params[:path])
|
43
42
|
end
|
44
43
|
|
45
44
|
def page_scope
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "alchemy/json_api/essence_serializer"
|
3
|
+
|
4
|
+
module Alchemy::JsonApi
|
5
|
+
class EssencePageSerializer
|
6
|
+
include EssenceSerializer
|
7
|
+
|
8
|
+
attribute :ingredient do |essence|
|
9
|
+
essence.page&.url_path
|
10
|
+
end
|
11
|
+
|
12
|
+
attribute :page_name do |essence|
|
13
|
+
essence.page&.name
|
14
|
+
end
|
15
|
+
|
16
|
+
attribute :page_url do |essence|
|
17
|
+
essence.page&.url_path
|
18
|
+
end
|
19
|
+
|
20
|
+
has_one :page, record_type: :page, serializer: PageSerializer
|
21
|
+
end
|
22
|
+
end
|
data/config/routes.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
Alchemy::JsonApi::Engine.routes.draw do
|
3
|
-
resources :pages, only: [:
|
4
|
-
|
3
|
+
resources :pages, only: [:index]
|
4
|
+
get "pages/*path" => "pages#show", as: :page
|
5
|
+
resources :layout_pages, only: [:index]
|
6
|
+
get "layout_pages/*path" => "layout_pages#show", as: :layout_page
|
5
7
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
RSpec.shared_examples "an essence serializer" do
|
3
|
+
describe "attributes" do
|
4
|
+
subject { serializer.serializable_hash[:data][:attributes] }
|
5
|
+
|
6
|
+
it "has the right keys and values" do
|
7
|
+
expect(subject).to have_key(:ingredient)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "relationships" do
|
12
|
+
subject { serializer.serializable_hash[:data][:relationships] }
|
13
|
+
|
14
|
+
it "has the right keys and values" do
|
15
|
+
expect(subject[:element]).to eq(data: { id: essence.element.id.to_s, type: :element })
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
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.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Meyerhoff
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: alchemy_cms
|
@@ -114,6 +114,7 @@ files:
|
|
114
114
|
- app/serializers/alchemy/json_api/essence_html_serializer.rb
|
115
115
|
- app/serializers/alchemy/json_api/essence_link_serializer.rb
|
116
116
|
- app/serializers/alchemy/json_api/essence_node_serializer.rb
|
117
|
+
- app/serializers/alchemy/json_api/essence_page_serializer.rb
|
117
118
|
- app/serializers/alchemy/json_api/essence_picture_serializer.rb
|
118
119
|
- app/serializers/alchemy/json_api/essence_richtext_serializer.rb
|
119
120
|
- app/serializers/alchemy/json_api/essence_select_serializer.rb
|
@@ -125,14 +126,14 @@ files:
|
|
125
126
|
- lib/alchemy/json_api.rb
|
126
127
|
- lib/alchemy/json_api/engine.rb
|
127
128
|
- lib/alchemy/json_api/essence_serializer.rb
|
128
|
-
- lib/alchemy/json_api/
|
129
|
+
- lib/alchemy/json_api/test_support/essence_serializer_behaviour.rb
|
129
130
|
- lib/alchemy/json_api/version.rb
|
130
131
|
- lib/tasks/alchemy/json_api_tasks.rake
|
131
132
|
homepage: https://github.com/AlchemyCMS/alchemy-json_api
|
132
133
|
licenses:
|
133
134
|
- MIT
|
134
135
|
metadata: {}
|
135
|
-
post_install_message:
|
136
|
+
post_install_message:
|
136
137
|
rdoc_options: []
|
137
138
|
require_paths:
|
138
139
|
- lib
|
@@ -148,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
148
149
|
version: '0'
|
149
150
|
requirements: []
|
150
151
|
rubygems_version: 3.0.3
|
151
|
-
signing_key:
|
152
|
+
signing_key:
|
152
153
|
specification_version: 4
|
153
154
|
summary: A JSONAPI compliant API for AlchemyCMS
|
154
155
|
test_files: []
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
module Alchemy
|
3
|
-
module JsonApi
|
4
|
-
module LinkHelper
|
5
|
-
def alchemy_link(path_base, object)
|
6
|
-
return unless object
|
7
|
-
|
8
|
-
if Rails.application.routes.default_url_options[:host]
|
9
|
-
Alchemy::Engine.routes.url_helpers.public_send("#{path_base}_url", object)
|
10
|
-
else
|
11
|
-
Alchemy::Engine.routes.url_helpers.public_send("#{path_base}_path", object)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|