]> gitweb.factorcode.org Git - factor.git/commitdiff
images.http: make it easier to image. stuff.
authorJohn Benediktsson <mrjbq7@gmail.com>
Mon, 4 Apr 2016 19:55:18 +0000 (12:55 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Mon, 4 Apr 2016 22:00:04 +0000 (15:00 -0700)
extra/images/http/http.factor

index a4c064619c93d179c750996fac3cc060866318ad..8ada757175b80e2ef7a3639140b125dd324a4441 100644 (file)
@@ -1,8 +1,8 @@
 ! Copyright (C) 2009 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors assocs http.client images.loader
-images.loader.private images.viewer io.pathnames kernel
-namespaces present sequences ;
+USING: accessors assocs combinators.short-circuit http.client
+images.loader images.loader.private images.viewer io.pathnames
+kernel namespaces present sequences strings urls ;
 IN: images.http
 
 <PRIVATE
@@ -18,5 +18,12 @@ PRIVATE>
     [ present file-extension ] bi or
     (image-class) load-image* ;
 
+M: string set-image
+    dup { [ "http://" head? ] [ "https://" head? ] } 1||
+    [ load-http-image ] [ load-image ] if >>image ;
+
+M: url set-image
+    protocol>> load-http-image >>image ;
+
 : http-image. ( path -- )
     load-http-image image. ;