Because the word can open more stuff than just files.
bundle-name
[ "Contents/Resources" copy-resources ]
[ "Contents/Frameworks" copy-libraries ] 2bi
- open-directory-after-deploy? get [ bundle-name open-file ] when ;
+ open-directory-after-deploy? get [ bundle-name open-item ] when ;
: deploy-app-bundle? ( vocab -- ? )
deploy-config [ deploy-console? get not deploy-ui? get or ] with-variables ;
[ drop deployed-image-name ]
[ drop namespace make-deploy-image-executable ]
[ nip "" [ copy-resources ] [ copy-libraries ] 3bi ]
- [ nip open-directory-after-deploy? get [ open-file ] [ drop ] if ]
+ [ nip open-directory-after-deploy? get [ open-item ] [ drop ] if ]
} 2cleave ;
M: unix deploy-path
[ drop deployed-image-name ]
[ drop namespace make-deploy-image-executable ]
[ nip "" [ copy-resources ] [ copy-libraries ] 3bi ]
- [ nip open-directory-after-deploy? get [ open-file ] [ drop ] if ]
+ [ nip open-directory-after-deploy? get [ open-item ] [ drop ] if ]
} 2cleave ;
M: windows deploy-path
IN: webbrowser.linux
-M: linux open-file ( path -- )
+M: linux open-item ( item -- )
present "xdg-open" swap 2array run-detached drop ;
IN: webbrowser.macosx
-M: macosx open-file ( path -- )
+M: macosx open-item ( item -- )
present "open" swap 2array run-detached drop ;
! Copyright (C) 2011 John Benediktsson
! See http://factorcode.org/license.txt for BSD license
-USING: help.markup help.syntax strings webbrowser ;
+USING: help.markup help.syntax kernel present strings ;
IN: webbrowser
-HELP: open-file
-{ $values { "path" string } }
+HELP: open-item
+{ $values { "item" object } }
{ $description
- "Open a specified file or directory in a detached process using "
- "the default application, similar to double-clicking the file's icon."
-} ;
+ "Opens an item, which is either a file, directory or url in a detached process using the default application, similar to double-clicking the file's icon. item is any object that has the " { $link present } " method." } ;
HELP: open-url
{ $values { "url" string } }
-USING: tools.test ;
+USING: io.pathnames tools.test ;
IN: webbrowser
{ t } [ "http://reddit.com" url-string? ] unit-test
{ t } [ "ftp://reddit.com" url-string? ] unit-test
{ f } [ "moo" url-string? ] unit-test
{ f } [ 123 url-string? ] unit-test
+
+{ } [ "" absolute-path open-item ] unit-test
! Copyright (C) 2011 John Benediktsson
! See http://factorcode.org/license.txt for BSD license
-
USING: accessors io.pathnames kernel sequences strings system
ui.operations urls vocabs ;
-
IN: webbrowser
-HOOK: open-file os ( path -- )
+HOOK: open-item os ( item -- )
"webbrowser." os name>> append require
: open-url ( url -- )
- >url open-file ;
-
-[ pathname? ] \ open-file H{ } define-operation
-
-[ url? ] \ open-url H{ } define-operation
+ >url open-item ;
PREDICATE: url-string < string >url protocol>> >boolean ;
-[ url-string? ] \ open-url H{ } define-operation
+[ pathname? ] \ open-item H{ } define-operation
+[ [ url? ] [ url-string? ] bi or ] \ open-url H{ } define-operation
windows.user32 ;
IN: webbrowser.windows
-M: windows open-file ( path -- )
+M: windows open-item ( item -- )
absolute-path [ f "open" ] dip present f f
SW_SHOWNORMAL ShellExecute drop ;