webbrowser: open url's in your webbrowser.
parent
340e69aef3
commit
e10e019f9f
|
@ -0,0 +1 @@
|
|||
John Benediktsson
|
|
@ -0,0 +1,13 @@
|
|||
! Copyright (C) 2011 John Benediktsson
|
||||
! See http://factorcode.org/license.txt for BSD license
|
||||
|
||||
USING: formatting io.launcher present system urls webbrowser ;
|
||||
|
||||
IN: webbrowser.unix
|
||||
|
||||
M: unix open-file ( path -- )
|
||||
"gnome-open \"%s\"" sprintf try-process ;
|
||||
|
||||
M: unix open-url ( url -- )
|
||||
>url present open-file ;
|
||||
|
|
@ -0,0 +1 @@
|
|||
linux
|
|
@ -0,0 +1,15 @@
|
|||
! 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 ;
|
||||
|
||||
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 ;
|
|
@ -0,0 +1 @@
|
|||
macosx
|
|
@ -0,0 +1 @@
|
|||
Open URLs in your web browser
|
|
@ -0,0 +1,19 @@
|
|||
! Copyright (C) 2011 John Benediktsson
|
||||
! See http://factorcode.org/license.txt for BSD license
|
||||
|
||||
USING: help.markup help.syntax strings webbrowser ;
|
||||
|
||||
IN: webbrowser
|
||||
|
||||
HELP: open-file
|
||||
{ $values { "path" string } }
|
||||
{ $description
|
||||
"Open a specified file or directory using the default "
|
||||
"application, similar to double-clicking the file's icon."
|
||||
} ;
|
||||
|
||||
HELP: open-url
|
||||
{ $values { "url" string } }
|
||||
{ $description
|
||||
"Open a specified url in the default web browser."
|
||||
} ;
|
|
@ -0,0 +1,18 @@
|
|||
! Copyright (C) 2011 John Benediktsson
|
||||
! See http://factorcode.org/license.txt for BSD license
|
||||
|
||||
USING: combinators 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
|
||||
|
||||
[ url? ] \ open-url H{ } define-operation
|
|
@ -0,0 +1 @@
|
|||
windows
|
|
@ -0,0 +1,13 @@
|
|||
! Copyright (C) 2011 John Benediktsson
|
||||
! See http://factorcode.org/license.txt for BSD license
|
||||
|
||||
USING: present urls 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 ;
|
||||
|
Loading…
Reference in New Issue