-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
5 changed files
with
286 additions
and
0 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
wcc-contentful-app/app/views/sections/_video_highlight.html.erb
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,18 @@ | ||
<div class="row justify-content-center"> | ||
<div class="col col-md-6"> | ||
<% if section.tag.present? %> | ||
<span class="section-video-highlight__tag"><%= section.tag %></span> | ||
<% end %> | ||
<h2 class="section-video-highlight__title"><%= section.title %></h2> | ||
<% if section.subtext.present? %> | ||
<div class="section-video-highlight__subtext"> | ||
<%= markdown(section.subtext) %> | ||
</div> | ||
<% end %> | ||
</div> | ||
<div class="column medium-6"> | ||
<div class="video-responsive section-video-highlight__video"> | ||
<%= raw section.embed_code %> | ||
</div> | ||
</div> | ||
</div><!--row--> |
80 changes: 80 additions & 0 deletions
80
...enerators/wcc/templates/section-video-highlight/generated_add_section-video-highlights.ts
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,80 @@ | ||
import Migration, { MigrationFunction } from 'contentful-migration' | ||
|
||
// Generated by contentful-schema-diff | ||
// from empty-export.json | ||
// to 7yx6ovlj39n5 | ||
export = function(migration : Migration, { makeRequest, spaceId, accessToken }) { | ||
|
||
/************ section-video-highlight ******************/ | ||
|
||
var sectionVideoHighlight = migration.createContentType('section-video-highlight', { | ||
displayField: 'internalTitle', | ||
name: 'Section: Video Highlight', | ||
description: 'Highlight a video with some text' | ||
}) | ||
|
||
sectionVideoHighlight.createField('internalTitle', { | ||
name: 'Internal Title (Contentful Only)', | ||
type: 'Symbol', | ||
localized: false, | ||
required: true, | ||
validations: [], | ||
disabled: false, | ||
omitted: true | ||
}) | ||
|
||
sectionVideoHighlight.createField('tag', { | ||
name: 'Tag', | ||
type: 'Symbol', | ||
localized: true, | ||
required: false, | ||
validations: | ||
[{ | ||
size: { max: 75 }, | ||
message: 'Tag must be short!' | ||
}], | ||
disabled: false, | ||
omitted: false | ||
}) | ||
|
||
sectionVideoHighlight.createField('title', { | ||
name: 'Title', | ||
type: 'Symbol', | ||
localized: false, | ||
required: true, | ||
validations: [], | ||
disabled: false, | ||
omitted: false | ||
}) | ||
|
||
sectionVideoHighlight.createField('subtext', { | ||
name: 'Subtext', | ||
type: 'Text', | ||
localized: true, | ||
required: false, | ||
validations: [{ size: { max: 500 } }], | ||
disabled: false, | ||
omitted: false | ||
}) | ||
|
||
sectionVideoHighlight.createField('embedCode', { | ||
name: 'Embed Code', | ||
type: 'Text', | ||
localized: false, | ||
required: true, | ||
validations: [], | ||
disabled: false, | ||
omitted: false | ||
}) | ||
|
||
sectionVideoHighlight.changeEditorInterface('tag', 'singleLine') | ||
|
||
sectionVideoHighlight.changeEditorInterface('title', 'singleLine') | ||
|
||
sectionVideoHighlight.changeEditorInterface('subtext', 'markdown') | ||
|
||
sectionVideoHighlight.changeEditorInterface('embedCode', 'markdown') | ||
|
||
sectionVideoHighlight.changeEditorInterface('internalTitle', 'singleLine') | ||
|
||
} as MigrationFunction |
21 changes: 21 additions & 0 deletions
21
...pp/lib/generators/wcc/templates/section-video-highlight/models/section-video-highlight.rb
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,21 @@ | ||
# frozen_string_literal: true | ||
# This model represents the 'section-video-highlight' content type in Contentful. Any linked | ||
# entries of the 'section-video-highlight' content type will be resolved as instances of this class. | ||
# It exposes .find, .find_by, and .find_all methods to query Contentful. | ||
class SectionVideoHighlight < WCC::Contentful::Model::SectionVideoHighlight | ||
# Add custom validations to ensure that app-specific properties exist: | ||
# validate_field :foo, :String, :required | ||
# validate_field :bar_links, :Array, link_to: %w[bar baz] | ||
# Override functionality or add utilities | ||
# | ||
# # Example: override equality | ||
# def ===(other) | ||
# ... | ||
# end | ||
# | ||
# # Example: override "title" attribute to always be titlecase. | ||
# # `@title` is populated by the gem in the initializer. | ||
# def title | ||
# @title_titlecased ||= @title.titlecase | ||
# 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
45 changes: 45 additions & 0 deletions
45
wcc-contentful-app/spec/views/sections/_video_highlight.html.erb_spec.rb
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,45 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe 'sections/video_highlight' do | ||
helper WCC::Contentful::App::SectionHelper | ||
|
||
it 'renders successfully' do | ||
section = contentful_create('section-video-highlight') | ||
|
||
render partial: 'components/section', locals: { section: section } | ||
|
||
expect(rendered).to have_css('section.section-video-highlight.default') | ||
end | ||
|
||
it 'renders raw embed code' do | ||
section = contentful_create('section-video-highlight', | ||
embed_code: '<video src="youtu.be/asdf">') | ||
|
||
render partial: 'components/section', locals: { section: section } | ||
|
||
expect(rendered).to include('<video src="youtu.be/asdf">') | ||
end | ||
|
||
it 'renders tag' do | ||
section = contentful_create('section-video-highlight', | ||
tag: 'Some Video') | ||
|
||
render partial: 'components/section', locals: { section: section } | ||
|
||
body = Capybara.string(rendered) | ||
expect(body.find('.section-video-highlight__tag').text.strip).to eq('Some Video') | ||
end | ||
|
||
it 'renders markdown subtext' do | ||
section = contentful_create('section-video-highlight', | ||
subtext: '## expect h2') | ||
|
||
render partial: 'components/section', locals: { section: section } | ||
|
||
body = Capybara.string(rendered) | ||
subtext = body.find('.section-video-highlight__subtext') | ||
expect(subtext.find('h2').text.strip).to eq('expect h2') | ||
end | ||
end |