Add javascript prototype library and fix outliners.
parent
beb58fe466
commit
f8939863ff
|
@ -1,7 +1,7 @@
|
|||
! Copyright (C) 2004, 2005 Slava Pestov.
|
||||
! See http://factor.sf.net/license.txt for BSD license.
|
||||
IN: httpd
|
||||
USING: browser-responder cont-responder file-responder
|
||||
USING: io browser-responder cont-responder file-responder
|
||||
help-responder inspect-responder kernel namespaces prettyprint ;
|
||||
|
||||
#! Remove all existing responders, and create a blank
|
||||
|
@ -18,6 +18,15 @@ global [
|
|||
! Online help browsing
|
||||
"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
|
||||
"inspector" [ inspect-responder ] install-cont-responder
|
||||
|
||||
|
|
|
@ -73,6 +73,7 @@ USE: sequences
|
|||
! <input "text" =type "name" =name "20" =size input/>
|
||||
|
||||
SYMBOL: html
|
||||
SYMBOL: attrs
|
||||
|
||||
: write-html H{ { html t } } format ;
|
||||
|
||||
|
@ -85,7 +86,7 @@ SYMBOL: html
|
|||
#! With the attribute namespace on the stack, get the attributes
|
||||
#! and write them to standard output. If no attributes exist, write
|
||||
#! nothing.
|
||||
"attrs" get attrs>string write-html ;
|
||||
attrs get attrs>string write-html ;
|
||||
|
||||
: html-word ( name def -- )
|
||||
#! Define 'word creating' word to allow
|
||||
|
@ -103,7 +104,7 @@ SYMBOL: html
|
|||
|
||||
: <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 -- )
|
||||
#! Return the name and code for the <foo patterned
|
||||
|
@ -161,7 +162,7 @@ SYMBOL: html
|
|||
|
||||
: define-attribute-word ( name -- )
|
||||
dup "=" swap append swap [
|
||||
, [ swons "attrs" get push ] %
|
||||
, [ swons attrs get push ] %
|
||||
] [ ] make html-word drop ;
|
||||
|
||||
! Define some closed HTML tags
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
! See http://factorcode.org/license.txt for BSD license.
|
||||
IN: html
|
||||
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 ;
|
||||
|
||||
: hex-color, ( triplet -- )
|
||||
|
@ -156,9 +156,9 @@ M: html-stream stream-format ( str style stream -- )
|
|||
<table "display: inline; " =style table>
|
||||
<tr>
|
||||
<td>
|
||||
get-random-id dup >r swap [
|
||||
"+" get-random-id dup >r rot [
|
||||
with-html-stream
|
||||
] curry "+" live-anchor
|
||||
] curry [ , \ show-final , ] [ ] make updating-anchor
|
||||
</td>
|
||||
<td>
|
||||
call
|
||||
|
@ -166,7 +166,7 @@ M: html-stream stream-format ( str style stream -- )
|
|||
</tr>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td r> =id td> </td>
|
||||
<td> <div r> =id div> </td>
|
||||
</tr>
|
||||
</table> ;
|
||||
|
||||
|
@ -205,7 +205,7 @@ M: html-stream stream-terpri [ <br/> ] with-stream* ;
|
|||
<head>
|
||||
<title> write </title>
|
||||
default-css
|
||||
include-live-updater-js
|
||||
include-prototype-js
|
||||
</head>
|
||||
<body>
|
||||
<h1> write </h1>
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -10,6 +10,7 @@ USING: words kernel parser sequences io compiler ;
|
|||
"httpd"
|
||||
"cont-responder"
|
||||
"live-updater"
|
||||
"prototype-js"
|
||||
"html"
|
||||
"file-responder"
|
||||
"help-responder"
|
||||
|
|
|
@ -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> ;
|
Loading…
Reference in New Issue