Module: Pageflow::VideoFilesHelper
- Includes:
- RevisionFileHelper
- Included in:
- Editor::FilesHelper
- Defined in:
- app/helpers/pageflow/video_files_helper.rb
Overview
rubocop:todo Style/Documentation
Instance Method Summary collapse
- #lookup_video_tag(video_id, poster_image_id, options = {}) ⇒ Object deprecated Deprecated.
-
#mobile_poster_image_div(config = {}) ⇒ Object
rubocop:todo Metrics/PerceivedComplexity rubocop:todo Metrics/CyclomaticComplexity.
-
#poster_image_tag(video_file_perma_id, poster_image_perma_id = nil, options = {}) ⇒ Object
rubocop:enable Metrics/CyclomaticComplexity rubocop:enable Metrics/PerceivedComplexity.
- #video_file_non_js_link(entry, video_file_perma_id) ⇒ Object
- #video_file_script_tag(video_file_perma_id, options = {}) ⇒ Object
- #video_file_sources(video_file, options = {}) ⇒ Object
-
#video_file_video_tag(video_file, options = {}) ⇒ Object
rubocop:todo Metrics/AbcSize rubocop:todo Metrics/PerceivedComplexity rubocop:todo Metrics/CyclomaticComplexity.
Methods included from RevisionFileHelper
Instance Method Details
#lookup_video_tag(video_id, poster_image_id, options = {}) ⇒ Object
Deprecated.
106 107 108 |
# File 'app/helpers/pageflow/video_files_helper.rb', line 106 def lookup_video_tag(video_id, poster_image_id, = {}) video_file_script_tag(video_id, .merge(poster_image_id:)) end |
#mobile_poster_image_div(config = {}) ⇒ Object
rubocop:todo Metrics/PerceivedComplexity rubocop:todo Metrics/CyclomaticComplexity
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/helpers/pageflow/video_files_helper.rb', line 7 def mobile_poster_image_div(config = {}) # rubocop:todo Metrics/AbcSize classes = ['background', 'background_image'] position = {x: 50, y: 50} if config['mobile_poster_image_id'] classes << "image_#{config['mobile_poster_image_id']}" position[:x] = config['mobile_poster_image_x'] || 50 position[:y] = config['mobile_poster_image_y'] || 50 elsif config['poster_image_id'] classes << "image_#{config['poster_image_id']}" position[:x] = config['poster_image_x'] || 50 position[:y] = config['poster_image_y'] || 50 elsif config['video_file_id'] classes << "video_poster_#{config['video_file_id']}" position[:x] = config['video_file_x'] || 50 position[:y] = config['video_file_y'] || 50 else classes << 'video_poster_none' end content_tag(:div, '', class: classes.join(' '), style: "background-position: #{position[:x]}% #{position[:y]}%;") end |
#poster_image_tag(video_file_perma_id, poster_image_perma_id = nil, options = {}) ⇒ Object
rubocop:enable Metrics/CyclomaticComplexity rubocop:enable Metrics/PerceivedComplexity
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/helpers/pageflow/video_files_helper.rb', line 34 def poster_image_tag(video_file_perma_id, poster_image_perma_id = nil, = {}) video_file = find_file_in_entry(VideoFile, video_file_perma_id) poster = if poster_image_perma_id.present? find_file_in_entry(ImageFile, poster_image_perma_id) end if poster&.ready? = .merge('data-src' => poster..url(:medium)) = .merge('data-printsrc' => poster..url(:print)) elsif video_file = .merge('data-src' => video_file.poster.url(:medium)) = .merge('data-printsrc' => video_file.poster.url(:print)) end image_tag('', ) end |
#video_file_non_js_link(entry, video_file_perma_id) ⇒ Object
126 127 128 129 130 131 132 133 |
# File 'app/helpers/pageflow/video_files_helper.rb', line 126 def video_file_non_js_link(entry, video_file_perma_id) video_file = find_file_in_entry(VideoFile, video_file_perma_id) return unless video_file link_to(t('pageflow.public.play_video'), short_video_file_path(entry, video_file.id), class: 'hint') end |
#video_file_script_tag(video_file_perma_id, options = {}) ⇒ Object
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'app/helpers/pageflow/video_files_helper.rb', line 110 def video_file_script_tag(video_file_perma_id, = {}) video_file = find_file_in_entry(VideoFile, video_file_perma_id) script_tag_data = {template: 'video'} if video_file && video_file.width.present? && video_file.height.present? script_tag_data[:video_width] = video_file.width script_tag_data[:video_height] = video_file.height end render('pageflow/video_files/script_tag', script_tag_data:, video_file:, options:) end |
#video_file_sources(video_file, options = {}) ⇒ Object
135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'app/helpers/pageflow/video_files_helper.rb', line 135 def video_file_sources(video_file, = {}) [ { type: 'application/x-mpegURL', src: video_file.hls_playlist.url(), high_src: video_file.hls_playlist.url() }, { type: 'video/mp4', src: video_file.mp4_medium.url(), high_src: video_file.mp4_high.url() } ] end |
#video_file_video_tag(video_file, options = {}) ⇒ Object
rubocop:todo Metrics/AbcSize rubocop:todo Metrics/PerceivedComplexity rubocop:todo Metrics/CyclomaticComplexity
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'app/helpers/pageflow/video_files_helper.rb', line 55 def video_file_video_tag(video_file, = {}) # rubocop:todo Metrics/MethodLength defaults = { crossorigin: 'anonymous', class: [ 'player video-js video-viewport vjs-default-skin', .delete(:class) ].compact * ' ', preload: .delete(:preload) ? 'metadata' : 'none' } .reverse_merge! defaults = {unique_id: .delete(:unique_id)} poster_image_id = .delete(:poster_image_id) poster = poster_image_id.present? ? find_file_in_entry(ImageFile, poster_image_id) : nil mobile_poster_image_id = .delete(:mobile_poster_image_id) mobile_poster = if mobile_poster_image_id.present? find_file_in_entry(ImageFile, mobile_poster_image_id) end [:data] = {} if mobile_poster&.ready? [:data][:mobile_poster] = mobile_poster..url(:medium) [:data][:mobile_large_poster] = mobile_poster..url(:large) end if poster&.ready? [:data][:poster] = poster..url(:medium) [:data][:large_poster] = poster..url(:large) elsif video_file [:data][:poster] = video_file.poster.url(:medium) [:data][:large_poster] = video_file.poster.url(:large) end if video_file && video_file.width.present? && video_file.height.present? [:data][:width] = video_file.width [:data][:height] = video_file.height end render('pageflow/video_files/video_tag', video_file:, options:, url_options:) end |