Re: Including Vimeo videos in a document

Posted by mojavelinux on
URL: https://discuss.asciidoctor.org/Including-Vimeo-videos-in-a-document-tp492p505.html

These are great suggestions Alex. Thanks for posting them!

To provide a little background, the video template in Asciidoctor currently matches the template in AsciiDoc. Admittedly, it's a bit narrowly focused on use case which is not really the norm at all. Most of the time when we link to a video, it's on a major service like YouTube, Vimeo and so on.

As Alex mentioned, the block macros in 0.1.4 (now in master) would allow you to put something together quite easily. You could create something like:

youtube::videoid[start="1:00", options="autoplay"]

Though, when I originally envisioned the video macro, I imagined it would be able to handle any video service. That way, we don't have tons of different macros for videos when really we are just specifying an option...the video service. Here's what I had in mind:

video::videoid[service="youtube", start="1:00", options="autoplay"]

The "service" is the central piece here. It determines which template fragment will be used to create the HTML output. Alternatively, we could use a URI scheme:

video::youtube://videoid[start="1:00", options="autoplay"]

An example slim template (based on using the service attribute) might look like:

.videoblock id=@id class=[@style,role]
  - if title?
    .title=captioned_title
  .content
    - if attr? :service, 'youtube'
      iframe(id=@id type="text/html" width=(attr :width, 640) height=(attr :height, 480)
          src="<a href="http://www.youtube.com/embed/#{attr">http://www.youtube.com/embed/#{attr 'target'}?autoplay="#{option?('autoplay') ? 1 : 0}")
    - elsif attr? :service, 'vimeo'
      / add template fo
    - else
      video(src=media_uri(attr :target) width=(attr :width) height=(attr :height)
          poster=((attr :poster) ? media_uri(attr :poster) : nil) autoplay=(option? 'autoplay')
          controls=!(option? 'nocontrols') loop=(option? 'loop'))
        |Your browser does not support the video tag.

I'd be happy to add support for YouTube and Vimeo out of the box. We just need to settle on where the service name is going to go in the macro (so we can align on a standard notation). Would you be willing to file an issue?

> Do you know if Asciidoctor 0.1.4 is going to be ready soon ?

As soon as possible. All but one of the outstanding pull requests have been merged and there are just a few minor things to cleanup. We'll most certainly have a release out by the beginning of next week.

-Dan


On Wed, Aug 21, 2013 at 11:07 AM, asotobu [via Asciidoctor :: Discussion] <[hidden email]> wrote:
well yes you can do it with custom templates because you can use conditionals on template depending on a defined attribute.

See this example in Haml for deckjs template:

https://github.com/asciidoctor/asciidoctor-backends/blob/master/haml/deckjs/block_ulist.html.haml

So you can create an attribute to the video block which tells you if there is a viemo or a youtube link, and then in your template you could generate one code or other.


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Including-Vimeo-videos-in-a-document-tp492p495.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--
Dan Allen | http://google.com/profiles/dan.j.allen