xkcd: adding words to view XKCD comics in the listener.

db4
John Benediktsson 2012-07-24 11:11:42 -07:00
parent 06469a4865
commit 66624ce7da
2 changed files with 26 additions and 0 deletions

1
extra/xkcd/authors.txt Normal file
View File

@ -0,0 +1 @@
John Benediktsson

25
extra/xkcd/xkcd.factor Normal file
View File

@ -0,0 +1,25 @@
! Copyright (C) 2011 John Benediktsson
! See http://factorcode.org/license.txt for BSD license
USING: formatting http.client images.http images.viewer kernel
regexp strings ;
IN: xkcd
<PRIVATE
: load-comic ( url -- image )
http-get nip
R" http://imgs\.xkcd\.com/comics/[^\.]+\.(png|jpg)"
first-match >string load-http-image ;
PRIVATE>
: xkcd. ( n -- )
"http://xkcd.com/%s/" sprintf load-comic image. ;
: random-xkcd. ( -- )
"http://dynamic.xkcd.com/random/comic/" load-comic image. ;
: latest-xkcd. ( -- )
"http://xkcd.com" load-comic image. ;