nowpad
nowpad copied to clipboard
Realtime text collaboration with Node.js, Express.js and Now.js
Note
These days there is now ShareJS. You should probably use that instead.
Nowpad is no longer maintained and the now dependency that nowpad depends on no longer works. Theoritically, the now
dependency could be swapped out for primus, which should take about half a day, but that is not guaranteed to work.
NowPad: Realtime Text Collaboration
NowPad adds realtime text collaboration to parts of your website such as textareas, allowing multiple people to work on the same document at the same time (while seeing each others changes as they are applied). The benefit of this over traditional collaborative editing is two people would be editing the same document, they've both made changes, one person saves, and the other has to make the choice 'lose my changes, or lose his changes'. Nowpad keeps and applies both your changes as they happen.
Install
NPM
- Use:
require('nowpad')
- Install:
npm install --save nowpad
It Uses
- Node.js - Server Side Javascript
- Express.js - The "Server" in Server Side Javascript
- Now.js - Server and Client Side Communication
- CoffeeScript - JavaScript Made Easy
- Buildr - (Java|Coffee)Script Bundling Made Easy
Demo
-
Clone and setup this repo
git clone https://github.com/balupton/nowpad.git nowpad cd nowpad npm install npm link
-
Start the demo app
nowpad # or npm start if inside nowpad directory
Implementing
Server Side
// Include NowPad
var nowpad = require('nowpad')
// Setup with your Express Server
var myNowpad = nowpad.createInstance({server: yourExpressServer})
//Create known documents
myNowpad.addDocument('doc1', 'this is doc1')
myNowpad.addDocument('doc2', 'this is doc2')
// Handle unknown document
// Fires when an unknown document is requested
myNowpad.requestDocument(function(documentId, callback){
// nowpad.addDocument(documentId)
// callback(true)
callback false
})
// Handle sync request
// Fires when a change is synced to the document
myNowpad.bind('sync', function(document, value){
})
// Handle disconnect request
// Fires when all the clients have disconnected from a document
myNowpad.bind('disconnected', function(document, value){
})
Client Side
-
Include Dependencies
<script src="/nowjs/now.js"></script> <script src="/nowpad/nowpad.js"></script>
-
Using NowPad with a Textarea
// Without jQuery window.nowpad.createInstance({ element: document.getElementById('myTextarea'), documentId: 'doc1' }); // Or With jQuery $textarea = $('#myTextarea').nowpad('doc1');
-
Using NowPad with ACE
window.nowpad.createInstance({ element: ace.edit('pad'), documentId: 'doc1' });
Learning
History
Discover the change history by heading on over to the HISTORY.md
file.
Contribute
Discover how you can contribute by heading on over to the CONTRIBUTING.md
file.
Backers
Maintainers
These amazing people are maintaining this project:
- Benjamin Lupton [email protected] (https://github.com/balupton)
Sponsors
No sponsors yet! Will you be the first?
Contributors
These amazing people have contributed code to this project:
License
Licensed under
Copyright © 2011+ Benjamin Lupton [email protected] (https://github.com/balupton)