Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Small cleanups and added require(share).scriptsDir

  • Loading branch information...
commit fcb4c542183ccc6d904a100df26022f58c087f3e 1 parent 2993794
@josephg josephg authored
View
2  lib/client/connection.js
@@ -226,7 +226,7 @@ Connection.prototype.sendOp = function(data) {
// Send a message to the connection.
Connection.prototype.send = function(msg) {
if (this.debug) console.log("SEND", JSON.stringify(msg));
- this.messageBuffer.push({t:(new Date()).toTimeString(), send:JSON.stringify(msg)});
+ this.messageBuffer.push({t:Date.now(), send:JSON.stringify(msg)});
while (this.messageBuffer.length > 100) {
this.messageBuffer.shift();
}
View
2  lib/client/web-prelude.js
@@ -1,5 +1,5 @@
// This file is included at the top of the compiled client JS.
// All the modules will just add stuff to exports, and it'll all get exported.
-var exports = window.sharejs = {version: '0.7.0'};
+var exports = window.sharejs = {version: '0.7.0-alpha8'};
View
6 lib/index.js
@@ -4,7 +4,11 @@ exports.client = require('./client');
// Type wrappers
exports.types = require('./types');
-exports.version = '0.7.0-alpha8';
+exports.version = require('../package.json').version;
+
+// Export the scripts directory to make it easy to host the scripts with connect. Do something like this:
+// app.use('sharejs', connect.static(sharejs.scriptsDir));
+exports.scriptsDir = __dirname + '/../webclient';
// Expose db.mongo, db.etc - whatever else is in livedb.
exports.db = require('livedb');
View
9 prototype/server.coffee
@@ -6,14 +6,14 @@ argv = require('optimist').argv
livedb = require 'livedb'
livedbMongo = require 'livedb-mongo'
+sharejs = require '../lib'
+
webserver = connect(
# connect.logger()
connect.static "#{__dirname}/public"
- connect.static "#{__dirname}/../webclient"
+ connect.static sharejs.scriptsDir
)
-sharejs = require '../lib'
-
#backend = livedb.client livedb.memory()
backend = livedb.client livedbMongo('localhost:27017/test?auto_reconnect', safe:false)
share = sharejs.server.createClient {backend}
@@ -29,8 +29,7 @@ share.use 'connect', (req, callback) ->
callback()
###
-opts = {webserver}
-webserver.use browserChannel opts, (client) ->
+webserver.use browserChannel {webserver}, (client) ->
stream = new Duplex objectMode:yes
stream._write = (chunk, encoding, callback) ->
console.log 's->c ', chunk
View
7 test/scriptsDir.coffee
@@ -0,0 +1,7 @@
+sharejs = require '../lib'
+fs = require 'fs'
+assert = require 'assert'
+
+it 'exports the client scripts directory', ->
+ assert fs.existsSync "#{sharejs.scriptsDir}/share.js"
+
View
4 test/version.coffee
@@ -6,9 +6,5 @@ node = require '../lib'
pkg = require '../package.json'
describe 'version', ->
- it 'should match require("share").version', ->
- assert.ok node.version
- assert.strictEqual node.version, pkg.version
-
it.skip 'should match share.version in the browser', ->
assert.strictEqual web.version, pkg.version
Please sign in to comment.
Something went wrong with that request. Please try again.