Skip to content

Commit

Permalink
EYCDTK-55 Accessible iframe update (#880)
Browse files Browse the repository at this point in the history
* Update video markup to support title

* Update logic for video markdown
  • Loading branch information
martikat authored Nov 5, 2024
1 parent 48b41b8 commit 97bf9c4
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/views/markup/_video.html.slim
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
p.embed-container
iframe src=url allow='accelerometer; autoplay; fullscreen; clipboard-write; encrypted-media; gyroscope; picture-in-picture'
iframe title=video_title src=url allow='accelerometer; autoplay; fullscreen; clipboard-write; encrypted-media; gyroscope; picture-in-picture'
9 changes: 6 additions & 3 deletions config/initializers/markdown.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,17 +136,20 @@ def blockquote
end

# @example
# {video}872080640{/video}
# {video}
# video
# This is a video title
# {/video}
#
# @return [CustomPreprocessor]
def video
pattern = build_regexp('video')
@output = output.gsub(pattern) do
params = { enablejsapi: 1, origin: ENV['DOMAIN'] }.to_param
video_id = Regexp.last_match(1)
video_id, video_title = split_content Regexp.last_match(1)
video_url = %(https://www.youtube.com/embed/#{video_id}?#{params})
# video_url = %(https://player.vimeo.com/video/#{video_id}?#{params})
video_template.render(nil, url: video_url)
video_template.render(nil, url: video_url, video_title: video_title)
end
self
end
Expand Down
19 changes: 19 additions & 0 deletions spec/helpers/content_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,25 @@
end
end
end

describe 'Video markup' do
let(:input) do
<<~MARKUP
{video}
video
This is a video title
{/video}
MARKUP
end

it 'renders the embedded video' do
expect(html).to have_selector('iframe')
end

it 'renders an iframe with a title' do
expect(html).to include 'title="This is a video title"'
end
end
end

describe 'Not found error' do
Expand Down

0 comments on commit 97bf9c4

Please sign in to comment.