Sha256: 24dd372611a436db5d9f3668d8406719b61196ec8efbd7440ffcfa4044176fff

Contents?: true

Size: 999 Bytes

Versions: 2

Compression:

Stored size: 999 Bytes

Contents

module MrVideo

  class EpisodesController < MrVideoController

    def show
      cassette = Cassette.find(params[:cassette_id])
      episode = cassette.find_episode_by_id(params[:id])
      episode_content = episode.content

      unless params[:fix_relative_links] == 'false'
        episode_content.gsub!(/href="\//, "href=\"#{episode.website_url}/")
        episode_content.gsub!(/href="(?<foo>[a-zA-z0-9_])/, 'href="' + episode.website_url + '/\k<foo>')
        episode_content.gsub!(/src="\//, "src=\"#{episode.website_url}/")
        episode_content.gsub!(/@import url\("/, "@import url(\"#{episode.website_url}/")
      end

      # TODO: Add method for sending decompressed content
      send_data episode_content, type: episode.content_type, disposition: 'inline'
    end

    def destroy
      cassette = Cassette.find(params[:cassette_id])
      @episode = cassette.find_episode_by_id(params[:id])
      @episode.destroy
    end

  end # CassettesController class

end # MrVideo module

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mr_video-1.0.1 app/controllers/mr_video/episodes_controller.rb
mr_video-1.0.0 app/controllers/mr_video/episodes_controller.rb