Add javascript prototype library and fix outliners.

cvs
Chris Double 2006-01-24 10:50:32 +00:00
parent beb58fe466
commit f8939863ff
6 changed files with 1828 additions and 9 deletions

View File

@ -1,7 +1,7 @@
! Copyright (C) 2004, 2005 Slava Pestov. ! Copyright (C) 2004, 2005 Slava Pestov.
! See http://factor.sf.net/license.txt for BSD license. ! See http://factor.sf.net/license.txt for BSD license.
IN: httpd IN: httpd
USING: browser-responder cont-responder file-responder USING: io browser-responder cont-responder file-responder
help-responder inspect-responder kernel namespaces prettyprint ; help-responder inspect-responder kernel namespaces prettyprint ;
#! Remove all existing responders, and create a blank #! Remove all existing responders, and create a blank
@ -18,6 +18,15 @@ global [
! Online help browsing ! Online help browsing
"help" [ help-responder ] install-cont-responder "help" [ help-responder ] install-cont-responder
! Javascript source used by ajax libraries
[
"contrib/httpd/javascript/" resource-path "doc-root" set
"javascript" "responder" set
[ file-responder ] "get" set
[ file-responder ] "post" set
[ file-responder ] "head" set
] make-responder
! Global variables ! Global variables
"inspector" [ inspect-responder ] install-cont-responder "inspector" [ inspect-responder ] install-cont-responder

View File

@ -73,6 +73,7 @@ USE: sequences
! <input "text" =type "name" =name "20" =size input/> ! <input "text" =type "name" =name "20" =size input/>
SYMBOL: html SYMBOL: html
SYMBOL: attrs
: write-html H{ { html t } } format ; : write-html H{ { html t } } format ;
@ -85,7 +86,7 @@ SYMBOL: html
#! With the attribute namespace on the stack, get the attributes #! With the attribute namespace on the stack, get the attributes
#! and write them to standard output. If no attributes exist, write #! and write them to standard output. If no attributes exist, write
#! nothing. #! nothing.
"attrs" get attrs>string write-html ; attrs get attrs>string write-html ;
: html-word ( name def -- ) : html-word ( name def -- )
#! Define 'word creating' word to allow #! Define 'word creating' word to allow
@ -103,7 +104,7 @@ SYMBOL: html
: <foo "<" swap append ; : <foo "<" swap append ;
: do-<foo write-html H{ } clone >n V{ } clone "attrs" set ; : do-<foo write-html H{ } clone >n V{ } clone attrs set ;
: def-for-html-word-<foo ( name -- ) : def-for-html-word-<foo ( name -- )
#! Return the name and code for the <foo patterned #! Return the name and code for the <foo patterned
@ -161,7 +162,7 @@ SYMBOL: html
: define-attribute-word ( name -- ) : define-attribute-word ( name -- )
dup "=" swap append swap [ dup "=" swap append swap [
, [ swons "attrs" get push ] % , [ swons attrs get push ] %
] [ ] make html-word drop ; ] [ ] make html-word drop ;
! Define some closed HTML tags ! Define some closed HTML tags

View File

@ -2,7 +2,7 @@
! See http://factorcode.org/license.txt for BSD license. ! See http://factorcode.org/license.txt for BSD license.
IN: html IN: html
USING: cont-responder generic hashtables help http inspector io USING: cont-responder generic hashtables help http inspector io
kernel lists live-updater math namespaces sequences strings kernel lists prototype-js math namespaces sequences strings
styles words xml ; styles words xml ;
: hex-color, ( triplet -- ) : hex-color, ( triplet -- )
@ -156,9 +156,9 @@ M: html-stream stream-format ( str style stream -- )
<table "display: inline; " =style table> <table "display: inline; " =style table>
<tr> <tr>
<td> <td>
get-random-id dup >r swap [ "+" get-random-id dup >r rot [
with-html-stream with-html-stream
] curry "+" live-anchor ] curry [ , \ show-final , ] [ ] make updating-anchor
</td> </td>
<td> <td>
call call
@ -166,7 +166,7 @@ M: html-stream stream-format ( str style stream -- )
</tr> </tr>
<tr> <tr>
<td> </td> <td> </td>
<td r> =id td> </td> <td> <div r> =id div> </td>
</tr> </tr>
</table> ; </table> ;
@ -205,7 +205,7 @@ M: html-stream stream-terpri [ <br/> ] with-stream* ;
<head> <head>
<title> write </title> <title> write </title>
default-css default-css
include-live-updater-js include-prototype-js
</head> </head>
<body> <body>
<h1> write </h1> <h1> write </h1>

1781
contrib/httpd/javascript/prototype.js vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -10,6 +10,7 @@ USING: words kernel parser sequences io compiler ;
"httpd" "httpd"
"cont-responder" "cont-responder"
"live-updater" "live-updater"
"prototype-js"
"html" "html"
"file-responder" "file-responder"
"help-responder" "help-responder"

View File

@ -0,0 +1,27 @@
! Copyright (C) 2006 Chris Double.
! See http://factorcode.org/license.txt for BSD license.
!
! Wrapper for the Prototype javascript library.
! 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 ;
: include-prototype-js ( -- )
#! Write out the HTML script tag to include the prototype
#! javascript library.
<script "text/javascript" =type "/responder/javascript/prototype.js" =src script>
</script> ;
: updating-javascript ( id quot -- string )
#! Return the javascript code to perform the updating
#! ajax call.
quot-url swap
[ "new Ajax.Updater(\"" % % "\",\"" % % "\", { method: \"get\" });" % ] "" make ;
: updating-anchor ( text id quot -- )
#! Write the HTML for an anchor that when clicked will
#! call the given quotation on the server. The output generated
#! from that quotation will replace the DOM element on the page with
#! the given id. The 'text' is the anchor text.
<a "#" =href updating-javascript =onclick a> write </a> ;