Skip to content
This repository has been archived by the owner on Aug 18, 2019. It is now read-only.
/ nowpad Public archive

Realtime text collaboration with Node.js, Express.js and Now.js

License

Notifications You must be signed in to change notification settings

bevry-archive/nowpad

Repository files navigation

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

Build Status NPM version Dependency Status Development Dependency Status
Gittip donate button Flattr donate button PayPayl donate button BitCoin donate button Wishlist browse button

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

  • 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

  1. Clone and setup this repo

     git clone https://github.com/balupton/nowpad.git nowpad
     cd nowpad
     npm install
     npm link
    
  2. 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

  1. Include Dependencies

    <script src="/nowjs/now.js"></script>
    <script src="/nowpad/nowpad.js"></script>
  2. Using NowPad with a Textarea

    // Without jQuery
    window.nowpad.createInstance({
    	element: document.getElementById('myTextarea'),
    	documentId: 'doc1'
    });
    
    // Or With jQuery
    $textarea = $('#myTextarea').nowpad('doc1');
  3. 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:

Sponsors

No sponsors yet! Will you be the first?

Gittip donate button Flattr donate button PayPayl donate button BitCoin donate button Wishlist browse button

Contributors

These amazing people have contributed code to this project:

Become a contributor!

License

Licensed under

Copyright © 2011+ Benjamin Lupton b@lupton.cc (https://github.com/balupton)

About

Realtime text collaboration with Node.js, Express.js and Now.js

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published