-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3efc459
commit f38b58e
Showing
16 changed files
with
284 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.rspec_status | ||
Gemfile.lock | ||
gemfiles/*.lock | ||
tmp/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
|
||
RSpec.describe 'Contentful integration test', type: :feature do | ||
around do |example| | ||
VCR.use_cassette('contentful', &example) | ||
end | ||
|
||
it 'renders Contentful entries' do | ||
visit '/contentful' | ||
|
||
expect(page.body.strip).to eq('Homepage') | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
|
||
RSpec.describe 'Prismic integration test', type: :feature do | ||
around do |example| | ||
VCR.use_cassette('prismic', &example) | ||
end | ||
|
||
it 'renders Contentful entries' do | ||
visit '/prismic' | ||
|
||
expect(page.body.strip).to eq('Homepage') | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# frozen_string_literal: true | ||
|
||
class PageComponent < ViewComponent::Base | ||
def initialize(entry:, client:) | ||
@entry = entry | ||
@client = client | ||
end | ||
|
||
def call | ||
normalized_fields[:title] | ||
end | ||
|
||
private | ||
|
||
def normalized_fields | ||
@normalized_fields ||= @entry.fields.with_indifferent_access.transform_values do |field| | ||
field.respond_to?(:as_text) ? field.as_text : field | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
class PagesController < ActionController::Base | ||
def prismic; end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<%= RenderfulContentfulClient.render('6pG1BlIIaL69l0YWcDI4I5', view_context: self) %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<%= RenderfulPrismicClient.render('XodtshAAACIACgDj', view_context: self) %> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# frozen_string_literal: true | ||
|
||
RenderfulPrismicClient = Renderful::Client.new( | ||
provider: Renderful::Provider::Prismic.new(prismic: Prismic.api( | ||
'https://renderfultest.cdn.prismic.io/api', | ||
)), | ||
components: { | ||
'page' => PageComponent, | ||
}, | ||
cache: Rails.cache, | ||
) | ||
|
||
RenderfulContentfulClient = Renderful::Client.new( | ||
provider: Renderful::Provider::Contentful.new(contentful: Contentful::Client.new( | ||
space: 'secret_space_id', | ||
access_token: 'secret_access_token' | ||
)), | ||
components: { | ||
'page' => PageComponent, | ||
}, | ||
cache: Rails.cache, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
# frozen_string_literal: true | ||
|
||
Rails.application.routes.draw do | ||
# Add your own routes here, or remove this file if you don't have need for it. | ||
get 'prismic', to: 'pages#prismic' | ||
get 'contentful', to: 'pages#contentful' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.