add browser style to words to allow browsing source. add browser and

cont-responder to factor httpd. add cont-responder tutorial to main doc
dicretory. mention location of cont-test.factor in tutorial. change
defauly startup location of browser.
cvs
Chris Double 2005-02-14 21:44:15 +00:00
parent a3a1cf8a8c
commit 0b3a34d0c8
9 changed files with 58 additions and 23 deletions

View File

@ -39,7 +39,6 @@ USE: random
USE: parser USE: parser
USE: html USE: html
USE: cont-responder USE: cont-responder
USE: cont-utils
USE: stdio USE: stdio
USE: namespaces USE: namespaces

View File

@ -26,7 +26,6 @@
IN: eval-responder IN: eval-responder
USE: html USE: html
USE: cont-responder USE: cont-responder
USE: cont-utils
USE: kernel USE: kernel
USE: stdio USE: stdio
USE: namespaces USE: namespaces
@ -110,7 +109,7 @@ USE: logging
#! of the given word. #! of the given word.
dup dup dup dup
<namespace> [ <namespace> [
"responder" "inspect" put "responder" "browser" put
<table border= "1" table> <table border= "1" table>
<tr> <th colspan= "2" th> "Source" write </th> </tr> <tr> <th colspan= "2" th> "Source" write </th> </tr>
<tr> <td colspan= "2" td> [ [ parse ] [ [ "No such word" write ] [ car see ] ifte ] catch ] with-simple-html-output </td> </tr> <tr> <td colspan= "2" td> [ [ parse ] [ [ "No such word" write ] [ car see ] ifte ] catch ] with-simple-html-output </td> </tr>
@ -186,7 +185,7 @@ USE: logging
#! All output should go to a string which is returned on the #! All output should go to a string which is returned on the
#! callstack along with the resulting datastack as a list. #! callstack along with the resulting datastack as a list.
<namespace> [ <namespace> [
"inspect" "responder" set "browser" "responder" set
1024 <string-output> dup >r <html-stream> [ 1024 <string-output> dup >r <html-stream> [
do-eval do-eval
] with-stream r> stream>str ] with-stream r> stream>str

View File

@ -31,7 +31,6 @@ USE: html
USE: words USE: words
USE: stdio USE: stdio
USE: kernel USE: kernel
USE: cont-utils
USE: cont-responder USE: cont-responder
USE: prettyprint USE: prettyprint
@ -39,7 +38,7 @@ USE: prettyprint
#! Given a string that is a factor word, show the #! Given a string that is a factor word, show the
#! aporpos of that word. #! aporpos of that word.
<namespace> [ <namespace> [
"responder" "inspect" put "responder" "browser" put
<pre> <pre>
stdio get <html-stream> [ stdio get <html-stream> [
apropos. apropos.

View File

@ -33,19 +33,23 @@ USE: stdio
USE: parser USE: parser
: l1 : l1
"cont-responder.factor" run-file
"cont-utils.factor" run-file ;
: l2
"cont-examples.factor" run-file "cont-examples.factor" run-file
"cont-numbers-game.factor" run-file ; "cont-numbers-game.factor" run-file ;
: l3 "todo.factor" run-file ; : l2 "todo.factor" run-file ;
: l4 "todo-example.factor" run-file ; : l3 "todo-example.factor" run-file ;
: l5 "live-updater.factor" run-file ; : l4 "live-updater.factor" run-file ;
: l6 "eval-responder.factor" run-file ; : l5 "eval-responder.factor" run-file ;
: l7 "live-updater-responder.factor" run-file ; : l6 "live-updater-responder.factor" run-file ;
: l8 "browser.factor" run-file ; : l7 "cont-testing.factor" run-file ;
: l9 "cont-testing.factor" run-file ; : l8
: la ; #! Use for reloading and testing changes to browser responder
#! in factor core.
"../../library/httpd/browser-responder.factor" run-file ;
: l9
#! Use for reloading and testing changes to cont responder
#! in factor core.
"../../library/httpd/cont-responder.factor" run-file ;
DEFER: la
: la [ 8888 httpd ] [ dup . flush [ la ] when* ] catch ; : la [ 8888 httpd ] [ dup . flush [ la ] when* ] catch ;
: lb [ la "httpd thread exited.\n" write flush ] in-thread ; : lb [ la "httpd thread exited.\n" write flush ] in-thread ;

View File

@ -29,7 +29,6 @@
IN: todo-example IN: todo-example
USE: cont-responder USE: cont-responder
USE: html USE: html
USE: cont-utils
USE: html USE: html
USE: stdio USE: stdio
USE: strings USE: strings

View File

@ -119,6 +119,8 @@ USING: kernel lists parser stdio words namespaces ;
"/library/httpd/test-responder.factor" "/library/httpd/test-responder.factor"
"/library/httpd/quit-responder.factor" "/library/httpd/quit-responder.factor"
"/library/httpd/resource-responder.factor" "/library/httpd/resource-responder.factor"
"/library/httpd/cont-responder.factor"
"/library/httpd/browser-responder.factor"
"/library/httpd/default-responders.factor" "/library/httpd/default-responders.factor"
"/library/tools/jedit.factor" "/library/tools/jedit.factor"

View File

@ -36,6 +36,8 @@ USE: inspect-responder
USE: quit-responder USE: quit-responder
USE: file-responder USE: file-responder
USE: resource-responder USE: resource-responder
USE: cont-responder
USE: browser-responder
#! Remove all existing responders, and create a blank #! Remove all existing responders, and create a blank
#! responder table. #! responder table.
@ -68,4 +70,6 @@ global [ <namespace> "httpd-responders" set ] bind
[ resource-responder ] "get" set [ resource-responder ] "get" set
] extend add-responder ] extend add-responder
"browser" [ f browser-responder ] install-cont-responder
"file" set-default-responder "file" set-default-responder

View File

@ -77,6 +77,19 @@ url-encoding presentation generic ;
call call
] ifte* ; ] ifte* ;
: browser-link-href ( style -- href )
dup "browser-link-word" swap assoc url-encode
swap "browser-link-vocab" swap assoc url-encode
"responder" get url-encode
[ "/responder/" , , "/?vocab=" , , "&word=" , , ] make-string ;
: browser-link-tag ( style quot -- style )
over "browser-link-word" swap assoc [
<a href= over browser-link-href a> call </a>
] [
call
] ifte ;
: icon-tag ( string style quot -- ) : icon-tag ( string style quot -- )
over "icon" swap assoc dup [ over "icon" swap assoc dup [
<img src= "/responder/resource/" swap cat2 img/> <img src= "/responder/resource/" swap cat2 img/>
@ -93,9 +106,11 @@ M: html-stream fwrite-attr ( str style stream -- )
wrapper-stream-scope [ wrapper-stream-scope [
[ [
[ [
[ drop chars>entities write ] span-tag [
] file-link-tag [ drop chars>entities write ] span-tag
] icon-tag ] file-link-tag
] icon-tag
] browser-link-tag
] bind ; ] bind ;
C: html-stream ( stream -- stream ) C: html-stream ( stream -- stream )

View File

@ -40,8 +40,22 @@ USE: words
: set-vocab-style ( style vocab -- ) : set-vocab-style ( style vocab -- )
>r default-style append r> "vocabularies" style set-hash ; >r default-style append r> "vocabularies" style set-hash ;
: browser-styles ( word -- style )
#! Return the style values for the HTML word browser
dup word-vocabulary [
swap word-name "browser-link-word" swons
swap "browser-link-vocab" swons
2list
] [
drop [ ]
] ifte* ;
: word-style ( word -- style ) : word-style ( word -- style )
word-vocabulary [ vocab-style ] [ default-style ] ifte* ; dup browser-styles swap word-vocabulary [
vocab-style
] [
default-style
] ifte* append ;
<namespace> "vocabularies" set-style <namespace> "vocabularies" set-style