webbrowser: let's change the name open-file -> open-item
Because the word can open more stuff than just files.char-rename
parent
88015e9632
commit
5f5098617a
|
@ -81,7 +81,7 @@ IN: tools.deploy.macosx
|
||||||
bundle-name
|
bundle-name
|
||||||
[ "Contents/Resources" copy-resources ]
|
[ "Contents/Resources" copy-resources ]
|
||||||
[ "Contents/Frameworks" copy-libraries ] 2bi
|
[ "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-app-bundle? ( vocab -- ? )
|
||||||
deploy-config [ deploy-console? get not deploy-ui? get or ] with-variables ;
|
deploy-config [ deploy-console? get not deploy-ui? get or ] with-variables ;
|
||||||
|
|
|
@ -15,7 +15,7 @@ M: unix deploy*
|
||||||
[ drop deployed-image-name ]
|
[ drop deployed-image-name ]
|
||||||
[ drop namespace make-deploy-image-executable ]
|
[ drop namespace make-deploy-image-executable ]
|
||||||
[ nip "" [ copy-resources ] [ copy-libraries ] 3bi ]
|
[ 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 ;
|
} 2cleave ;
|
||||||
|
|
||||||
M: unix deploy-path
|
M: unix deploy-path
|
||||||
|
|
|
@ -33,7 +33,7 @@ M: windows deploy*
|
||||||
[ drop deployed-image-name ]
|
[ drop deployed-image-name ]
|
||||||
[ drop namespace make-deploy-image-executable ]
|
[ drop namespace make-deploy-image-executable ]
|
||||||
[ nip "" [ copy-resources ] [ copy-libraries ] 3bi ]
|
[ 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 ;
|
} 2cleave ;
|
||||||
|
|
||||||
M: windows deploy-path
|
M: windows deploy-path
|
||||||
|
|
|
@ -5,5 +5,5 @@ USING: arrays io.launcher kernel present system webbrowser ;
|
||||||
|
|
||||||
IN: webbrowser.linux
|
IN: webbrowser.linux
|
||||||
|
|
||||||
M: linux open-file ( path -- )
|
M: linux open-item ( item -- )
|
||||||
present "xdg-open" swap 2array run-detached drop ;
|
present "xdg-open" swap 2array run-detached drop ;
|
||||||
|
|
|
@ -5,5 +5,5 @@ USING: arrays io.launcher kernel present system webbrowser ;
|
||||||
|
|
||||||
IN: webbrowser.macosx
|
IN: webbrowser.macosx
|
||||||
|
|
||||||
M: macosx open-file ( path -- )
|
M: macosx open-item ( item -- )
|
||||||
present "open" swap 2array run-detached drop ;
|
present "open" swap 2array run-detached drop ;
|
||||||
|
|
|
@ -1,16 +1,14 @@
|
||||||
! Copyright (C) 2011 John Benediktsson
|
! Copyright (C) 2011 John Benediktsson
|
||||||
! See http://factorcode.org/license.txt for BSD license
|
! 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
|
IN: webbrowser
|
||||||
|
|
||||||
HELP: open-file
|
HELP: open-item
|
||||||
{ $values { "path" string } }
|
{ $values { "item" object } }
|
||||||
{ $description
|
{ $description
|
||||||
"Open a specified file or directory in a detached process using "
|
"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." } ;
|
||||||
"the default application, similar to double-clicking the file's icon."
|
|
||||||
} ;
|
|
||||||
|
|
||||||
HELP: open-url
|
HELP: open-url
|
||||||
{ $values { "url" string } }
|
{ $values { "url" string } }
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
USING: tools.test ;
|
USING: io.pathnames tools.test ;
|
||||||
IN: webbrowser
|
IN: webbrowser
|
||||||
|
|
||||||
{ t } [ "http://reddit.com" url-string? ] unit-test
|
{ t } [ "http://reddit.com" url-string? ] unit-test
|
||||||
|
@ -6,3 +6,5 @@ IN: webbrowser
|
||||||
{ t } [ "ftp://reddit.com" url-string? ] unit-test
|
{ t } [ "ftp://reddit.com" url-string? ] unit-test
|
||||||
{ f } [ "moo" url-string? ] unit-test
|
{ f } [ "moo" url-string? ] unit-test
|
||||||
{ f } [ 123 url-string? ] unit-test
|
{ f } [ 123 url-string? ] unit-test
|
||||||
|
|
||||||
|
{ } [ "" absolute-path open-item ] unit-test
|
||||||
|
|
|
@ -1,22 +1,17 @@
|
||||||
! Copyright (C) 2011 John Benediktsson
|
! Copyright (C) 2011 John Benediktsson
|
||||||
! See http://factorcode.org/license.txt for BSD license
|
! See http://factorcode.org/license.txt for BSD license
|
||||||
|
|
||||||
USING: accessors io.pathnames kernel sequences strings system
|
USING: accessors io.pathnames kernel sequences strings system
|
||||||
ui.operations urls vocabs ;
|
ui.operations urls vocabs ;
|
||||||
|
|
||||||
IN: webbrowser
|
IN: webbrowser
|
||||||
|
|
||||||
HOOK: open-file os ( path -- )
|
HOOK: open-item os ( item -- )
|
||||||
|
|
||||||
"webbrowser." os name>> append require
|
"webbrowser." os name>> append require
|
||||||
|
|
||||||
: open-url ( url -- )
|
: open-url ( url -- )
|
||||||
>url open-file ;
|
>url open-item ;
|
||||||
|
|
||||||
[ pathname? ] \ open-file H{ } define-operation
|
|
||||||
|
|
||||||
[ url? ] \ open-url H{ } define-operation
|
|
||||||
|
|
||||||
PREDICATE: url-string < string >url protocol>> >boolean ;
|
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
|
||||||
|
|
|
@ -4,6 +4,6 @@ USING: io.pathnames kernel present system webbrowser windows.shell32
|
||||||
windows.user32 ;
|
windows.user32 ;
|
||||||
IN: webbrowser.windows
|
IN: webbrowser.windows
|
||||||
|
|
||||||
M: windows open-file ( path -- )
|
M: windows open-item ( item -- )
|
||||||
absolute-path [ f "open" ] dip present f f
|
absolute-path [ f "open" ] dip present f f
|
||||||
SW_SHOWNORMAL ShellExecute drop ;
|
SW_SHOWNORMAL ShellExecute drop ;
|
||||||
|
|
Loading…
Reference in New Issue