Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Asset helper: video #396

Closed
jodosha opened this issue Nov 23, 2015 · 3 comments
Closed

Asset helper: video #396

jodosha opened this issue Nov 23, 2015 · 3 comments

Comments

@jodosha
Copy link
Member

jodosha commented Nov 23, 2015

Implement video helper.

See Lotus::Assets::Helpers and Lotus::Helpers::HtmlHelper for reference.

Usage

Basic Usage

<%= video 'movie.mp4' %>
<video src="/assets/movie.mp4"></video>

HTML Attributes

It must accept optional HTML attributes.

<%= video 'movie.mp4', autoplay: true, controls: true %>
<video src="/assets/movie.mp4" autoplay controls></video>

Fallback Content

It accepts an optional block for fallback content for browsers not supporting <video> tag.

<%=
  video 'movie.mp4' do
    "Your browser does not support the video tag"
  end
%>
<video src="/assets/movie.mp4">
  Your browser does not support the video tag
</video>

Tracks

It should support <track> tag.

<%=
  video 'movie.mp4' do
    track(kind: 'captions', src: asset_path('movie.en.vtt'), srclang: 'en', label: 'English')
    track(kind: 'captions', src: asset_path('movie.it.vtt'), srclang: 'it', label: 'Italiano')
  end
%>
<video src="movie.mp4">
  <track kind="captions" src="movie.en.vtt" srclang="en" label="English">
  <track kind="captions" src="movie.it.vtt" srclang="it" label="Italiano">
</video>

A few notes:

Sources

It should support <source> tag.

<%=
  video do
    text "Your browser does not support the video tag"
    source src: asset_path('movie.mp4'), type: 'video/mp4'
    source src: asset_path('movie.ogg'), type: 'video/ogg'
  end
%>
<video>
  Your browser does not support the video tag
  <source src="/assets/movie.mp4" type="video/mp4">
  <source src="/assets/movie.ogg" type="video/ogg">
</video>

A few notes:

URL Prefix

This should take account of the prefix defined in Lotus::Assets::Configuration.

That means, if an application has a prefix: /admin, when one this helper is used, the prefix should be used.

<%= video 'movie.mp4' %>
<video src="/assets/admin/movie.mp4"></video>

Digest Mode

If "Digest Mode" is enabled (usually in production), it should generate the file name with the digest suffix (see https://github.com/lotus/assets/blob/master/lib/lotus/assets/configuration.rb#L37).

<%= video 'song.ogg' %>
<video src="/assets/movie-78a21a377046e9ddb3bd9b509c22d4c3.mp4"></video>

Testing Notes

Add an integration test with Lotus::View, in order to make sure that the output isn't escaped twice and produces a valid HTML.

@leighhalliday
Copy link
Contributor

I'll give this one a go... my first time contributing to Lotus though so it may take a little bit and I may have some questions :)

@jodosha
Copy link
Member Author

jodosha commented Nov 23, 2015

@leighhalliday Lovely, thank you! Ping me here on in chat for questions 😄

leighhalliday added a commit to leighhalliday/helpers that referenced this issue Nov 24, 2015
hanami/hanami#396

This commit exposes a `video` method to the view
which can be used to generate HTML5 video tags.
It accepts options to generate HTML attributes along
with a block for creating fallback content and/or
`source` and `track` tags.
leighhalliday added a commit to leighhalliday/helpers that referenced this issue Nov 25, 2015
hanami/hanami#396

This commit exposes a `video` method to the view
which can be used to generate HTML5 video tags.
It accepts options to generate HTML attributes along
with a block for creating fallback content and/or
`source` and `track` tags.
leighhalliday added a commit to leighhalliday/lotus that referenced this issue Dec 1, 2015
hanami#396

This commit exposes a `video` method to the view
which can be used to generate HTML5 video tags.
It accepts options to generate HTML attributes along
with a block for creating fallback content and/or
`source` and `track` tags.
leighhalliday added a commit to leighhalliday/lotus that referenced this issue Dec 1, 2015
hanami#396

This commit exposes a `video` method to the view
which can be used to generate HTML5 video tags.
It accepts options to generate HTML attributes along
with a block for creating fallback content and/or
`source` and `track` tags.
leighhalliday added a commit to leighhalliday/lotus that referenced this issue Dec 1, 2015
hanami#396

This commit exposes a `video` method to the view
which can be used to generate HTML5 video tags.
It accepts options to generate HTML attributes along
with a block for creating fallback content and/or
`source` and `track` tags.
@jodosha
Copy link
Member Author

jodosha commented Dec 3, 2015

Implemented by #407

@jodosha jodosha closed this as completed Dec 3, 2015
jodosha pushed a commit to hanami/assets that referenced this issue Dec 13, 2015
hanami/hanami#396

This commit exposes a `video` method to the view
which can be used to generate HTML5 video tags.
It accepts options to generate HTML attributes along
with a block for creating fallback content and/or
`source` and `track` tags.
jodosha pushed a commit to hanami/assets that referenced this issue Dec 13, 2015
hanami/hanami#396

This commit exposes a `video` method to the view
which can be used to generate HTML5 video tags.
It accepts options to generate HTML attributes along
with a block for creating fallback content and/or
`source` and `track` tags.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants