diff --git a/extra/alarms/alarms.factor b/extra/alarms/alarms.factor index 1ccfdcbd30..55a66c5231 100755 --- a/extra/alarms/alarms.factor +++ b/extra/alarms/alarms.factor @@ -85,5 +85,8 @@ PRIVATE> : later ( quot dt -- alarm ) from-now f add-alarm ; +: every ( quot dt -- alarm ) + [ from-now ] keep add-alarm ; + : cancel-alarm ( alarm -- ) alarm-entry [ alarms get-global heap-delete ] if-box? ; diff --git a/extra/http/client/client-tests.factor b/extra/http/client/client-tests.factor index 4fca1697a5..661f63ab59 100755 --- a/extra/http/client/client-tests.factor +++ b/extra/http/client/client-tests.factor @@ -23,6 +23,5 @@ tuple-syntax namespaces ; [ "http://www.apple.com/index.html" - request-with-url ] with-scope ] unit-test diff --git a/extra/http/client/client.factor b/extra/http/client/client.factor index b00032e259..f011ff537e 100755 --- a/extra/http/client/client.factor +++ b/extra/http/client/client.factor @@ -6,72 +6,76 @@ splitting calendar continuations accessors vectors io.encodings.latin1 io.encodings.binary ; IN: http.client +DEFER: http-request + +r >>path r> dup [ query>assoc ] when >>query ; -! This is all pretty complex because it needs to handle -! HTTP redirects, which might be absolute or relative : request-with-url ( url request -- request ) - clone dup "request" set swap parse-url >r >r store-path r> >>host r> >>port ; -DEFER: (http-request) - +! This is all pretty complex because it needs to handle +! HTTP redirects, which might be absolute or relative : absolute-redirect ( url -- request ) - "request" get request-with-url ; + request get request-with-url ; : relative-redirect ( path -- request ) - "request" get swap store-path ; + request get swap store-path ; : do-redirect ( response -- response stream ) dup response-code 300 399 between? [ + stdio get dispose header>> "location" swap at dup "http://" head? [ absolute-redirect ] [ relative-redirect - ] if "GET" >>method (http-request) + ] if "GET" >>method http-request ] [ stdio get ] if ; -: (http-request) ( request -- response stream ) - dup host>> over port>> latin1 stdio set - dup "r" set-global write-request flush read-response - do-redirect ; +: request-addr ( request -- addr ) + dup host>> swap port>> ; + +: close-on-error ( stream quot -- ) + [ with-stream* ] curry [ ] pick [ dispose ] curry cleanup ; + inline PRIVATE> -: http-request ( url request -- response stream ) - [ - request-with-url +: http-request ( request -- response stream ) + dup request [ + dup request-addr latin1 + 1 minutes over set-timeout [ - (http-request) - 1 minutes over set-timeout - ] [ ] [ stdio get dispose ] cleanup - ] with-scope ; + write-request flush + read-response + do-redirect + ] close-on-error + ] with-variable ; -: ( -- request ) - "GET" >>method ; +: ( url -- request ) + request-with-url "GET" >>method ; : http-get-stream ( url -- response stream ) http-request ; : success? ( code -- ? ) 200 = ; -: check-response ( response stream -- stream ) - swap code>> success? - [ dispose "HTTP download failed" throw ] unless ; +: check-response ( response -- ) + code>> success? + [ "HTTP download failed" throw ] unless ; : http-get ( url -- string ) - http-get-stream check-response contents ; + http-get-stream contents swap check-response ; : download-name ( url -- name ) file-name "?" split1 drop "/" ?tail drop ; @@ -84,12 +88,13 @@ PRIVATE> : download ( url -- ) dup download-name download-to ; -: ( content-type content -- request ) +: ( content-type content url -- request ) + request-with-url "POST" >>method swap >>post-data swap >>post-data-type ; : http-post ( content-type content url -- response string ) #! The content is URL encoded for you. - -rot url-encode http-request contents ; + >r url-encode r> http-request contents ; diff --git a/extra/http/http-tests.factor b/extra/http/http-tests.factor index b706f34d13..16be0d026d 100755 --- a/extra/http/http-tests.factor +++ b/extra/http/http-tests.factor @@ -127,3 +127,30 @@ read-response-test-1' 1array [ "rmid=732423sdfs73242; path=/; domain=.example.net; expires=Fri, 31-Dec-2010 23:59:59 GMT" dup parse-cookies unparse-cookies = ] unit-test + +! Live-fire exercise +USING: http.server http.server.static http.server.actions +http.client io.server io.files io accessors namespaces threads +io.encodings.ascii ; + +[ ] [ + [ + + + [ stop-server "text/html" [ "Goodbye" write ] >>body ] >>get + "quit" add-responder + "extra/http/test" resource-path >>default + default-host set + + [ 1237 httpd ] "HTTPD test" spawn drop + ] with-scope +] unit-test + +[ t ] [ + "extra/http/test/foo.html" resource-path ascii file-contents + "http://localhost:1237/foo.html" http-get = +] unit-test + +[ "Goodbye" ] [ + "http://localhost:1237/quit" http-get +] unit-test diff --git a/extra/http/server/cgi/cgi.factor b/extra/http/server/cgi/cgi.factor index 9950a9a4a4..cce3e5402d 100755 --- a/extra/http/server/cgi/cgi.factor +++ b/extra/http/server/cgi/cgi.factor @@ -41,18 +41,17 @@ IN: http.server.cgi ] when ] H{ } make-assoc ; -: cgi-descriptor ( name -- desc ) - [ - dup 1array +arguments+ set - cgi-variables +environment+ set - ] H{ } make-assoc ; +: ( name -- desc ) + + over 1array >>command + swap cgi-variables >>environment ; : serve-cgi ( name -- response ) 200 >>code "CGI output follows" >>message swap [ - stdio get swap cgi-descriptor [ + stdio get swap [ post? [ request get post-data>> write flush ] when diff --git a/extra/http/server/static/static.factor b/extra/http/server/static/static.factor index 8d47d38eb1..93eb51ce4e 100755 --- a/extra/http/server/static/static.factor +++ b/extra/http/server/static/static.factor @@ -3,7 +3,7 @@ USING: calendar html io io.files kernel math math.parser http http.server namespaces parser sequences strings assocs hashtables debugger http.mime sorting html.elements logging -calendar.format new-slots accessors ; +calendar.format new-slots accessors io.encodings.binary ; IN: http.server.static SYMBOL: responder @@ -33,7 +33,7 @@ TUPLE: file-responder root hook special ; over file-length "content-length" set-header over file-http-date "last-modified" set-header - swap [ stdio get stream-copy ] curry >>body + swap [ binary stdio get stream-copy ] curry >>body ] ; : serve-static ( filename mime-type -- response ) diff --git a/extra/http/test/foo.html b/extra/http/test/foo.html new file mode 100644 index 0000000000..2638986853 --- /dev/null +++ b/extra/http/test/foo.html @@ -0,0 +1 @@ +HelloHTTPd test diff --git a/extra/io/server/server.factor b/extra/io/server/server.factor index 4267f7d1e8..0b7e626908 100755 --- a/extra/io/server/server.factor +++ b/extra/io/server/server.factor @@ -40,11 +40,11 @@ PRIVATE> f swap t resolve-host ; : with-server ( seq service encoding quot -- ) - V{ } clone [ - swap servers [ + V{ } clone servers [ + [ [ server-loop ] 2curry with-logging - ] with-variable - ] 3curry curry parallel-each ; inline + ] 3curry parallel-each + ] with-variable ; inline : stop-server ( -- ) servers get [ dispose ] each ; diff --git a/extra/logging/analysis/analysis.factor b/extra/logging/analysis/analysis.factor index b530c09b22..e2c77377ac 100755 --- a/extra/logging/analysis/analysis.factor +++ b/extra/logging/analysis/analysis.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. USING: kernel sequences namespaces words assocs logging sorting -prettyprint io io.styles strings logging.parser ; +prettyprint io io.styles strings logging.parser calendar.format ; IN: logging.analysis SYMBOL: word-names @@ -42,16 +42,14 @@ SYMBOL: message-histogram ] tabular-output ; : log-entry. - [ - dup first [ write ] with-cell - dup second [ pprint ] with-cell - dup third [ write ] with-cell - fourth "\n" join [ write ] with-cell - ] with-row ; + "====== " write + dup first (timestamp>string) bl + dup second pprint bl + dup third write nl + fourth "\n" join print ; : errors. ( errors -- ) - standard-table-style - [ [ log-entry. ] each ] tabular-output ; + [ log-entry. ] each ; : analysis. ( errors word-histogram message-histogram -- ) "==== INTERESTING MESSAGES:" print nl diff --git a/extra/logging/insomniac/insomniac.factor b/extra/logging/insomniac/insomniac.factor index 0294085eda..dfd7f430d2 100755 --- a/extra/logging/insomniac/insomniac.factor +++ b/extra/logging/insomniac/insomniac.factor @@ -1,8 +1,9 @@ ! Copyright (C) 2008 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: logging.analysis logging.server logging smtp io.sockets -kernel io.files io.streams.string namespaces raptor.cron assocs -io.encodings.utf8 ; +USING: logging.analysis logging.server logging smtp kernel +io.files io.streams.string namespaces alarms assocs +io.encodings.utf8 accessors calendar qualified ; +QUALIFIED: io.sockets IN: logging.insomniac SYMBOL: insomniac-smtp-host @@ -25,17 +26,20 @@ SYMBOL: insomniac-recipients ] with-scope ; inline : email-subject ( service -- string ) - [ "[INSOMNIAC] " % % " on " % host-name % ] "" make ; + [ + "[INSOMNIAC] " % % " on " % io.sockets:host-name % + ] "" make ; : (email-log-report) ( service word-names -- ) [ - over >r - ?analyze-log dup [ - r> email-subject - insomniac-recipients get - insomniac-sender get - send-simple-message - ] [ r> 2drop ] if + dupd ?analyze-log dup [ + + swap >>body + insomniac-recipients get >>to + insomniac-sender get >>from + swap email-subject >>subject + send + ] [ 2drop ] if ] with-insomniac-smtp ; \ (email-log-report) NOTICE add-error-logging @@ -44,6 +48,5 @@ SYMBOL: insomniac-recipients "logging.insomniac" [ (email-log-report) ] with-logging ; : schedule-insomniac ( service word-names -- ) - { 25 } { 6 } f f f -rot [ - [ email-log-report ] assoc-each rotate-logs - ] 2curry schedule ; + [ [ email-log-report ] assoc-each rotate-logs ] 2curry + 1 days every drop ; diff --git a/extra/slides/slides.factor b/extra/slides/slides.factor index a0065d6fe3..b58253381c 100755 --- a/extra/slides/slides.factor +++ b/extra/slides/slides.factor @@ -6,10 +6,14 @@ IN: slides : stylesheet H{ - { default-style + { default-span-style H{ { font "sans-serif" } { font-size 36 } + } + } + { default-block-style + H{ { wrap-margin 1000 } } } diff --git a/misc/macos-release.sh b/misc/macos-release.sh deleted file mode 100644 index 3a080e0ae6..0000000000 --- a/misc/macos-release.sh +++ /dev/null @@ -1,35 +0,0 @@ -source misc/version.sh - -TARGET=$1 - -if [ "$1" = "x86" ]; then - CPU="x86.32" - TARGET=macosx-x86-32 -else - CPU="macosx-ppc" - TARGET=macosx-ppc -fi - -BOOT_IMAGE=boot.$CPU.image -wget http://factorcode.org/images/$VERSION/$BOOT_IMAGE - -make $TARGET -Factor.app/Contents/MacOS/factor -i=$BOOT_IMAGE -no-user-init - -DISK_IMAGE_DIR=Factor-$VERSION -DISK_IMAGE=Factor-$VERSION-$TARGET.dmg - -rm -f $DISK_IMAGE -rm -rf $DISK_IMAGE_DIR -mkdir $DISK_IMAGE_DIR -mkdir -p $DISK_IMAGE_DIR/Factor/ -cp -R Factor.app $DISK_IMAGE_DIR/Factor/Factor.app -chmod +x cp_dir -cp factor.image license.txt README.txt $DISK_IMAGE_DIR/Factor/ -find core extra fonts misc unmaintained -type f \ - -exec ./cp_dir {} $DISK_IMAGE_DIR/Factor/{} \; -hdiutil create -srcfolder "$DISK_IMAGE_DIR" -fs HFS+ \ - -volname "$DISK_IMAGE_DIR" "$DISK_IMAGE" - -ssh linode mkdir -p w/downloads/$VERSION/ -scp $DISK_IMAGE linode:w/downloads/$VERSION/ diff --git a/misc/source-release.sh b/misc/source-release.sh deleted file mode 100755 index 6b1bb2dafc..0000000000 --- a/misc/source-release.sh +++ /dev/null @@ -1,7 +0,0 @@ -source misc/version.sh -rm -rf .git .gitignore -cd .. -tar cfz Factor-$VERSION.tar.gz factor/ - -ssh linode mkdir -p w/downloads/$VERSION/ -scp Factor-$VERSION.tar.gz linode:w/downloads/$VERSION/ diff --git a/misc/windows-release.sh b/misc/windows-release.sh deleted file mode 100755 index 7c3941a39a..0000000000 --- a/misc/windows-release.sh +++ /dev/null @@ -1,31 +0,0 @@ -source misc/version.sh - -CPU=$1 - -if [ "$CPU" = "x86" ]; then - FLAGS="-no-sse2" -fi - -make windows-nt-x86-32 - -wget http://factorcode.org/dlls/freetype6.dll -wget http://factorcode.org/dlls/zlib1.dll -wget http://factorcode.org/images/$VERSION/boot.x86.32.image - -CMD="./factor-nt -i=boot.x86.32.image -no-user-init $FLAGS" -echo $CMD -$CMD -rm -rf .git/ .gitignore -rm -rf Factor.app/ -rm -rf vm/ -rm -f Makefile -rm -f cp_dir -rm -f boot.*.image - -FILE=Factor-$VERSION-win32-$CPU.zip - -cd .. -zip -r $FILE Factor/ - -ssh linode mkdir -p w/downloads/$VERSION/ -scp $FILE linode:w/downloads/$VERSION/ diff --git a/extra/webapps/fjsc/authors.txt b/unmaintained/webapps/fjsc/authors.txt similarity index 100% rename from extra/webapps/fjsc/authors.txt rename to unmaintained/webapps/fjsc/authors.txt diff --git a/extra/webapps/fjsc/fjsc.factor b/unmaintained/webapps/fjsc/fjsc.factor similarity index 100% rename from extra/webapps/fjsc/fjsc.factor rename to unmaintained/webapps/fjsc/fjsc.factor diff --git a/extra/webapps/fjsc/head.furnace b/unmaintained/webapps/fjsc/head.furnace similarity index 100% rename from extra/webapps/fjsc/head.furnace rename to unmaintained/webapps/fjsc/head.furnace diff --git a/extra/webapps/fjsc/repl.furnace b/unmaintained/webapps/fjsc/repl.furnace similarity index 100% rename from extra/webapps/fjsc/repl.furnace rename to unmaintained/webapps/fjsc/repl.furnace diff --git a/extra/webapps/fjsc/resources/repl.js b/unmaintained/webapps/fjsc/resources/repl.js similarity index 100% rename from extra/webapps/fjsc/resources/repl.js rename to unmaintained/webapps/fjsc/resources/repl.js diff --git a/extra/webapps/fjsc/resources/termlib/faq.html b/unmaintained/webapps/fjsc/resources/termlib/faq.html similarity index 100% rename from extra/webapps/fjsc/resources/termlib/faq.html rename to unmaintained/webapps/fjsc/resources/termlib/faq.html diff --git a/extra/webapps/fjsc/resources/termlib/index.html b/unmaintained/webapps/fjsc/resources/termlib/index.html similarity index 100% rename from extra/webapps/fjsc/resources/termlib/index.html rename to unmaintained/webapps/fjsc/resources/termlib/index.html diff --git a/extra/webapps/fjsc/resources/termlib/multiterm_test.html b/unmaintained/webapps/fjsc/resources/termlib/multiterm_test.html similarity index 100% rename from extra/webapps/fjsc/resources/termlib/multiterm_test.html rename to unmaintained/webapps/fjsc/resources/termlib/multiterm_test.html diff --git a/extra/webapps/fjsc/resources/termlib/parser_sample.html b/unmaintained/webapps/fjsc/resources/termlib/parser_sample.html similarity index 100% rename from extra/webapps/fjsc/resources/termlib/parser_sample.html rename to unmaintained/webapps/fjsc/resources/termlib/parser_sample.html diff --git a/extra/webapps/fjsc/resources/termlib/readme.txt b/unmaintained/webapps/fjsc/resources/termlib/readme.txt similarity index 100% rename from extra/webapps/fjsc/resources/termlib/readme.txt rename to unmaintained/webapps/fjsc/resources/termlib/readme.txt diff --git a/extra/webapps/fjsc/resources/termlib/term_styles.css b/unmaintained/webapps/fjsc/resources/termlib/term_styles.css similarity index 100% rename from extra/webapps/fjsc/resources/termlib/term_styles.css rename to unmaintained/webapps/fjsc/resources/termlib/term_styles.css diff --git a/extra/webapps/fjsc/resources/termlib/termlib.js b/unmaintained/webapps/fjsc/resources/termlib/termlib.js similarity index 100% rename from extra/webapps/fjsc/resources/termlib/termlib.js rename to unmaintained/webapps/fjsc/resources/termlib/termlib.js diff --git a/extra/webapps/fjsc/resources/termlib/termlib_parser.js b/unmaintained/webapps/fjsc/resources/termlib/termlib_parser.js similarity index 100% rename from extra/webapps/fjsc/resources/termlib/termlib_parser.js rename to unmaintained/webapps/fjsc/resources/termlib/termlib_parser.js diff --git a/extra/webapps/fjsc/summary.txt b/unmaintained/webapps/fjsc/summary.txt similarity index 100% rename from extra/webapps/fjsc/summary.txt rename to unmaintained/webapps/fjsc/summary.txt diff --git a/extra/webapps/fjsc/tags.txt b/unmaintained/webapps/fjsc/tags.txt similarity index 100% rename from extra/webapps/fjsc/tags.txt rename to unmaintained/webapps/fjsc/tags.txt diff --git a/extra/webapps/help/authors.txt b/unmaintained/webapps/help/authors.txt similarity index 100% rename from extra/webapps/help/authors.txt rename to unmaintained/webapps/help/authors.txt diff --git a/extra/webapps/help/help.factor b/unmaintained/webapps/help/help.factor similarity index 100% rename from extra/webapps/help/help.factor rename to unmaintained/webapps/help/help.factor diff --git a/extra/webapps/numbers/authors.txt b/unmaintained/webapps/numbers/authors.txt similarity index 100% rename from extra/webapps/numbers/authors.txt rename to unmaintained/webapps/numbers/authors.txt diff --git a/extra/webapps/numbers/numbers.factor b/unmaintained/webapps/numbers/numbers.factor similarity index 100% rename from extra/webapps/numbers/numbers.factor rename to unmaintained/webapps/numbers/numbers.factor diff --git a/extra/webapps/pastebin/annotate-paste.furnace b/unmaintained/webapps/pastebin/annotate-paste.furnace similarity index 100% rename from extra/webapps/pastebin/annotate-paste.furnace rename to unmaintained/webapps/pastebin/annotate-paste.furnace diff --git a/extra/webapps/pastebin/annotation.furnace b/unmaintained/webapps/pastebin/annotation.furnace similarity index 100% rename from extra/webapps/pastebin/annotation.furnace rename to unmaintained/webapps/pastebin/annotation.furnace diff --git a/extra/webapps/pastebin/authors.txt b/unmaintained/webapps/pastebin/authors.txt similarity index 100% rename from extra/webapps/pastebin/authors.txt rename to unmaintained/webapps/pastebin/authors.txt diff --git a/extra/webapps/pastebin/footer.furnace b/unmaintained/webapps/pastebin/footer.furnace similarity index 100% rename from extra/webapps/pastebin/footer.furnace rename to unmaintained/webapps/pastebin/footer.furnace diff --git a/extra/webapps/pastebin/header.furnace b/unmaintained/webapps/pastebin/header.furnace similarity index 100% rename from extra/webapps/pastebin/header.furnace rename to unmaintained/webapps/pastebin/header.furnace diff --git a/extra/webapps/pastebin/modes.furnace b/unmaintained/webapps/pastebin/modes.furnace similarity index 100% rename from extra/webapps/pastebin/modes.furnace rename to unmaintained/webapps/pastebin/modes.furnace diff --git a/extra/webapps/pastebin/new-paste.furnace b/unmaintained/webapps/pastebin/new-paste.furnace similarity index 100% rename from extra/webapps/pastebin/new-paste.furnace rename to unmaintained/webapps/pastebin/new-paste.furnace diff --git a/extra/webapps/pastebin/paste-list.furnace b/unmaintained/webapps/pastebin/paste-list.furnace similarity index 100% rename from extra/webapps/pastebin/paste-list.furnace rename to unmaintained/webapps/pastebin/paste-list.furnace diff --git a/extra/webapps/pastebin/paste-summary.furnace b/unmaintained/webapps/pastebin/paste-summary.furnace similarity index 100% rename from extra/webapps/pastebin/paste-summary.furnace rename to unmaintained/webapps/pastebin/paste-summary.furnace diff --git a/extra/webapps/pastebin/pastebin.factor b/unmaintained/webapps/pastebin/pastebin.factor similarity index 100% rename from extra/webapps/pastebin/pastebin.factor rename to unmaintained/webapps/pastebin/pastebin.factor diff --git a/extra/webapps/pastebin/show-paste.furnace b/unmaintained/webapps/pastebin/show-paste.furnace similarity index 100% rename from extra/webapps/pastebin/show-paste.furnace rename to unmaintained/webapps/pastebin/show-paste.furnace diff --git a/extra/webapps/pastebin/style.css b/unmaintained/webapps/pastebin/style.css similarity index 100% rename from extra/webapps/pastebin/style.css rename to unmaintained/webapps/pastebin/style.css diff --git a/extra/webapps/pastebin/syntax.furnace b/unmaintained/webapps/pastebin/syntax.furnace similarity index 100% rename from extra/webapps/pastebin/syntax.furnace rename to unmaintained/webapps/pastebin/syntax.furnace diff --git a/extra/webapps/planet/authors.txt b/unmaintained/webapps/planet/authors.txt similarity index 100% rename from extra/webapps/planet/authors.txt rename to unmaintained/webapps/planet/authors.txt diff --git a/extra/webapps/planet/planet.factor b/unmaintained/webapps/planet/planet.factor similarity index 100% rename from extra/webapps/planet/planet.factor rename to unmaintained/webapps/planet/planet.factor diff --git a/extra/webapps/planet/planet.furnace b/unmaintained/webapps/planet/planet.furnace similarity index 100% rename from extra/webapps/planet/planet.furnace rename to unmaintained/webapps/planet/planet.furnace diff --git a/extra/webapps/planet/style.css b/unmaintained/webapps/planet/style.css similarity index 100% rename from extra/webapps/planet/style.css rename to unmaintained/webapps/planet/style.css