Module: Pageflow::AudioFilesHelper
- Includes:
- RevisionFileHelper
- Included in:
- Editor::FilesHelper
- Defined in:
- app/helpers/pageflow/audio_files_helper.rb
Instance Method Summary collapse
- #audio_file_audio_tag(audio_file_perma_id, options = {}) ⇒ Object
- #audio_file_non_js_link(entry, audio_file_perma_id) ⇒ Object
- #audio_file_script_tag(audio_file_perma_id, options = {}) ⇒ Object
- #audio_file_sources(audio_file, options = {}) ⇒ Object
Methods included from RevisionFileHelper
Instance Method Details
#audio_file_audio_tag(audio_file_perma_id, options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'app/helpers/pageflow/audio_files_helper.rb', line 5 def audio_file_audio_tag(audio_file_perma_id, = {}) .merge!(class: ['audio-js', .delete(:class)].compact * ' ', controls: true, preload: 'none') = {unique_id: .delete(:unique_id)} audio_file = find_file_in_entry(AudioFile, audio_file_perma_id) return unless audio_file content_tag(:audio, ) do audio_file_sources(audio_file, ).each do |source| concat(tag(:source, source.slice(:src, :type))) end end end |
#audio_file_non_js_link(entry, audio_file_perma_id) ⇒ Object
28 29 30 31 32 |
# File 'app/helpers/pageflow/audio_files_helper.rb', line 28 def audio_file_non_js_link(entry, audio_file_perma_id) audio_file = find_file_in_entry(AudioFile, audio_file_perma_id) return unless audio_file link_to(t('pageflow.audio.open'), short_audio_file_path(entry, audio_file)) end |
#audio_file_script_tag(audio_file_perma_id, options = {}) ⇒ Object
20 21 22 23 24 25 26 |
# File 'app/helpers/pageflow/audio_files_helper.rb', line 20 def audio_file_script_tag(audio_file_perma_id, = {}) audio_file = find_file_in_entry(AudioFile, audio_file_perma_id) return unless audio_file render('pageflow/audio_files/script_tag', audio_file: audio_file, audio_file_sources: audio_file_sources(audio_file, )) end |
#audio_file_sources(audio_file, options = {}) ⇒ Object
34 35 36 37 38 39 40 |
# File 'app/helpers/pageflow/audio_files_helper.rb', line 34 def audio_file_sources(audio_file, = {}) [ {type: 'audio/ogg', src: audio_file.ogg.url()}, {type: 'audio/mp4', src: audio_file.m4a.url()}, {type: 'audio/mpeg', src: audio_file.mp3.url()} ] end |