Sha256: b549fec083e08b98db24c6cf7c73addae5cd6f5019f0e3fa26fbaa435ecbe569

Contents?: true

Size: 1.34 KB

Versions: 3

Compression:

Stored size: 1.34 KB

Contents

module Kinney
  module ClipHelper
    include ::KinneyClipHelper
    
    def duration_pretty(clip)
      "(#{clip.duration_pretty})" if !clip.duration.blank?
    end

      
    def download_button(clip)
      link_to(clip.mp4, :class => 'btn', :id => 'download_mp4') do
        "<i class='icon-arrow-down'></i> #{t 'kinney.clips.show.download_mp4'}".html_safe
      end
    end
    
    # TODO: once we have VTT for everything change this and make VTT's manditory
    def vtt_button(clip)
      begin
        client = HTTPClient.new
        response = client.head(clip.vtt)
        link_to_options = {:class => 'btn', :id => 'download_vtt'}
        if response.status != 200
          link_to_options.merge!(:style => 'display:none')
        end
        link_to(clip.vtt, link_to_options) do
            "<i class='icon-arrow-down'></i> #{t :download_transcript}".html_safe
          end
      rescue
      end
    end

    def jump_time(timestamp)
      time_parts = timestamp.split(':')
      seconds = time_parts.pop
      minutes = time_parts.pop
      hours   = time_parts.first if !time_parts.blank?
      total_seconds = hours.to_i.hours.seconds
      total_seconds += minutes.to_i.minutes.seconds
      total_seconds += seconds.split('.').first.to_i
    end
    
    def topic_li_class(topic)
      current_page?(topic_path(topic)) ? 'active' : ''
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
kinney-0.0.3 app/helpers/kinney/clip_helper.rb
kinney-0.0.2 app/helpers/kinney/clip_helper.rb
kinney-0.0.1 app/helpers/kinney/clip_helper.rb