From 17abc90d48ea58dc8093b9ff66cd0a2e46f25f71 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 7 Mar 2008 15:52:41 -0600 Subject: [PATCH 1/7] Updated http client --- extra/http/client/client.factor | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/extra/http/client/client.factor b/extra/http/client/client.factor index f7a160017a..b00032e259 100755 --- a/extra/http/client/client.factor +++ b/extra/http/client/client.factor @@ -2,7 +2,8 @@ ! See http://factorcode.org/license.txt for BSD license. USING: assocs http kernel math math.parser namespaces sequences io io.sockets io.streams.string io.files io.timeouts strings -splitting calendar continuations accessors vectors io.encodings.binary ; +splitting calendar continuations accessors vectors io.encodings.latin1 +io.encodings.binary ; IN: http.client : parse-url ( url -- resource host port ) @@ -42,7 +43,7 @@ DEFER: (http-request) ] if ; : (http-request) ( request -- response stream ) - dup host>> over port>> stdio set + dup host>> over port>> latin1 stdio set dup "r" set-global write-request flush read-response do-redirect ; From 915fd4e0f8f103b613523814f5a8712b2b2f6dbb Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Fri, 7 Mar 2008 16:45:11 -0600 Subject: [PATCH 2/7] fix two load errors --- extra/db/sqlite/sqlite.factor | 2 +- extra/html/parser/analyzer/analyzer.factor | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/extra/db/sqlite/sqlite.factor b/extra/db/sqlite/sqlite.factor index 643b42165d..d0bf721aa7 100755 --- a/extra/db/sqlite/sqlite.factor +++ b/extra/db/sqlite/sqlite.factor @@ -5,7 +5,7 @@ hashtables io.files kernel math math.parser namespaces prettyprint sequences strings tuples alien.c-types continuations db.sqlite.lib db.sqlite.ffi db.tuples words combinators.lib db.types combinators tools.walker -combinators.cleave io ; +combinators.cleave io namespaces.lib ; IN: db.sqlite TUPLE: sqlite-db path ; diff --git a/extra/html/parser/analyzer/analyzer.factor b/extra/html/parser/analyzer/analyzer.factor index 45197b1a90..1a60390f64 100755 --- a/extra/html/parser/analyzer/analyzer.factor +++ b/extra/html/parser/analyzer/analyzer.factor @@ -1,5 +1,6 @@ USING: assocs html.parser kernel math sequences strings ascii -arrays shuffle unicode.case namespaces splitting http ; +arrays shuffle unicode.case namespaces splitting http +sequences.lib ; IN: html.parser.analyzer : (find-relative) From 695dbe1a59b371d0811204883d652307cc0d9ead Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 7 Mar 2008 16:59:44 -0600 Subject: [PATCH 3/7] Move web apps to unmaintained/ for now; get more stuff in extra to load --- extra/alarms/alarms.factor | 3 +++ extra/http/server/cgi/cgi.factor | 11 ++++----- extra/logging/insomniac/insomniac.factor | 24 +++++++++---------- extra/slides/slides.factor | 6 ++++- .../webapps/fjsc/authors.txt | 0 .../webapps/fjsc/fjsc.factor | 0 .../webapps/fjsc/head.furnace | 0 .../webapps/fjsc/repl.furnace | 0 .../webapps/fjsc/resources/repl.js | 0 .../webapps/fjsc/resources/termlib/faq.html | 0 .../webapps/fjsc/resources/termlib/index.html | 0 .../resources/termlib/multiterm_test.html | 0 .../fjsc/resources/termlib/parser_sample.html | 0 .../webapps/fjsc/resources/termlib/readme.txt | 0 .../fjsc/resources/termlib/term_styles.css | 0 .../webapps/fjsc/resources/termlib/termlib.js | 0 .../fjsc/resources/termlib/termlib_parser.js | 0 .../webapps/fjsc/summary.txt | 0 {extra => unmaintained}/webapps/fjsc/tags.txt | 0 .../webapps/help/authors.txt | 0 .../webapps/help/help.factor | 0 .../webapps/numbers/authors.txt | 0 .../webapps/numbers/numbers.factor | 0 .../webapps/pastebin/annotate-paste.furnace | 0 .../webapps/pastebin/annotation.furnace | 0 .../webapps/pastebin/authors.txt | 0 .../webapps/pastebin/footer.furnace | 0 .../webapps/pastebin/header.furnace | 0 .../webapps/pastebin/modes.furnace | 0 .../webapps/pastebin/new-paste.furnace | 0 .../webapps/pastebin/paste-list.furnace | 0 .../webapps/pastebin/paste-summary.furnace | 0 .../webapps/pastebin/pastebin.factor | 0 .../webapps/pastebin/show-paste.furnace | 0 .../webapps/pastebin/style.css | 0 .../webapps/pastebin/syntax.furnace | 0 .../webapps/planet/authors.txt | 0 .../webapps/planet/planet.factor | 0 .../webapps/planet/planet.furnace | 0 .../webapps/planet/style.css | 0 40 files changed, 25 insertions(+), 19 deletions(-) rename {extra => unmaintained}/webapps/fjsc/authors.txt (100%) rename {extra => unmaintained}/webapps/fjsc/fjsc.factor (100%) rename {extra => unmaintained}/webapps/fjsc/head.furnace (100%) rename {extra => unmaintained}/webapps/fjsc/repl.furnace (100%) rename {extra => unmaintained}/webapps/fjsc/resources/repl.js (100%) rename {extra => unmaintained}/webapps/fjsc/resources/termlib/faq.html (100%) rename {extra => unmaintained}/webapps/fjsc/resources/termlib/index.html (100%) rename {extra => unmaintained}/webapps/fjsc/resources/termlib/multiterm_test.html (100%) rename {extra => unmaintained}/webapps/fjsc/resources/termlib/parser_sample.html (100%) rename {extra => unmaintained}/webapps/fjsc/resources/termlib/readme.txt (100%) rename {extra => unmaintained}/webapps/fjsc/resources/termlib/term_styles.css (100%) rename {extra => unmaintained}/webapps/fjsc/resources/termlib/termlib.js (100%) rename {extra => unmaintained}/webapps/fjsc/resources/termlib/termlib_parser.js (100%) rename {extra => unmaintained}/webapps/fjsc/summary.txt (100%) rename {extra => unmaintained}/webapps/fjsc/tags.txt (100%) rename {extra => unmaintained}/webapps/help/authors.txt (100%) rename {extra => unmaintained}/webapps/help/help.factor (100%) rename {extra => unmaintained}/webapps/numbers/authors.txt (100%) rename {extra => unmaintained}/webapps/numbers/numbers.factor (100%) rename {extra => unmaintained}/webapps/pastebin/annotate-paste.furnace (100%) rename {extra => unmaintained}/webapps/pastebin/annotation.furnace (100%) rename {extra => unmaintained}/webapps/pastebin/authors.txt (100%) rename {extra => unmaintained}/webapps/pastebin/footer.furnace (100%) rename {extra => unmaintained}/webapps/pastebin/header.furnace (100%) rename {extra => unmaintained}/webapps/pastebin/modes.furnace (100%) rename {extra => unmaintained}/webapps/pastebin/new-paste.furnace (100%) rename {extra => unmaintained}/webapps/pastebin/paste-list.furnace (100%) rename {extra => unmaintained}/webapps/pastebin/paste-summary.furnace (100%) rename {extra => unmaintained}/webapps/pastebin/pastebin.factor (100%) rename {extra => unmaintained}/webapps/pastebin/show-paste.furnace (100%) rename {extra => unmaintained}/webapps/pastebin/style.css (100%) rename {extra => unmaintained}/webapps/pastebin/syntax.furnace (100%) rename {extra => unmaintained}/webapps/planet/authors.txt (100%) rename {extra => unmaintained}/webapps/planet/planet.factor (100%) rename {extra => unmaintained}/webapps/planet/planet.furnace (100%) rename {extra => unmaintained}/webapps/planet/style.css (100%) 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/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/logging/insomniac/insomniac.factor b/extra/logging/insomniac/insomniac.factor index 0294085eda..83339af1c0 100755 --- a/extra/logging/insomniac/insomniac.factor +++ b/extra/logging/insomniac/insomniac.factor @@ -1,8 +1,8 @@ ! 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 ; +kernel io.files io.streams.string namespaces alarms assocs +io.encodings.utf8 accessors calendar ; IN: logging.insomniac SYMBOL: insomniac-smtp-host @@ -29,13 +29,14 @@ SYMBOL: insomniac-recipients : (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 +45,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/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 From c6c7269d45669a884fae67d9ff6189f17c0c7189 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 7 Mar 2008 17:00:55 -0600 Subject: [PATCH 4/7] Remove obsolete scripts --- misc/macos-release.sh | 35 ----------------------------------- misc/source-release.sh | 7 ------- misc/windows-release.sh | 31 ------------------------------- 3 files changed, 73 deletions(-) delete mode 100644 misc/macos-release.sh delete mode 100755 misc/source-release.sh delete mode 100755 misc/windows-release.sh 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/ From 71a1edf42665dee0bc6fc6c95e5ad275d92a1c28 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 7 Mar 2008 17:20:15 -0600 Subject: [PATCH 5/7] Fixing logging --- extra/logging/analysis/analysis.factor | 16 +++++++--------- extra/logging/insomniac/insomniac.factor | 11 +++++++---- 2 files changed, 14 insertions(+), 13 deletions(-) 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 83339af1c0..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 alarms assocs -io.encodings.utf8 accessors calendar ; +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,7 +26,9 @@ 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 -- ) [ From 68f276b444624a016f8b8ef4a337c3dcef594085 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Fri, 7 Mar 2008 17:21:20 -0600 Subject: [PATCH 6/7] HTTP server and client fixes --- extra/http/client/client-tests.factor | 1 - extra/http/client/client.factor | 63 ++++++++++++++------------ extra/http/http-tests.factor | 27 +++++++++++ extra/http/server/static/static.factor | 4 +- extra/http/test/foo.html | 1 + extra/io/server/server.factor | 8 ++-- 6 files changed, 68 insertions(+), 36 deletions(-) create mode 100644 extra/http/test/foo.html 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/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 ; From 9ffe013d0331c7619d7974f764ff126baeb1c9f0 Mon Sep 17 00:00:00 2001 From: Eduardo Cavazos Date: Fri, 7 Mar 2008 18:30:47 -0600 Subject: [PATCH 7/7] builder.*: lots of updates for the new language changes --- extra/builder/builder.factor | 2 +- extra/builder/test/test.factor | 14 ++++++++------ extra/builder/util/util.factor | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/extra/builder/builder.factor b/extra/builder/builder.factor index 728e87f28d..747f0cd1e5 100644 --- a/extra/builder/builder.factor +++ b/extra/builder/builder.factor @@ -102,7 +102,7 @@ SYMBOL: build-status enter-build-dir - "report" + "report" utf8 [ "Build machine: " write host-name print "CPU: " write cpu print diff --git a/extra/builder/test/test.factor b/extra/builder/test/test.factor index c664941132..d03be0781a 100644 --- a/extra/builder/test/test.factor +++ b/extra/builder/test/test.factor @@ -6,22 +6,24 @@ USING: kernel namespaces sequences assocs builder continuations prettyprint tools.browser tools.test + io.encodings.utf8 bootstrap.stage2 benchmark builder.util ; IN: builder.test : do-load ( -- ) - try-everything keys "../load-everything-vocabs" [ . ] with-file-writer ; + try-everything keys "../load-everything-vocabs" utf8 [ . ] with-file-writer ; : do-tests ( -- ) - run-all-tests keys "../test-all-vocabs" [ . ] with-file-writer ; + run-all-tests keys "../test-all-vocabs" utf8 [ . ] with-file-writer ; -: do-benchmarks ( -- ) run-benchmarks "../benchmarks" [ . ] with-file-writer ; +: do-benchmarks ( -- ) + run-benchmarks "../benchmarks" utf8 [ . ] with-file-writer ; : do-all ( -- ) - bootstrap-time get "../boot-time" [ . ] with-file-writer - [ do-load ] runtime "../load-time" [ . ] with-file-writer - [ do-tests ] runtime "../test-time" [ . ] with-file-writer + bootstrap-time get "../boot-time" utf8 [ . ] with-file-writer + [ do-load ] runtime "../load-time" utf8 [ . ] with-file-writer + [ do-tests ] runtime "../test-time" utf8 [ . ] with-file-writer do-benchmarks ; MAIN: do-all \ No newline at end of file diff --git a/extra/builder/util/util.factor b/extra/builder/util/util.factor index 50d74ddfc8..82514ca43d 100644 --- a/extra/builder/util/util.factor +++ b/extra/builder/util/util.factor @@ -70,7 +70,7 @@ DEFER: to-strings : milli-seconds>time ( n -- string ) 1000 /i 60 /mod >r 60 /mod r> 3array [ pad-00 ] map ":" join ; -: eval-file ( file -- obj ) file-contents eval ; +: eval-file ( file -- obj ) utf8 file-contents eval ; : cat ( file -- ) utf8 file-contents print ;