2011-11-12 19:18:52 -05:00
|
|
|
! Copyright (C) 2011 John Benediktsson
|
|
|
|
! See http://factorcode.org/license.txt for BSD license
|
|
|
|
|
2014-11-13 16:00:44 -05:00
|
|
|
USING: accessors combinators.short-circuit io.pathnames
|
|
|
|
sequences strings system ui.operations urls vocabs ;
|
2011-11-12 19:18:52 -05:00
|
|
|
|
|
|
|
IN: webbrowser
|
|
|
|
|
|
|
|
HOOK: open-file os ( path -- )
|
|
|
|
|
2014-11-13 16:00:44 -05:00
|
|
|
"webbrowser." os name>> append require
|
2011-11-12 19:18:52 -05:00
|
|
|
|
2011-11-13 19:31:52 -05:00
|
|
|
: open-url ( url -- )
|
2013-11-17 15:57:11 -05:00
|
|
|
>url open-file ;
|
|
|
|
|
|
|
|
[ pathname? ] \ open-file H{ } define-operation
|
2011-11-13 19:31:52 -05:00
|
|
|
|
2011-11-12 19:18:52 -05:00
|
|
|
[ url? ] \ open-url H{ } define-operation
|
2012-09-22 19:49:53 -04:00
|
|
|
|
2012-09-22 19:52:01 -04:00
|
|
|
PREDICATE: url-string < string
|
2012-09-22 19:49:53 -04:00
|
|
|
{ [ "http://" head? ] [ "https://" head? ] } 1|| ;
|
|
|
|
|
2012-09-22 19:52:01 -04:00
|
|
|
[ url-string? ] \ open-url H{ } define-operation
|