webbrowser: changing open-url to use open-file everywhere.

db4
John Benediktsson 2011-11-13 16:31:52 -08:00
parent 54dcd8a4ea
commit f98a6a7987
4 changed files with 11 additions and 24 deletions

View File

@ -1,13 +1,9 @@
! Copyright (C) 2011 John Benediktsson
! See http://factorcode.org/license.txt for BSD license
USING: formatting io.launcher present system urls webbrowser ;
USING: io.launcher kernel sequences system webbrowser ;
IN: webbrowser.unix
M: unix open-file ( path -- )
"gnome-open \"%s\"" sprintf try-process ;
M: unix open-url ( url -- )
>url present open-file ;
IN: webbrowser.linux
M: linux open-file ( path -- )
{ "gnome-open" } swap suffix try-process ;

View File

@ -1,15 +1,9 @@
! Copyright (C) 2011 John Benediktsson
! See http://factorcode.org/license.txt for BSD license
USING: formatting io.encodings.ascii io.launcher present system
urls webbrowser ;
USING: io.launcher kernel sequences system webbrowser ;
IN: webbrowser.macosx
M: macosx open-file ( path -- )
"open \"%s\"" sprintf try-process ;
M: macosx open-url ( url -- )
>url present "osascript" ascii [
"open location \"%s\"" printf
] with-process-writer ;
{ "open" } swap suffix try-process ;

View File

@ -1,18 +1,19 @@
! Copyright (C) 2011 John Benediktsson
! See http://factorcode.org/license.txt for BSD license
USING: combinators system ui.operations urls vocabs ;
USING: combinators present system ui.operations urls vocabs ;
IN: webbrowser
HOOK: open-file os ( path -- )
HOOK: open-url os ( url -- )
{
{ [ os macosx? ] [ "webbrowser.macosx" ] }
{ [ os linux? ] [ "webbrowser.linux" ] }
{ [ os windows? ] [ "webbrowser.windows" ] }
} cond require
: open-url ( url -- )
>url present open-file ;
[ url? ] \ open-url H{ } define-operation

View File

@ -1,13 +1,9 @@
! Copyright (C) 2011 John Benediktsson
! See http://factorcode.org/license.txt for BSD license
USING: present urls webbrowser windows.shell32 windows.user32 ;
USING: webbrowser windows.shell32 windows.user32 ;
IN: webbrowser.windows
M: windows open-file ( path -- )
[ f "open" ] dip f f SW_SHOWNORMAL ShellExecute drop ;
M: windows open-url ( url -- )
>url present open-file ;