Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

DEVELOPER-833 update video structured data #41

Merged
merged 1 commit into from

2 participants

Pete Muir Jason Porter
Pete Muir

No description provided.

Jason Porter LightGuard commented on the diff
lib/aweplug/helpers/vimeo.rb
@@ -240,6 +240,19 @@ def duration_in_seconds
(a.length > 0 ? a[0].to_i : 0) + (a.length > 1 ? a[1].to_i * 60 : 0) + (a.length > 2 ? a[2].to_i * 60 : 0)
end
+ def duration_iso8601
+ t = Integer @video["duration"]
+ Time.at(t).utc.strftime("PT%HH%MM%SS")
Jason Porter Owner

There's a Time#iso8601(number_of_nanoseconds_to_display) but it also includes the offset, which you're not showing here, so not sure if you care.

Pete Muir
pmuir added a note

Oh that would have been easier. I can try that one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Jason Porter
Owner

@pmuir are you going to try that change?

Pete Muir

@LightGuard I can't see a method Time#iso8601 Where is it documented?

Pete Muir

I guess you are referring to Date#iso8601 which formats a date using iso8601. I need to format a duration, which AFAIK Ruby doesn't offer.

http://www.ruby-doc.org/stdlib-2.1.2/libdoc/date/rdoc/Date.html#method-i-iso8601

Jason Porter
Owner
Pete Muir

I did try it. It behaves the same as Date#iso8601, hence my comment.

Jason Porter
Owner
Pete Muir
Jason Porter LightGuard merged commit 1ce581a into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 5, 2014
  1. Pete Muir
This page is out of date. Refresh to see the latest.
8 lib/aweplug/helpers/video_player.html.slim
View
@@ -1,8 +1,12 @@
div(itemprop="video" itemscope itemtype="http://schema.org/VideoObject" data-searchisko-type="jbossdeveloper_vimeo" data-searchisko-id="#{video.id}")
+ link itemprop="url" href="#{page.url}"
+ meta itemprop="description" content="#{video.description}"
+ meta itemprop="height" content="#{video.height}"
+ meta itemprop="width" content="#{video.width}"
h4 itemprop="name" #{video.title}
/ TODO Add more metadata
- span itemprop="duration" content="#{video.duration_in_seconds}"
- span itemprop="thumbnail" content="#{video.thumb_url}"
+ span itemprop="duration" content="#{video.duration_iso8601}"
+ span itemprop="thumbnailurl" content="#{video.thumb_url}"
span itemprop="uploadDate" content="#{video.upload_date_iso8601}"
.flex-video(widescreen vimeo)
iframe(src="//player.vimeo.com/video/#{video.id}?title=0&byline=0&portrait=0&badge=0&color=2664A2" width="500" height="313" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen)
15 lib/aweplug/helpers/vimeo.rb
View
@@ -53,7 +53,7 @@ def render(video, default_snippet, snippet)
else
path = Pathname.new(File.dirname(__FILE__)).join(default_snippet)
end
- Tilt.new(path.to_s).render(Object.new, :video => video)
+ Tilt.new(path.to_s).render(Object.new, :video => video, :page => page, :site => site)
end
end
@@ -240,6 +240,19 @@ def duration_in_seconds
(a.length > 0 ? a[0].to_i : 0) + (a.length > 1 ? a[1].to_i * 60 : 0) + (a.length > 2 ? a[2].to_i * 60 : 0)
end
+ def duration_iso8601
+ t = Integer @video["duration"]
+ Time.at(t).utc.strftime("PT%HH%MM%SS")
Jason Porter Owner

There's a Time#iso8601(number_of_nanoseconds_to_display) but it also includes the offset, which you're not showing here, so not sure if you care.

Pete Muir
pmuir added a note

Oh that would have been easier. I can try that one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ end
+
+ def height
+ @video["height"]
+ end
+
+ def width
+ @video["width"]
+ end
+
def load_thumb_url
if @video['thumbnails']
@thumb = @video["thumbnails"]["thumbnail"][1]
Something went wrong with that request. Please try again.