--- /dev/null
+John Benediktsson
--- /dev/null
+! 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 ;
+
--- /dev/null
+! 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 ;
--- /dev/null
+Open URLs in your web browser
--- /dev/null
+! 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."
+} ;
--- /dev/null
+! 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
--- /dev/null
+! 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 ;
+