Module: Pageflow::AudioFilesHelper
- Defined in:
- app/helpers/pageflow/audio_files_helper.rb
Instance Method Summary collapse
- #audio_file_audio_tag(audio_file_id, options = {}) ⇒ Object
- #audio_file_non_js_link(audio_file_id) ⇒ Object
- #audio_file_script_tag(audio_file_id, options = {}) ⇒ Object
- #audio_file_sources(audio_file, options = {}) ⇒ Object
Instance Method Details
#audio_file_audio_tag(audio_file_id, options = {}) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'app/helpers/pageflow/audio_files_helper.rb', line 3 def audio_file_audio_tag(audio_file_id, = {}) .merge!(class: ['audio-js', .delete(:class)].compact * ' ', controls: true, preload: 'none') = {unique_id: .delete(:unique_id)} if (audio_file = AudioFile.find_by_id(audio_file_id)) content_tag(:audio, ) do audio_file_sources(audio_file, ).each do |source| concat(tag(:source, source.slice(:src, :type))) end end end end |
#audio_file_non_js_link(audio_file_id) ⇒ Object
26 27 28 29 30 |
# File 'app/helpers/pageflow/audio_files_helper.rb', line 26 def audio_file_non_js_link(audio_file_id) if (audio_file = AudioFile.find_by_id(audio_file_id)) link_to(t('pageflow.audio.open'), short_audio_file_path(audio_file.entry, audio_file)) end end |
#audio_file_script_tag(audio_file_id, options = {}) ⇒ Object
18 19 20 21 22 23 24 |
# File 'app/helpers/pageflow/audio_files_helper.rb', line 18 def audio_file_script_tag(audio_file_id, = {}) if (audio_file = AudioFile.find_by_id(audio_file_id)) render('pageflow/audio_files/script_tag', audio_file: audio_file, audio_file_sources: audio_file_sources(audio_file, )) end end |
#audio_file_sources(audio_file, options = {}) ⇒ Object
32 33 34 35 36 37 38 |
# File 'app/helpers/pageflow/audio_files_helper.rb', line 32 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 |