Updating HTTPD for 0.83 changes
parent
dd473d9578
commit
bba26be715
|
@ -25,7 +25,7 @@
|
|||
! cont-responder facilities.
|
||||
!
|
||||
IN: browser-responder
|
||||
USING: cont-responder hashtables help html io kernel lists
|
||||
USING: cont-responder hashtables help html io kernel
|
||||
memory namespaces prettyprint sequences words xml ;
|
||||
|
||||
: option ( current text -- )
|
||||
|
@ -56,7 +56,7 @@ memory namespaces prettyprint sequences words xml ;
|
|||
|
||||
: word-source ( vocab word -- )
|
||||
#! Write the source for the given word from the vocab as HTML.
|
||||
swap lookup [ [ (help) ] with-html-stream ] when* ;
|
||||
swap lookup [ [ help ] with-html-stream ] when* ;
|
||||
|
||||
: browser-body ( vocab word -- )
|
||||
#! Write out the HTML for the body of the main browser page.
|
||||
|
@ -80,7 +80,8 @@ memory namespaces prettyprint sequences words xml ;
|
|||
: browse ( vocab word -- )
|
||||
#! Display a Smalltalk like browser for exploring words.
|
||||
[
|
||||
2dup browser-title [
|
||||
2dup browser-title dup [
|
||||
<h1> write </h1>
|
||||
<form "main" =name "" =action "get" =method form> browser-body </form>
|
||||
] html-document
|
||||
] show-final ;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
! See http://factorcode.org/license.txt for BSD license.
|
||||
|
||||
USING: http httpd math namespaces io
|
||||
lists strings kernel html hashtables
|
||||
strings kernel html hashtables
|
||||
parser generic sequences ;
|
||||
IN: cont-responder
|
||||
|
||||
|
@ -122,7 +122,7 @@ TUPLE: resume value stdio ;
|
|||
|
||||
: >callable ( quot|interp|f -- interp )
|
||||
dup continuation? [
|
||||
[ continue-with ] cons
|
||||
[ continue-with ] curry
|
||||
] when ;
|
||||
|
||||
: get-registered-continuation ( id -- cont )
|
||||
|
@ -232,7 +232,7 @@ SYMBOL: callback-cc
|
|||
#! NOTE: On return from 'show' the stack is exactly the same as
|
||||
#! initial entry with 'quot' popped off an <namespace> put on. Even
|
||||
#! if the quotation consumes items on the stack.
|
||||
\ serving-html swons (show) ;
|
||||
[ serving-html ] swap append (show) ;
|
||||
|
||||
: (show-final) ( quot -- namespace )
|
||||
#! See comments for show-final. The difference is the
|
||||
|
@ -248,7 +248,7 @@ SYMBOL: callback-cc
|
|||
#! when a page is to be displayed with no further action to occur. Its
|
||||
#! use is an optimisation to save having to generate and save a continuation
|
||||
#! in that special case.
|
||||
\ serving-html swons (show-final) ;
|
||||
[ serving-html ] swap append (show-final) ;
|
||||
|
||||
#! Name of variable for holding initial continuation id that starts
|
||||
#! the responder.
|
||||
|
@ -281,7 +281,8 @@ SYMBOL: root-continuation
|
|||
#! by returning a quotation that will pass the original
|
||||
#! quotation to the callback continuation.
|
||||
[
|
||||
, \ stdio , \ get , \ <resume> , callback-cc get ,
|
||||
, [ stdio get <resume> ] %
|
||||
callback-cc get ,
|
||||
\ continue-with ,
|
||||
] [ ] make ;
|
||||
|
||||
|
@ -305,14 +306,17 @@ SYMBOL: root-continuation
|
|||
#! within the session namespace.
|
||||
f post-refresh-get? set dup resume-stdio stdio set ;
|
||||
|
||||
: prepare-cont-quot ( quot -- quot )
|
||||
[ init-session-namespace ] swap append
|
||||
[ with-scope ] curry ;
|
||||
|
||||
: install-cont-responder ( name quot -- )
|
||||
#! Install a cont-responder with the given name
|
||||
#! that will initially run the given quotation.
|
||||
#!
|
||||
#! Convert the quotation so it is run within a session namespace
|
||||
#! and that namespace is initialized first.
|
||||
\ init-session-namespace swons [ , \ with-scope , ] [ ] make
|
||||
[
|
||||
prepare-cont-quot [
|
||||
[ cont-get/post-responder ] "get" set
|
||||
[ cont-get/post-responder ] "post" set
|
||||
swap "responder" set
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
IN: embedded
|
||||
USING: sequences kernel parser math namespaces io lists ;
|
||||
USING: sequences kernel parser math namespaces io ;
|
||||
|
||||
! if example.fhtml contains:
|
||||
! <html>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
! Copyright (C) 2004,2005 Slava Pestov.
|
||||
! See http://factor.sf.net/license.txt for BSD license.
|
||||
IN: file-responder
|
||||
USING: cont-responder html httpd io kernel lists math namespaces
|
||||
USING: cont-responder html httpd io kernel math namespaces
|
||||
parser sequences strings ;
|
||||
|
||||
: serving-path ( filename -- filename )
|
||||
|
|
|
@ -9,5 +9,5 @@ sequences ;
|
|||
"topic" "query" get hash
|
||||
dup empty? [ drop "handbook" ] when
|
||||
dup article-title
|
||||
[ [ (help) ] with-html-stream ] html-document
|
||||
[ [ help ] with-html-stream ] html-document
|
||||
] show-final ;
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
IN: html
|
||||
USE: prettyprint
|
||||
USE: strings
|
||||
USE: lists
|
||||
USE: kernel
|
||||
USE: io
|
||||
USE: namespaces
|
||||
|
@ -86,7 +85,7 @@ SYMBOL: html
|
|||
: def-for-html-word-<foo> ( name -- )
|
||||
#! Return the name and code for the <foo> patterned
|
||||
#! word.
|
||||
dup <foo> swap [ <foo> write-html ] cons html-word
|
||||
dup <foo> swap [ <foo> write-html ] curry html-word
|
||||
define-open ;
|
||||
|
||||
: <foo "<" swap append ;
|
||||
|
@ -94,7 +93,7 @@ SYMBOL: html
|
|||
: def-for-html-word-<foo ( name -- )
|
||||
#! Return the name and code for the <foo patterned
|
||||
#! word.
|
||||
<foo dup [ write-html ] cons html-word drop ;
|
||||
<foo dup [ write-html ] curry html-word drop ;
|
||||
|
||||
: foo> ">" append ;
|
||||
|
||||
|
@ -108,14 +107,14 @@ SYMBOL: html
|
|||
: def-for-html-word-</foo> ( name -- )
|
||||
#! Return the name and code for the </foo> patterned
|
||||
#! word.
|
||||
</foo> dup [ write-html ] cons html-word define-close ;
|
||||
</foo> dup [ write-html ] curry html-word define-close ;
|
||||
|
||||
: <foo/> [ "<" % % "/>" % ] "" make ;
|
||||
|
||||
: def-for-html-word-<foo/> ( name -- )
|
||||
#! Return the name and code for the <foo/> patterned
|
||||
#! word.
|
||||
dup <foo/> swap [ <foo/> write-html ] cons html-word drop ;
|
||||
dup <foo/> swap [ <foo/> write-html ] curry html-word drop ;
|
||||
|
||||
: foo/> "/>" append ;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
! Copyright (C) 2004, 2006 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: cont-responder generic hashtables help http inspector io
|
||||
kernel lists prototype-js math namespaces sequences strings
|
||||
kernel prototype-js math namespaces sequences strings
|
||||
styles words xml ;
|
||||
IN: html
|
||||
|
||||
|
@ -195,7 +195,7 @@ M: html-stream stream-terpri [ <br/> ] with-stream* ;
|
|||
|
||||
: html-document ( title quot -- )
|
||||
xhtml-preamble
|
||||
swap chars>entities dup
|
||||
swap chars>entities
|
||||
<html>
|
||||
<head>
|
||||
<title> write </title>
|
||||
|
@ -203,7 +203,6 @@ M: html-stream stream-terpri [ <br/> ] with-stream* ;
|
|||
include-prototype-js
|
||||
</head>
|
||||
<body>
|
||||
<h1> write </h1>
|
||||
call
|
||||
</body>
|
||||
</html> ;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
! Copyright (C) 2003, 2005 Slava Pestov
|
||||
IN: http
|
||||
USING: errors hashtables io kernel lists math namespaces parser
|
||||
USING: errors hashtables io kernel math namespaces parser
|
||||
sequences strings ;
|
||||
|
||||
: header-line ( line -- )
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
! Copyright (C) 2003, 2005 Slava Pestov.
|
||||
! See http://factor.sf.net/license.txt for BSD license.
|
||||
IN: httpd
|
||||
USING: errors hashtables kernel lists namespaces io strings
|
||||
USING: errors hashtables kernel namespaces io strings
|
||||
threads http sequences ;
|
||||
|
||||
: (url>path) ( uri -- path )
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
! See http://factorcode.org/license.txt for BSD license.
|
||||
IN: inspect-responder
|
||||
USING: cont-responder generic hashtables help html inspector
|
||||
kernel lists namespaces sequences ;
|
||||
kernel namespaces sequences ;
|
||||
|
||||
! Mini object inspector
|
||||
: http-inspect ( obj -- )
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
! For information and license details for protoype
|
||||
! see http://prototype.conio.net
|
||||
IN: prototype-js
|
||||
USING: io httpd cont-responder html kernel lists namespaces strings ;
|
||||
USING: io httpd cont-responder html kernel namespaces strings ;
|
||||
|
||||
: include-prototype-js ( -- )
|
||||
#! Write out the HTML script tag to include the prototype
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
! Copyright (C) 2004, 2005 Slava Pestov.
|
||||
! See http://factor.sf.net/license.txt for BSD license.
|
||||
IN: httpd
|
||||
USING: arrays hashtables http kernel lists math namespaces
|
||||
USING: arrays hashtables http kernel math namespaces
|
||||
parser sequences io strings ;
|
||||
|
||||
! Variables
|
||||
|
|
|
@ -6,7 +6,6 @@ USE: namespaces
|
|||
USE: io
|
||||
USE: test
|
||||
USE: strings
|
||||
USE: lists
|
||||
|
||||
[ "HTTP/1.0 200 OK\nContent-Length: 12\nContent-Type: text/html\n\n" ]
|
||||
[
|
||||
|
|
Loading…
Reference in New Issue