USE: parser
USE: html
USE: cont-responder
-USE: cont-utils
USE: stdio
USE: namespaces
IN: eval-responder
USE: html
USE: cont-responder
-USE: cont-utils
USE: kernel
USE: stdio
USE: namespaces
#! of the given word.
dup dup
<namespace> [
- "responder" "inspect" put
+ "responder" "browser" put
<table border= "1" table>
<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>
#! All output should go to a string which is returned on the
#! callstack along with the resulting datastack as a list.
<namespace> [
- "inspect" "responder" set
+ "browser" "responder" set
1024 <string-output> dup >r <html-stream> [
do-eval
] with-stream r> stream>str
USE: words
USE: stdio
USE: kernel
-USE: cont-utils
USE: cont-responder
USE: prettyprint
#! Given a string that is a factor word, show the
#! aporpos of that word.
<namespace> [
- "responder" "inspect" put
+ "responder" "browser" put
<pre>
stdio get <html-stream> [
apropos.
USE: parser
-: l1
- "cont-responder.factor" run-file
- "cont-utils.factor" run-file ;
-: l2
+: l1
"cont-examples.factor" run-file
"cont-numbers-game.factor" run-file ;
-: l3 "todo.factor" run-file ;
-: l4 "todo-example.factor" run-file ;
-: l5 "live-updater.factor" run-file ;
-: l6 "eval-responder.factor" run-file ;
-: l7 "live-updater-responder.factor" run-file ;
-: l8 "browser.factor" run-file ;
-: l9 "cont-testing.factor" run-file ;
-: la ;
+: l2 "todo.factor" run-file ;
+: l3 "todo-example.factor" run-file ;
+: l4 "live-updater.factor" run-file ;
+: l5 "eval-responder.factor" run-file ;
+: l6 "live-updater-responder.factor" run-file ;
+: l7 "cont-testing.factor" run-file ;
+: l8
+ #! 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 ;
: lb [ la "httpd thread exited.\n" write flush ] in-thread ;
IN: todo-example
USE: cont-responder
USE: html
-USE: cont-utils
USE: html
USE: stdio
USE: strings
"/library/httpd/test-responder.factor"\r
"/library/httpd/quit-responder.factor"\r
"/library/httpd/resource-responder.factor"\r
+ "/library/httpd/cont-responder.factor"\r
+ "/library/httpd/browser-responder.factor"\r
"/library/httpd/default-responders.factor"\r
\r
"/library/tools/jedit.factor"\r
USE: quit-responder
USE: file-responder
USE: resource-responder
+USE: cont-responder
+USE: browser-responder
#! Remove all existing responders, and create a blank
#! responder table.
[ resource-responder ] "get" set
] extend add-responder
+"browser" [ f browser-responder ] install-cont-responder
+
"file" set-default-responder
call
] 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 -- )
over "icon" swap assoc dup [
<img src= "/responder/resource/" swap cat2 img/>
wrapper-stream-scope [
[
[
- [ drop chars>entities write ] span-tag
- ] file-link-tag
- ] icon-tag
+ [
+ [ drop chars>entities write ] span-tag
+ ] file-link-tag
+ ] icon-tag
+ ] browser-link-tag
] bind ;
C: html-stream ( stream -- stream )
: set-vocab-style ( style vocab -- )
>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-vocabulary [ vocab-style ] [ default-style ] ifte* ;
+ dup browser-styles swap word-vocabulary [
+ vocab-style
+ ] [
+ default-style
+ ] ifte* append ;
<namespace> "vocabularies" set-style