README currently in work
This app works with play 2.1-SNAPSHOT. At the moment, you must checkout at this commit : a61a48e35a4c6c0e0d28966c84bcbbd0d4d4014a.
PlayStory is an app that receive logs over HTTP, persist them in MongoDB and display them in a Web page in real time.
This application use the last features of Play! Framework :
- ReactiveMongo driver https://github.com/zenexity/ReactiveMongo
- Play-ReactiveMongo https://github.com/zenexity/Play-ReactiveMongo
- New Json API
- Stream SSE/Comet (Enumerator/Enumeratee/Iteratee with Akka Actor)
PlayStory is a single-web page.
All the javascript code rely on procrastination.js library (https://github.com/jto/procrastination).
Here how I organize the javascript.
My application is composed of two pages :
- The home page.
- The dashboard page.
The idea is to split each page into several independant views. We usually do a lot to manage a view :
- We make requests to the server.
- We listen some events from DOM, server (requests/streams) and javascript router.
- We update the DOM.
My javascript Router have some interesting features:
Router.when('uri/:param', action1.then(action2))
Router.when('uri/:param').chain(action1, action2)
Router.when('uri/:param', action1.and(action2))
Router.when('uri/:param').par(action1, action2)
Router.when('uri/:param').lazy(function() {
return action1.then(action2);
});
Router.fromStart()
.when('uri/:param')
.chain(action1, action2)
Router.from('page')
.when('uri/:param')
.chain(action1, action2)
Router.go('page', true)
Router.forward()
Router.back()
Binding to server events.
server.onReceive('uri/:param')
.await(actions)
.subscribe();
server.onReceiveFromTemplate('model')
.await(actions)
.subscribe();
Binding to DOM events:
When(event).await(actions).subscribe();
'Bucket' is a just one place where you can put some models and collections.
Bucket.collections('name').get()
Bucket.collections('name').first()
Bucket.collections('name').last()
Bucket.collections('name').size()
Bucket.collections('name').put(model)
Bucket.collections('name').set(collection)
Bucket.collections('name').reset()
Bucket.collections('name').destroy()
Bucket.model('name').get()
Bucket.model('name').set(model)