From 1edc5b645e227616e9d329fcd18deee750bd7155 Mon Sep 17 00:00:00 2001 From: "chris.double" Date: Mon, 17 Jul 2006 09:13:29 +0000 Subject: [PATCH] get cont-responder examples test1 and test2 working --- contrib/httpd/examples/cont-examples.factor | 23 ++++++++++----------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/contrib/httpd/examples/cont-examples.factor b/contrib/httpd/examples/cont-examples.factor index 3de5f6ee1e..7a838f17de 100644 --- a/contrib/httpd/examples/cont-examples.factor +++ b/contrib/httpd/examples/cont-examples.factor @@ -24,11 +24,11 @@ ! Simple test applications IN: cont-examples USE: cont-responder +USE: hashtables USE: html USE: kernel USE: io USE: html -USE: lists USE: strings USE: math USE: namespaces @@ -40,24 +40,24 @@ USE: sequences #! Display a page with some text to test the cont-responder. #! The page has a link to the 'next' continuation. [ +

over write

swap [ "Next" write ] html-document - ] show drop drop ; + ] show drop ; : display-get-name-page ( -- name ) #! Display a page prompting for input of a name and return that name. - [ + dup [ "Enter your name" [ +

swap write

"Name: " write
] html-document - ] show [ - "name" get - ] bind ; + ] show "name" swap hash ; : test-cont-responder ( - ) #! Test the cont-responder responder by displaying a few pages in a row. @@ -67,22 +67,21 @@ USE: sequences : test-cont-responder2 ( - ) #! Test the cont-responder responder by displaying a few pages in a loop. - [ "one" "two" "three" "four" ] [ display-page [ .s ] string-out display-page ] each + [ "one" "two" "three" "four" ] [ display-page ] each "Done!" display-page ; : test-cont-responder3 ( - ) #! Test the quot-href word by displaying a menu of the current - #! test words. Note that we drop the 'url' argument to the show - #! quotation as we don't link to a 'next' page. + #! test words. Note that we use show-final as we don't link to a 'next' page. [ - drop "Menu" [ +

"Menu" write

  1. "Test responder1" [ test-cont-responder ] quot-href
  2. "Test responder2" [ [ .s ] string-out display-page test-cont-responder2 [ .s ] string-out display-page ] quot-href
] html-document - ] show drop ; + ] show-final ; : counter-example ( count - ) #! Display a counter which can be incremented or decremented @@ -119,6 +118,6 @@ USE: sequences ! Install the examples "counter1" [ drop 0 counter-example ] install-cont-responder "counter2" [ drop counter-example2 ] install-cont-responder -"test1" [ drop test-cont-responder ] install-cont-responder +"test1" [ test-cont-responder ] install-cont-responder "test2" [ drop test-cont-responder2 ] install-cont-responder "test3" [ drop test-cont-responder3 ] install-cont-responder