: with-directory ( path quot -- )
[ absolute-path current-directory ] dip with-variable ; inline
+: with-resource-directory ( quot -- )
+ [ "resource:" ] dip with-directory ; inline
+
! Creating directories
HOOK: make-directory io-backend ( path -- )
[ % "/Contents/Resources/" % % ".image" % ] "" make ;
: deploy-app-bundle ( vocab -- )
- "resource:" [
+ [
dup deploy-config [
bundle-name dup exists? [ delete-tree ] [ drop ] if
[ bundle-name create-app-dir ] keep
[ "Contents/Frameworks" copy-libraries ] 2bi
bundle-name show-in-finder
] with-variables
- ] with-directory ;
+ ] with-resource-directory ;
: deploy-app-bundle? ( vocab -- ? )
deploy-config [ deploy-console? get not deploy-ui? get or ] with-variables ;
: shake-and-bake ( vocab -- )
[ test-image temp-file delete-file ] ignore-errors
- "resource:" [
+ [
[ vm test-image temp-file ] dip
dup deploy-config make-deploy-image drop
- ] with-directory ;
+ ] with-resource-directory ;
ERROR: image-too-big actual-size max-size ;
deploy-name get ;
M: unix deploy* ( vocab -- )
- "resource:" [
+ [
dup deploy-config [
[ bundle-name create-app-dir ] keep
[ deployed-image-name ] keep
bundle-name normalize-path "Binary deployed to " "." surround print
bundle-name webbrowser:open-file
] with-variables
- ] with-directory ;
+ ] with-resource-directory ;
[ 2drop ] if ;
M: windows deploy*
- "resource:" [
+ [
dup deploy-config [
deploy-name get
{
[ nip open-in-explorer ]
} 2cleave
] with-variables
- ] with-directory ;
+ ] with-resource-directory ;
! of the build directory, and they look for a file named
! build-support/cleanup there. Use with-directory here to
! ensure we use the file from the current source tree instead.
-"resource:" [
+[
[ f ] [
macosx target-os [
"Factor.app" useless-files member?
"Factor.app" useless-files member?
] with-variable
] unit-test
-] with-directory
+] with-resource-directory
! See http://factorcode.org/license.txt for BSD license.
USING: furnace furnace.actions furnace.redirection
http.server.dispatchers html.forms validators urls accessors
-math kernel ;
+math kernel io.directories ;
IN: webapps.calculator
TUPLE: calculator < dispatcher ;
: calculator-db ( -- db ) "calculator.db" <sqlite-db> ;
: run-calculator ( -- )
- <calculator>
- calculator-db <alloy>
- main-responder set-global
- 8080 httpd drop ;
+ [
+ <calculator>
+ calculator-db <alloy>
+ main-responder set-global
+ 8080 httpd drop
+ ] with-resource-directory ;
MAIN: run-calculator