2011-11-12 19:18:52 -05:00
|
|
|
! Copyright (C) 2011 John Benediktsson
|
|
|
|
! See http://factorcode.org/license.txt for BSD license
|
|
|
|
|
2012-09-22 19:49:53 -04:00
|
|
|
USING: combinators combinators.short-circuit present sequences strings system
|
|
|
|
ui.operations urls vocabs ;
|
2011-11-12 19:18:52 -05:00
|
|
|
|
|
|
|
IN: webbrowser
|
|
|
|
|
|
|
|
HOOK: open-file os ( path -- )
|
|
|
|
|
|
|
|
{
|
|
|
|
{ [ os macosx? ] [ "webbrowser.macosx" ] }
|
|
|
|
{ [ os linux? ] [ "webbrowser.linux" ] }
|
|
|
|
{ [ os windows? ] [ "webbrowser.windows" ] }
|
|
|
|
} cond require
|
|
|
|
|
2011-11-13 19:31:52 -05:00
|
|
|
: open-url ( url -- )
|
|
|
|
>url present open-file ;
|
|
|
|
|
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
|