Browse files

Fix examples, update requirejs i18n to work

The 2.0.1 version of requirejs's i18n plugin did not work. I'm guessing
the plugin might actually depend on requirejs itself (I can find no
other reason for it not working standalone), but version 1.0.5 works
fine. As far as I can tell, the two versions are not that different, so
this is no big deal.

The inbrowser example was updated to work using the 0.8.3 coweb-jsoe
build.
  • Loading branch information...
1 parent eded0e2 commit 665a42754363255824107f1812c9301e63e8be52 @ccotter ccotter committed Sep 7, 2012
Showing with 118 additions and 116 deletions.
  1. +3 −3 NOTICES
  2. +8 −6 README.markdown
  3. +5 −1 bin/release-jsoe.sh
  4. +3 −0 bin/release-npm.sh
  5. +3 −0 examples/inbrowser/README.markdown
  6. +15 −13 examples/inbrowser/server.js
  7. +8 −1 src/npm/README.markdown
  8. +73 −92 src/org/requirejs/i18n.js
View
6 NOTICES
@@ -15,9 +15,9 @@ following third-party code that is not covered under the OpenCoweb License:
The copyright and licenses of these third-party products are reproduced below.
-RequireJS i18n 2.0.1
+RequireJS i18n 1.0.5
Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
-Available via the MIT new BSD license at
-https://github.com/requirejs/i18n/blob/2.0.1/LICENSE.
+Available via the MIT new BSD license at
+https://github.com/jrburke/requirejs/blob/1.0.5/LICENSE.
View
14 README.markdown
@@ -17,8 +17,6 @@ library.
Currently, the OCW OT API supports Unix-like systems with the following tools.
-* make
-* curl
* Node.js, npm (optional, for using the OT API with Node.js)
* sphinx docs (optional, for building documentation)
@@ -28,18 +26,22 @@ Application programmers wishing to use the OT API can checkout this project as a
git repository (or submodule into an already existing git repository), or
download the code as a tarball and extract into their project.
-###Setup
+###Code organization
-In the root directory of this project, run `make install`. This fetches required
-dependencies (currently, only RequireJS's i18n library).
+ * `/src` The source code lives here.
+ * `/docs` Sphinx documentation.
+ * `/examples` Example code using the OCW OT API.
+ * `/bin` Scripts to build release versions of the OCW OT API.
+ * `/dist` Release versions.
##Usage
###Operational Transform
To get started with operational transform, make sure you understand
[the basics](http://opencoweb.org/ocwdocs/intro/openg.html) of operational
-transform. At the very least, read the last paragraph entitled ["A final word"](http://opencoweb.org/ocwdocs/intro/openg.html#a-final-word).
+transform. At the very least, read the last paragraph entitled
+["A final word"](http://opencoweb.org/ocwdocs/intro/openg.html#a-final-word).
The most important concept to understand is that the API guarantees convergence
of local data structures as long as the local application 1) sends remote peers
View
6 bin/release-jsoe.sh
@@ -10,14 +10,17 @@ JSOE_VERSION=${JSOE_VERSION%\"*}
JSOE_ROOT=`pwd`
TMPDIR=`mktemp -d -t cowebjsoeXXXXXX`
-RELEASE_NAME=jsoe-$JSOE_VERSION
+RELEASE_NAME=coweb-jsoe-$JSOE_VERSION
RELEASE_TARBALL_DIR=./dist/jsoe
RELEASE_TARBALL=$RELEASE_TARBALL_DIR/$RELEASE_NAME.tar
FORCE=false
for arg in "$@"; do
if [ "--force" == $arg ]; then
FORCE=true
+ else
+ echo "Unknown option \"$arg\""
+ exit 1
fi
done
@@ -41,6 +44,7 @@ cd $TMPDIR
tar -cf $JSOE_ROOT/$RELEASE_TARBALL ./
echo "Created $RELEASE_TARBALL"
cd $JSOE_ROOT
+cp -r $TMPDIR/$RELEASE_NAME $RELEASE_TARBALL_DIR
echo "Cleanup temporary files."
rm -rf $TMPDIR
View
3 bin/release-npm.sh
@@ -17,6 +17,9 @@ FORCE=false
for arg in "$@"; do
if [ "--force" == $arg ]; then
FORCE=true
+ else
+ echo "Unknown option \"$arg\""
+ exit 1
fi
done
View
3 examples/inbrowser/README.markdown
@@ -12,6 +12,9 @@ In this scenario, the client is the only entity that uses the coweb-jsoe. The
server exists to facilitate communication among remote clients and fulfill some
requirements of the OT engine (eg: a total order for operations).
+This example uses the 0.8.3 release of coweb-jsoe (in
+dist/jsoe/coweb-jsoe-0.8.3).
+
##Running and usage
To run the Node.js server, run `node server.js`. To specify a port to listen on,
View
28 examples/inbrowser/server.js
@@ -4,23 +4,25 @@ var fs = require("fs");
var url = require("url");
var querystring = require("querystring");
+var jsoeLoc = "../../dist/jsoe/coweb-jsoe-0.8.3/coweb/jsoe";
+
var fileList = [
["index.html", "index.html"],
["config.js", "config.js"],
["main.js", "main.js"],
- ["../../org/requirejs/i18n.js", "org/requirejs/i18n.js"],
- ["../../nls/messages.js", "coweb/jsoe/nls/messages.js"],
- ["../../ContextDifference.js", "coweb/jsoe/ContextDifference.js"],
- ["../../ContextVector.js", "coweb/jsoe/ContextVector.js"],
- ["../../ContextVectorTable.js", "coweb/jsoe/ContextVectorTable.js"],
- ["../../DeleteOperation.js", "coweb/jsoe/DeleteOperation.js"],
- ["../../factory.js", "coweb/jsoe/factory.js"],
- ["../../HistoryBuffer.js", "coweb/jsoe/HistoryBuffer.js"],
- ["../../InsertOperation.js", "coweb/jsoe/InsertOperation.js"],
- ["../../Operation.js", "coweb/jsoe/Operation.js"],
- ["../../OperationEngine.js", "coweb/jsoe/OperationEngine.js"],
- ["../../OTEngine.js", "coweb/jsoe/OTEngine.js"],
- ["../../UpdateOperation.js", "coweb/jsoe/UpdateOperation.js"]
+ ["../../dist/jsoe/coweb-jsoe-0.8.3/org/requirejs/i18n.js", "org/requirejs/i18n.js"],
+ [jsoeLoc + "/nls/messages.js", "coweb/jsoe/nls/messages.js"],
+ [jsoeLoc + "/ContextDifference.js", "coweb/jsoe/ContextDifference.js"],
+ [jsoeLoc + "/ContextVector.js", "coweb/jsoe/ContextVector.js"],
+ [jsoeLoc + "/ContextVectorTable.js", "coweb/jsoe/ContextVectorTable.js"],
+ [jsoeLoc + "/DeleteOperation.js", "coweb/jsoe/DeleteOperation.js"],
+ [jsoeLoc + "/factory.js", "coweb/jsoe/factory.js"],
+ [jsoeLoc + "/HistoryBuffer.js", "coweb/jsoe/HistoryBuffer.js"],
+ [jsoeLoc + "/InsertOperation.js", "coweb/jsoe/InsertOperation.js"],
+ [jsoeLoc + "/Operation.js", "coweb/jsoe/Operation.js"],
+ [jsoeLoc + "/OperationEngine.js", "coweb/jsoe/OperationEngine.js"],
+ [jsoeLoc + "/OTEngine.js", "coweb/jsoe/OTEngine.js"],
+ [jsoeLoc + "/UpdateOperation.js", "coweb/jsoe/UpdateOperation.js"]
];
var fileContents = {};
View
9 src/npm/README.markdown
@@ -3,5 +3,12 @@
##About
-Fill this in later...
+This Node.JS package allows for easy integration with the OpenCoweb Operation
+Transform engine.
+
+##Usage
+
+Install with `npm install coweb-jsoe`.
+In Node.JS, access the OTEngine object via `require("coweb-jsoe").OTEngine`.
+
View
165 src/org/requirejs/i18n.js
@@ -1,9 +1,9 @@
/**
- * @license RequireJS i18n 2.0.1 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
+ * @license RequireJS i18n 1.0.0 Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
* Available via the MIT or new BSD license.
- * see: http://github.com/requirejs/i18n for details
+ * see: http://github.com/jrburke/requirejs for details
*/
-/*jslint regexp: true */
+/*jslint regexp: false, nomen: false, plusplus: false, strict: false */
/*global require: false, navigator: false, define: false */
/**
@@ -35,15 +35,14 @@
* for the nls/fr-fr/colors bundle to be that mixed in locale.
*/
(function () {
- 'use strict';
-
//regexp for reconstructing the master bundle name from parts of the regexp match
//nlsRegExp.exec("foo/bar/baz/nls/en-ca/foo") gives:
//["foo/bar/baz/nls/en-ca/foo", "foo/bar/baz/nls/", "/", "/", "en-ca", "foo"]
//nlsRegExp.exec("foo/bar/baz/nls/foo") gives:
//["foo/bar/baz/nls/foo", "foo/bar/baz/nls/", "/", "/", "foo", ""]
//so, if match[5] is blank, it means this is the top bundle definition.
- var nlsRegExp = /(^.*(^|\/)nls(\/|$))([^\/]*)\/?([^\/]*)/;
+ var nlsRegExp = /(^.*(^|\/)nls(\/|$))([^\/]*)\/?([^\/]*)/,
+ empty = {};
//Helper function to avoid repeating code. Lots of arguments in the
//desire to stay functional and support RequireJS contexts without having
@@ -72,109 +71,91 @@
* trigger a problem related to that.
*/
function mixin(target, source, force) {
- var prop;
- for (prop in source) {
- if (source.hasOwnProperty(prop) && (!target.hasOwnProperty(prop) || force)) {
+ for (var prop in source) {
+ if (!(prop in empty) && (!(prop in target) || force)) {
target[prop] = source[prop];
- } else if (typeof source[prop] === 'object') {
- mixin(target[prop], source[prop], force);
}
}
}
- define(['module'], function (module) {
- var masterConfig = module.config();
-
- return {
- version: '2.0.1',
- /**
- * Called when a dependency needs to be loaded.
- */
- load: function (name, req, onLoad, config) {
- config = config || {};
+ define({
+ version: '1.0.0',
+ /**
+ * Called when a dependency needs to be loaded.
+ */
+ load: function (name, req, onLoad, config) {
+ config = config || {};
- if (config.locale) {
- masterConfig.locale = config.locale;
- }
+ var masterName,
+ match = nlsRegExp.exec(name),
+ prefix = match[1],
+ locale = match[4],
+ suffix = match[5],
+ parts = locale.split("-"),
+ toLoad = [],
+ value = {},
+ i, part, current = "";
- var masterName,
- match = nlsRegExp.exec(name),
- prefix = match[1],
- locale = match[4],
- suffix = match[5],
- parts = locale.split("-"),
- toLoad = [],
- value = {},
- i, part, current = "";
+ //If match[5] is blank, it means this is the top bundle definition,
+ //so it does not have to be handled. Locale-specific requests
+ //will have a match[4] value but no match[5]
+ if (match[5]) {
+ //locale-specific bundle
+ prefix = match[1];
+ masterName = prefix + suffix;
+ } else {
+ //Top-level bundle.
+ masterName = name;
+ suffix = match[4];
+ locale = config.locale || (config.locale =
+ typeof navigator === "undefined" ? "root" :
+ (navigator.language ||
+ navigator.userLanguage || "root").toLowerCase());
+ parts = locale.split("-");
+ }
- //If match[5] is blank, it means this is the top bundle definition,
- //so it does not have to be handled. Locale-specific requests
- //will have a match[4] value but no match[5]
- if (match[5]) {
- //locale-specific bundle
- prefix = match[1];
- masterName = prefix + suffix;
- } else {
- //Top-level bundle.
- masterName = name;
- suffix = match[4];
- locale = masterConfig.locale;
- if (!locale) {
- locale = masterConfig.locale =
- typeof navigator === "undefined" ? "root" :
- (navigator.language ||
- navigator.userLanguage || "root").toLowerCase();
- }
- parts = locale.split("-");
+ if (config.isBuild) {
+ //Check for existence of all locale possible files and
+ //require them if exist.
+ toLoad.push(masterName);
+ addIfExists(req, "root", toLoad, prefix, suffix);
+ for (i = 0; (part = parts[i]); i++) {
+ current += (current ? "-" : "") + part;
+ addIfExists(req, current, toLoad, prefix, suffix);
}
- if (config.isBuild) {
- //Check for existence of all locale possible files and
- //require them if exist.
- toLoad.push(masterName);
- addIfExists(req, "root", toLoad, prefix, suffix);
- for (i = 0; i < parts.length; i++) {
- part = parts[i];
+ req(toLoad, function () {
+ onLoad();
+ });
+ } else {
+ //First, fetch the master bundle, it knows what locales are available.
+ req([masterName], function (master) {
+ //Figure out the best fit
+ var needed = [];
+
+ //Always allow for root, then do the rest of the locale parts.
+ addPart("root", master, needed, toLoad, prefix, suffix);
+ for (i = 0; (part = parts[i]); i++) {
current += (current ? "-" : "") + part;
- addIfExists(req, current, toLoad, prefix, suffix);
+ addPart(current, master, needed, toLoad, prefix, suffix);
}
+ //Load all the parts missing.
req(toLoad, function () {
- onLoad();
- });
- } else {
- //First, fetch the master bundle, it knows what locales are available.
- req([masterName], function (master) {
- //Figure out the best fit
- var needed = [],
- part;
-
- //Always allow for root, then do the rest of the locale parts.
- addPart("root", master, needed, toLoad, prefix, suffix);
- for (i = 0; i < parts.length; i++) {
- part = parts[i];
- current += (current ? "-" : "") + part;
- addPart(current, master, needed, toLoad, prefix, suffix);
- }
-
- //Load all the parts missing.
- req(toLoad, function () {
- var i, partBundle, part;
- for (i = needed.length - 1; i > -1 && needed[i]; i--) {
- part = needed[i];
- partBundle = master[part];
- if (partBundle === true || partBundle === 1) {
- partBundle = req(prefix + part + '/' + suffix);
- }
- mixin(value, partBundle);
+ var i, partBundle;
+ for (i = needed.length - 1; i > -1 && (part = needed[i]); i--) {
+ partBundle = master[part];
+ if (partBundle === true || partBundle === 1) {
+ partBundle = req(prefix + part + '/' + suffix);
}
+ mixin(value, partBundle);
+ }
- //All done, notify the loader.
- onLoad(value);
- });
+ //All done, notify the loader.
+ onLoad(value);
});
- }
+ });
}
- };
+ }
});
}());

0 comments on commit 665a427

Please sign in to comment.