From 5f5098617a006115ae9171f3cd0552839dd8c4b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Lindqvist?= Date: Sun, 18 Dec 2016 03:23:24 +0100 Subject: [PATCH] webbrowser: let's change the name open-file -> open-item Because the word can open more stuff than just files. --- basis/tools/deploy/macosx/macosx.factor | 2 +- basis/tools/deploy/unix/unix.factor | 2 +- basis/tools/deploy/windows/windows.factor | 2 +- basis/webbrowser/linux/linux.factor | 2 +- basis/webbrowser/macosx/macosx.factor | 2 +- basis/webbrowser/webbrowser-docs.factor | 10 ++++------ basis/webbrowser/webbrowser-tests.factor | 4 +++- basis/webbrowser/webbrowser.factor | 13 ++++--------- basis/webbrowser/windows/windows.factor | 2 +- 9 files changed, 17 insertions(+), 22 deletions(-) diff --git a/basis/tools/deploy/macosx/macosx.factor b/basis/tools/deploy/macosx/macosx.factor index 782e09781d..215914dcab 100644 --- a/basis/tools/deploy/macosx/macosx.factor +++ b/basis/tools/deploy/macosx/macosx.factor @@ -81,7 +81,7 @@ IN: tools.deploy.macosx 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 ; diff --git a/basis/tools/deploy/unix/unix.factor b/basis/tools/deploy/unix/unix.factor index a8a37c69d1..16676ab8b4 100644 --- a/basis/tools/deploy/unix/unix.factor +++ b/basis/tools/deploy/unix/unix.factor @@ -15,7 +15,7 @@ M: unix deploy* [ 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 diff --git a/basis/tools/deploy/windows/windows.factor b/basis/tools/deploy/windows/windows.factor index ff0f417854..d4d9388f63 100755 --- a/basis/tools/deploy/windows/windows.factor +++ b/basis/tools/deploy/windows/windows.factor @@ -33,7 +33,7 @@ M: windows deploy* [ 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 diff --git a/basis/webbrowser/linux/linux.factor b/basis/webbrowser/linux/linux.factor index 8f3d518c46..e5ae19ec26 100644 --- a/basis/webbrowser/linux/linux.factor +++ b/basis/webbrowser/linux/linux.factor @@ -5,5 +5,5 @@ USING: arrays io.launcher kernel present system webbrowser ; IN: webbrowser.linux -M: linux open-file ( path -- ) +M: linux open-item ( item -- ) present "xdg-open" swap 2array run-detached drop ; diff --git a/basis/webbrowser/macosx/macosx.factor b/basis/webbrowser/macosx/macosx.factor index 3b4c642146..9975c3ce29 100644 --- a/basis/webbrowser/macosx/macosx.factor +++ b/basis/webbrowser/macosx/macosx.factor @@ -5,5 +5,5 @@ USING: arrays io.launcher kernel present system webbrowser ; IN: webbrowser.macosx -M: macosx open-file ( path -- ) +M: macosx open-item ( item -- ) present "open" swap 2array run-detached drop ; diff --git a/basis/webbrowser/webbrowser-docs.factor b/basis/webbrowser/webbrowser-docs.factor index d537f2806a..8449502ad3 100644 --- a/basis/webbrowser/webbrowser-docs.factor +++ b/basis/webbrowser/webbrowser-docs.factor @@ -1,16 +1,14 @@ ! 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 } } diff --git a/basis/webbrowser/webbrowser-tests.factor b/basis/webbrowser/webbrowser-tests.factor index e667e35c0e..1bc174907f 100644 --- a/basis/webbrowser/webbrowser-tests.factor +++ b/basis/webbrowser/webbrowser-tests.factor @@ -1,4 +1,4 @@ -USING: tools.test ; +USING: io.pathnames tools.test ; IN: webbrowser { t } [ "http://reddit.com" url-string? ] unit-test @@ -6,3 +6,5 @@ IN: webbrowser { 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 diff --git a/basis/webbrowser/webbrowser.factor b/basis/webbrowser/webbrowser.factor index 2bcfccb588..a712fb1f5a 100644 --- a/basis/webbrowser/webbrowser.factor +++ b/basis/webbrowser/webbrowser.factor @@ -1,22 +1,17 @@ ! 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 diff --git a/basis/webbrowser/windows/windows.factor b/basis/webbrowser/windows/windows.factor index 2ec409eddd..705de35b9c 100644 --- a/basis/webbrowser/windows/windows.factor +++ b/basis/webbrowser/windows/windows.factor @@ -4,6 +4,6 @@ USING: io.pathnames kernel present system webbrowser windows.shell32 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 ;