Thanks for the method. In playing with it, I've noticed on the windows
platform, r396, that using the 'image' method with a png works fine
but with a jpg image, the shoes app crashes.

Don

On Jan 11, 2008 2:10 PM, why the lucky stiff <[EMAIL PROTECTED]> wrote:
>
> On Fri, Jan 11, 2008 at 01:43:46PM -0800, Don Park wrote:
> > is there an easy way to load a remote image for use with the 'image' method?
> >
> > image "http://www.google.com/intl/en_ALL/images/logo.gif";
> > that looks on the local filesystem
>
> Sure, yeah.
>
>   class Shoes
>     def remote_image uri, opts = {}, &blk
>       uri = URI(uri) unless uri.is_a? URI
>       uri.open do |fin|
>         name = uri.host + "." + fin.meta['etag'].gsub(/[^\w\-\.]/, '') +
>           File.extname(uri.path)
>         cache_path = File.join(LIB_DIR, name)
>         unless File.exists? cache_path
>           File.open(cache_path, 'w') do |fout|
>             while chunk = fin.read(16384)
>               fout.write chunk
>             end
>           end
>         end
>         image cache_path, opts, &blk
>       end
>     end
>   end
>
> This will be in Shoes soon.  I just need to make some caching decisions.
>
> _why
>

Reply via email to