[Wheat-cvs] r1/web-dev/source/graffiti graffiti.ws,NONE,1.1
Status: Pre-Alpha
Brought to you by:
mark_lentczner
From: Kragen S. <kr...@us...> - 2005-04-09 03:22:48
|
Update of /cvsroot/wheat/r1/web-dev/source/graffiti In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5850/web-dev/source/graffiti Added Files: graffiti.ws Log Message: Donovan and I are checking in some prototype LivePage functionality for Wheat. --- NEW FILE: graffiti.ws --- wheat(version: 1) `` graffiti wall graffiti-wall: { -- instance -- wall-name: "Brick Wall" wall-graffiti: ??? -- public -- add(new-graffito): { #wall-graffiti.push(new-graffito) } initialize(): { #wall-graffiti := [ "Kilroy was here", "For a good time call 867-5309"] } submit(post-args:p, request:r): { ``p.low-level-debug #add(p.new-graffito) return $/library/render.redirect(\self, request:r) } template: ""( <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <title>Wall</title> <script type="text/javascript"> //<![CDATA[ var createRequest = function() { return new XMLHttpRequest() } UNINITIALIZED = 0 LOADING = 1 LOADED = 2 INTERACTIVE = 3 COMPLETED = 4 var invokeAction = function(whatAction, whatId, arguments) { var request = createRequest() request.onreadystatechange = function() { if (request.readyState == COMPLETED) { document.open() document.write(request.responseText) document.close() /* try { var oldNode = document.getElementById(whatId) oldNode.id = '' var newNodeInNewDocument = request.responseXML.getElementById(whatId) alert(newNodeInNewDocument) var newNode = document.importNode(newNodeInNewDocument, true) oldNode.parentNode.replaceChild(newNode, oldNode) alert(request.responseText) } catch (e) { window.fuckedup = e } */ } } request.open('POST', 'http://localhost:8100/garden/thingy') request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded') var encoded = [] for (var key in arguments) { encoded.push( encodeURIComponent(key) + '=' + encodeURIComponent(arguments[key])) } request.overrideMimeType('text/xml') request.send(encoded.join('&')) } //]]> </script> </head> <body> <h1 tt:name="wall-name">Wall</h1> <ul id="theWall"> <li tt:name="wall-graffiti"><tt:span tt:name="graffito">Graffito</tt:span></li> </ul> <form method="POST" onsubmit="invokeAction('hello', 'theWall', {'new-graffito': this['new-graffito'].value}); return false"> <input name="new-graffito" /> <input name="op" value="add" type="submit" /> </form> </body> </html> "") expander: {:'/library/render/expander': tt-wall-name():{ return #subject.wall-name } tt-wall-graffiti(): { #start-repeat() i := 0 g := #subject.wall-graffiti while (i < g.size) { #expand(subject: g[i], expander: \#graffito-expander) i += 1 } } graffito-expander: {:'/library/render/expander': tt-graffito(): { return #subject } } } } ``( We got this error when we were missing a close curly brace: 500 Wheat error library/buffer/exception/invalid-line-number(40) unknown source:?: generated by mark-line-end() /root/applications/farm.ws:262: returned to process-error() /root/applications/farm.ws:246: returned to do-compile() /root/applications/farm.ws:213: returned to submit() Wheat/r1 at resilient:8100 ``) ``( We used the instantiator and gave it a url which already existed; it properly blew away the old object and gave us a new one, but gave us no warning that it was going to do so. ``) instantiables: [ -> '/applications/graffiti/graffiti-wall' ] sample-graffiti-wall: {:'/applications/graffiti/graffiti-wall':} tests: {:'/library/wheatunit/test-case': create-wall(): { s := \$../sample-graffiti-wall s.initialize() return \s } test-title(): { html := #create-wall.render() #assert-contains("<h1>Brick Wall</h1>", html) } test-graffiti(): { html := #create-wall.render() #assert-contains("<li>Kilroy was here</li>", html) } test-adding(): { wall := #create-wall wall.add("More graffiti") html := wall.render() #assert-contains("<li>More graffiti</li>", html) } test-adding-web(): { wall := \#create-wall what := wall.submit( post-args:{ op: "add" new-graffito: "Hello" }, request:#sample-request) #assert-equals("see-other", what.type) #assert-equals($/library/render.url(\wall, request:#sample-request), what.location) html := wall.render() #assert-contains("<li>Hello</li>", html) } sample-request(): { return $/library/render.tests.sample-request; } } |