> On Tuesday, 7 February 2012 at 19:27:46 UTC, bls wrote: >> >> You know it, web stuff documentation is a weak point. > > > Yeah, I know. > > >> looks very interesting ... so a real world sample app would be nice.. > > > The closest i have is a little blog like thing that I started > and haven't worked on since. > > http://arsdnet.net/blog/my-source > > >> I would like to see a sample RIA - M- V-C wise, using (say using dojo >> dijit as View layer ) in conjunction with the D web stuff . (Model- >> Controler) > > > I haven't used one of those toolkits, but plain javascript > is easy to do like this. > > > I'm writing a little browser game on the weekends. When I finish > it, I might be able to show it to you. (I'll have to replace the > copyrighted images in there right now though.) > > > > Basically you just call the server functions in your event handlers. > > > Want to replace a div with content from the other side? > > D > === > import arsd.web; > class Server : ApiProvider { > string hello(string name) { return "hello " ~ name; } > } > mixin FancyMain!Server; > === > > HTML/Javascript > === > <script src="app/functions.js"></script> > <div id="holder"></div> > <button > onclick="Server.hello(prompt('Name?')).useToReplace('holder');">Click > me</button> > === > > > > And when you click that button, the string D returns will be > put inside as text. > > That's the basic of it. > > > > > I'm taking this to an extreme with this: > > http://arsdnet.net:8080/ > > (that's my custom D web server, so if it doesn't respond, I probably > closed the program. Will leave it open for a while though.) > > > Click on the link and the body. You should get some text added. > > > > Take a look at the javascript though: > http://arsdnet.net:8080/sse.js > > > document.body.addEventListener("click", function(event) { > var response = Test.cancelableEvent( > event.type, > event.target.getAttribute("data-node-index") > ).getSync(); > [snip] > > > > It uses synchronous ajax on the click handler to forward the > event to the server, which then passes it through the server > side dom. > > > D: > === > > /* the library implements EventResponse cancelableEvent(...), > which dispatches the event on the server, so you can write: */ > > // body is a keyword in D, hence mainBody instead. > document.mainBody.addEventListener("click"), (Event ev) { > ev.target.appendText("got click!"); > ev.preventDefault(); > }); > > === > > > sync ajax requests suck because it blocks the whole web app > waiting for a response. But writing server side event handlers > is a fun toy. > > > > > > > > > I do write real applications with web.d, but they are almost > all proprietary, so little toys is all I really have to show > right now.
As somebody that frequently laments the lack of documentation in general (I use Silverstripe at work, in which the documentation is patchy at best) I work hard on my documentation. Adam's stuff is very good, I plan to take a look at it and "borrow" some code for a web framework I'm working on. But I am also open-sourcing modules that I am using as I go along. It would be cool if we ended up with a set of independent modules that worked well together but had few dependencies. I guess the point is whether Adam is ok with the community extending his work separately, since "misc-stuff-including-D-programming-language-web-stuff" isn't exactly a catchy name :P. It would be unfortunate if Adam's work wasn't built upon, and that work was needlessly replicated, then tightly integrated into some other project, rather than being something that everybody could use.
