diff --git a/app/assets/images/icons/fontawesome/vimeo-v-brands-solid.svg b/app/assets/images/icons/fontawesome/vimeo-v-brands-solid.svg new file mode 100644 index 000000000..c890dff95 --- /dev/null +++ b/app/assets/images/icons/fontawesome/vimeo-v-brands-solid.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/app/javascript/controllers/video_player_controller.js b/app/javascript/controllers/video_player_controller.js index d48a89f65..bb51e4728 100644 --- a/app/javascript/controllers/video_player_controller.js +++ b/app/javascript/controllers/video_player_controller.js @@ -1,9 +1,11 @@ import { Controller } from '@hotwired/stimulus' import Vlitejs from 'vlitejs' -import VlitejsYoutube from 'vlitejs/providers/youtube.js' +import YouTube from 'vlitejs/providers/youtube.js' +import Vimeo from 'vlitejs/providers/vimeo.js' import youtubeSvg from '../../assets/images/icons/fontawesome/youtube-brands-solid.svg?raw' -Vlitejs.registerProvider('youtube', VlitejsYoutube) +Vlitejs.registerProvider('youtube', YouTube) +Vlitejs.registerProvider('vimeo', Vimeo) export default class extends Controller { static values = { poster: String, src: String, provider: String } diff --git a/app/models/talk.rb b/app/models/talk.rb index c8f749951..737905791 100644 --- a/app/models/talk.rb +++ b/app/models/talk.rb @@ -81,7 +81,7 @@ class Talk < ApplicationRecord before_validation :set_kind, if: -> { !kind_changed? } # enums - enum :video_provider, %w[youtube mp4 scheduled not_published not_recorded].index_by(&:itself) + enum :video_provider, %w[youtube mp4 vimeo scheduled not_published not_recorded].index_by(&:itself) enum :kind, %w[keynote talk lightning_talk panel workshop gameshow podcast q_and_a discussion fireside_chat interview award].index_by(&:itself) @@ -212,11 +212,23 @@ def thumbnail(size = :thumbnail_lg) end end - if !youtube? && event && (asset = Rails.application.assets.load_path.find(event.poster_image_path)) + if !youtube? && !vimeo? && event && (asset = Rails.application.assets.load_path.find(event.poster_image_path)) return "/assets/#{asset.digested_path}" end - return fallback_thumbnail unless youtube? + return fallback_thumbnail unless youtube? || vimeo? + + if vimeo? + vimeo = { + thumbnail_xs: "_small", + thumbnail_sm: "_small", + thumbnail_md: "_medium", + thumbnail_lg: "_large", + thumbnail_xl: "_large" + } + + return "https://vumbnail.com/#{video_id}#{vimeo[size]}.jpg" + end youtube = { thumbnail_xs: "default", diff --git a/app/views/talks/_talk.html.erb b/app/views/talks/_talk.html.erb index e7feee0e4..c47ada877 100644 --- a/app/views/talks/_talk.html.erb +++ b/app/views/talks/_talk.html.erb @@ -25,7 +25,7 @@ <% end %> <% else %> - <% if talk.video_provider.in?(["mp4", "youtube", "scheduled", "not_published", "not_recorded"]) %> + <% if talk.video_provider.in?(["mp4", "youtube", "vimeo", "scheduled", "not_published", "not_recorded"]) %> <%= render partial: "talks/video_providers/#{talk.video_provider}", locals: {talk: talk} %> <% else %> Provider <%= talk.video_provider.inspect %> is not configured. @@ -42,7 +42,7 @@
<% if talk.video_provider == "youtube" %> - " target="_blank" data-action="click->video-player#pause"> + " target="_blank" data-action="click->video-player#pause">
Play on <%= fa("youtube-brands", size: :sm, style: :solid) %> @@ -50,6 +50,15 @@ <% end %> + <% if talk.video_provider == "vimeo" %> + " target="_blank" data-action="click->video-player#pause"> +
+ Play on + <%= fa("vimeo-v-brands", size: :sm, style: :solid) %> +
+
+ <% end %> + <% if signed_in? && !talk.scheduled? %> <%= turbo_frame_tag dom_id(talk, :watched_talk) do %> <% if talk.watched? %> diff --git a/app/views/talks/video_providers/_vimeo.html.erb b/app/views/talks/video_providers/_vimeo.html.erb new file mode 100644 index 000000000..738696ade --- /dev/null +++ b/app/views/talks/video_providers/_vimeo.html.erb @@ -0,0 +1,7 @@ +
+ +
diff --git a/db/seeds.rb b/db/seeds.rb index 34905cd8a..5e86e7170 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -52,7 +52,7 @@ end Talk - .find_or_initialize_by(video_id: talk_data["video_id"], video_provider: talk_data["video_provider"] || :youtube) + .find_or_initialize_by(video_id: talk_data["video_id"].to_s, video_provider: talk_data["video_provider"] || :youtube) .update_from_yml_metadata!(event: event) rescue ActiveRecord::RecordInvalid => e puts "Couldn't save: #{talk_data["title"]}, error: #{e.message}"