node-mobwrite
This is a node port of google-mobwrite, which enables live collaborative editing of text (e.g. in forms).
Getting Started
- Ensure you have the system requirements:
- node 0.6+
- Python 2.5+
- Install via npm:
npm install mobwrite
- Start up a demo server:
node node_modules/mobwrite/examples/form-editor/server.js
- Visit http://localhost:8000 in two browser windows
- Type text in one browser window, and see it show up in the other window :)
Building Your Own App
To start, create a demo page like demo.html
:
Open this page in multiple browser windows, edits will sync between them :)
This will share a document with a filename of "my-notes".
Next, connect your demo to a webserver with the mobwrite middleware. You have a couple options:
- express web framework (see below)
- the builtin
http
module in node (see below)
You can also take a look at the examples for more ideas.
Option 1: mobwrite + express web framework
If you are using express as your webserver, you can
easily use()
mobwrite functionality as middleware.
First, make sure that you have the express
module installed:
npm install express
Next, create an app.js
in the same directory as your demo.html
:
var mobwrite = var express = var app = app app appconsole
Then, start the server from the commandline:
node app.js
You can visit your demo at http://localhost:8000/demo.html.
Option 2: mobwrite + builtin node HTTP server
Create an app.js
in the same directory as your demo.html
:
var fs = var path = var http = var mobwrite = var mob = var server = http serverconsole
Then, start the server from the commandline:
node app.js
You can visit your demo at http://localhost:8000/demo.html.
Using Advanced Features
There are a few configuration options you can use to customize the behavior of mobwrite:
var mobwrite = var mob =
You can also keep up-to-date on the current contents of a document:
on("document:change", callback)
triggers when a document changes inside of mobwritereadDocument(callback)
reads the document from mobwrite
For example, you could set up auto-saving to your database:
var mobwrite = var mob = // This event handler gets called anytime a browser client makes a change// to a document in mobwrite.mob
Developing
If google-mobwrite changes, you can update the internal copy by re-exporting the SVN repository:
rm -rf ext/google-mobwrite
svn export http://google-mobwrite.googlecode.com/svn/trunk ext/google-mobwrite
Contributing
Improvements and additions are welcome! Here's a list of ideas:
- socket.io gateway (faster, cleaner, less polling)
- configuration handling for mobwrite daemon (right now it uses baked-in configs)
- memcache-based document loading (rather than transferring via XMLRPC)
- browser-side event for merge conflicts (e.g. so the browser could warn the user)
- ability to connect middleware to an existing mobwrite daemon or AppEngine instance
- reconnect behavior for clients (when the server is restarted)