1 ! Copyright (C) 2009 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors combinators.short-circuit http.client
4 images.loader images.loader.private images.viewer io.pathnames
5 kernel present sequences strings urls ;
10 : content-type ( response -- type/f )
11 content-type>> dup "image/" head?
12 [ 6 tail ] [ drop f ] if ;
16 : load-http-image ( path -- image )
17 [ http-get swap content-type ]
18 [ present file-extension ] bi or
19 (image-class) load-image* ;
22 dup { [ "http://" head? ] [ "https://" head? ] } 1||
23 [ load-http-image ] [ load-image ] if >>image ;
26 protocol>> load-http-image >>image ;
28 : http-image. ( path -- )
29 load-http-image image. ;