Sha256: 413e782386e1fd4156af9aec449560dc0e1c7cf2a39c99d6fdcd1bf0cd4eff4b

Contents?: true

Size: 727 Bytes

Versions: 1

Compression:

Stored size: 727 Bytes

Contents

%w{
cgi

murlsh
}.each { |m| require m }

module Murlsh

  # Set the thumbnail of imageshack images.
  class AddPre60Imageshack < Plugin

    @hook = 'add_pre'

    ImageshackRe =
      %r{^(http://img\d+\.imageshack\.us/img\d+/\d+/)(\w+)\.(jpe?g|gif|png)$}i
    StorageDir = File.join(File.dirname(__FILE__), '..', 'public', 'img',
      'thumb')

    def self.run(url, config)
      if match = ImageshackRe.match(url.url)
        thumb_storage = Murlsh::ImgStore.new(StorageDir,
          :user_agent => config['user_agent'])
        stored_filename = thumb_storage.store(
          "#{match[1]}#{match[2]}.th.#{match[3]}")
        url.thumbnail_url = "img/thumb/#{CGI.escape(stored_filename)}"
      end
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
murlsh-1.0.0 plugins/add_pre_60_imageshack.rb