changeset 43:023f767662d3

Fix compatibility with strict mode of node 0.4 and some files without licence header.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Tue, 01 Mar 2011 11:58:15 +0100
parents 07ca0263a53f
children 3e0ca96d2dce
files README backends/directory.js backends/file.js configuration.js errors.js fdsq.js forms.js iso8601.js modules.js modules/http/mod_atom.js modules/mod_adhoc.js modules/mod_configure.js modules/mod_disco.js modules/mod_http.js modules/mod_manage.js modules/mod_options.js modules/mod_owner.js modules/mod_publish.js modules/mod_publish_message.js modules/mod_retrieve.js modules/mod_subscribe.js modules/mod_version.js namespaces.js nodes.js notifs.js psgxs.js storage.js
diffstat 27 files changed, 327 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/README
+++ b/README
@@ -60,8 +60,6 @@ Please read the COPYING file for details
 =======================
         Thanks
 =======================
-= People =
- Paul Sowden (<http://delete.me.uk/>) - ISO 8601 date functions
 
 ======================
        The code
--- a/backends/directory.js
+++ b/backends/directory.js
@@ -17,6 +17,8 @@
  *  along with PSĜS.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+'use strict';
+
 var fs = require('fs');
 var Node = require('../nodes').Node;
 var backend = exports;
@@ -27,9 +29,9 @@ backend.save = function(dir) {
 
 	fs.stat(dir, function(err, stats) {
 		if (err)
-			fs.mkdir(dir, 0755);
+			fs.mkdir(dir, 509); // 0755 in decimal
 		else if (!stats.isDirectory()) {
-			console.log('\033[1;41mThe file “' + dir + '” isn’t a directory. Exiting.\033[0m');
+			console.log('\x1b[1;41mThe file “' + dir + '” isn’t a directory. Exiting.\x1b[0m');
 			process.exit(1);
 		}
 
@@ -77,9 +79,9 @@ backend.load = function(dir) {
 
 	fs.stat(dir, function(err, stats) {
 		if (err)
-			fs.mkdir(dir, 0755);
+			fs.mkdir(dir, 509); // 0755 in decimal
 		else if (!stats.isDirectory()) {
-			console.log('\033[1;41mThe file “' + dir + '” isn’t a directory. Exiting.\033[0m');
+			console.log('\x1b[1;41mThe file “' + dir + '” isn’t a directory. Exiting.\x1b[0m');
 			process.exit(1);
 		}
 
--- a/backends/file.js
+++ b/backends/file.js
@@ -17,6 +17,8 @@
  *  along with PSĜS.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+'use strict';
+
 var fs = require('fs');
 var Node = require('../nodes').Node;
 var backend = exports;
@@ -82,7 +84,7 @@ backend.load = function(file) {
 		if (err)
 			fs.writeFileSync(file, '{}');
 		else if (!stats.isFile()) {
-			console.log('\033[1;41mThe file “' + file + '” isn’t a regular file. Exiting.\033[0m');
+			console.log('\x1b[1;41mThe file “' + file + '” isn’t a regular file. Exiting.\x1b[0m');
 			process.exit(1);
 		}
 
--- a/configuration.js
+++ b/configuration.js
@@ -17,6 +17,8 @@
  *  along with PSĜS.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+'use strict';
+
 var config = exports;
 
 config.jid = 'pubsub.example.org';
--- a/errors.js
+++ b/errors.js
@@ -17,6 +17,8 @@
  *  along with PSĜS.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+'use strict';
+
 var errors = exports;
 
 errors.success = true;
--- a/fdsq.js
+++ b/fdsq.js
@@ -17,6 +17,8 @@
  *  along with PSĜS.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+'use strict';
+
 var sha1hex = require('sha1').hex;
 
 var fdsq = exports;
--- a/forms.js
+++ b/forms.js
@@ -17,6 +17,8 @@
  *  along with PSĜS.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+'use strict';
+
 var xmpp = require('xmpp')
 var service_configuration = require('./configuration').service_configuration;
 
--- a/iso8601.js
+++ b/iso8601.js
@@ -17,6 +17,8 @@
  *  along with PSĜS.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+'use strict';
+
 Date.prototype.setFromISO8601 = function(iso){
 	var format = /(\d{4})(-)?(\d\d)(-)?(\d\d)(T)?(\d\d)(:)?(\d\d)(:)?(\d\d)Z/;
 	var m = iso.match(format);
--- a/modules.js
+++ b/modules.js
@@ -1,3 +1,24 @@
+/*
+ *  Copyright (C) 2010  Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
+ *
+ *  This file is part of PSĜS, a PubSub server written in JavaScript.
+ *
+ *  PSĜS is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU Affero General Public License as
+ *  published by the Free Software Foundation, either version 3 of the
+ *  License.
+ *
+ *  PSĜS is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Affero General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Affero General Public License
+ *  along with PSĜS.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+'use strict';
+
 var modules = exports;
 
 var fs = require('fs');
--- a/modules/http/mod_atom.js
+++ b/modules/http/mod_atom.js
@@ -1,3 +1,24 @@
+/*
+ *  Copyright (C) 2010  Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
+ *
+ *  This file is part of PSĜS, a PubSub server written in JavaScript.
+ *
+ *  PSĜS is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU Affero General Public License as
+ *  published by the Free Software Foundation, either version 3 of the
+ *  License.
+ *
+ *  PSĜS is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Affero General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Affero General Public License
+ *  along with PSĜS.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+'use strict';
+
 exports.atom = {
 	url: /^\/atom/,
 	func: function (req, res) {
--- a/modules/mod_adhoc.js
+++ b/modules/mod_adhoc.js
@@ -1,3 +1,24 @@
+/*
+ *  Copyright (C) 2010  Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
+ *
+ *  This file is part of PSĜS, a PubSub server written in JavaScript.
+ *
+ *  PSĜS is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU Affero General Public License as
+ *  published by the Free Software Foundation, either version 3 of the
+ *  License.
+ *
+ *  PSĜS is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Affero General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Affero General Public License
+ *  along with PSĜS.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+'use strict';
+
 // XEP-0050: Ad-Hoc Commands
 exports.adHoc = {
 	type: 'set',
--- a/modules/mod_configure.js
+++ b/modules/mod_configure.js
@@ -1,3 +1,24 @@
+/*
+ *  Copyright (C) 2010  Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
+ *
+ *  This file is part of PSĜS, a PubSub server written in JavaScript.
+ *
+ *  PSĜS is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU Affero General Public License as
+ *  published by the Free Software Foundation, either version 3 of the
+ *  License.
+ *
+ *  PSĜS is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Affero General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Affero General Public License
+ *  along with PSĜS.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+'use strict';
+
 // SECTION 8.2: Configure a Node
 exports.getConfigure = {
 	type: 'get',
--- a/modules/mod_disco.js
+++ b/modules/mod_disco.js
@@ -1,3 +1,24 @@
+/*
+ *  Copyright (C) 2010  Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
+ *
+ *  This file is part of PSĜS, a PubSub server written in JavaScript.
+ *
+ *  PSĜS is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU Affero General Public License as
+ *  published by the Free Software Foundation, either version 3 of the
+ *  License.
+ *
+ *  PSĜS is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Affero General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Affero General Public License
+ *  along with PSĜS.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+'use strict';
+
 // SECTION 5.1: Discover Features
 exports.disco_info = {
 	type: 'get',
--- a/modules/mod_http.js
+++ b/modules/mod_http.js
@@ -1,3 +1,24 @@
+/*
+ *  Copyright (C) 2010  Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
+ *
+ *  This file is part of PSĜS, a PubSub server written in JavaScript.
+ *
+ *  PSĜS is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU Affero General Public License as
+ *  published by the Free Software Foundation, either version 3 of the
+ *  License.
+ *
+ *  PSĜS is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Affero General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Affero General Public License
+ *  along with PSĜS.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+'use strict';
+
 var sites = {};
 
 var http = require('http');
--- a/modules/mod_manage.js
+++ b/modules/mod_manage.js
@@ -1,3 +1,24 @@
+/*
+ *  Copyright (C) 2010  Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
+ *
+ *  This file is part of PSĜS, a PubSub server written in JavaScript.
+ *
+ *  PSĜS is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU Affero General Public License as
+ *  published by the Free Software Foundation, either version 3 of the
+ *  License.
+ *
+ *  PSĜS is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Affero General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Affero General Public License
+ *  along with PSĜS.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+'use strict';
+
 // SECTION 8.8.1: Retrieve Subscriptions List
 exports.manageRetrieveSub = {
 	type: 'get',
--- a/modules/mod_options.js
+++ b/modules/mod_options.js
@@ -1,3 +1,24 @@
+/*
+ *  Copyright (C) 2010  Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
+ *
+ *  This file is part of PSĜS, a PubSub server written in JavaScript.
+ *
+ *  PSĜS is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU Affero General Public License as
+ *  published by the Free Software Foundation, either version 3 of the
+ *  License.
+ *
+ *  PSĜS is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Affero General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Affero General Public License
+ *  along with PSĜS.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+'use strict';
+
 // SECTION 6.3.2: Configure Subscription Options (Request)
 exports.getConfigureSub = {
 	type: 'get',
--- a/modules/mod_owner.js
+++ b/modules/mod_owner.js
@@ -1,3 +1,24 @@
+/*
+ *  Copyright (C) 2010  Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
+ *
+ *  This file is part of PSĜS, a PubSub server written in JavaScript.
+ *
+ *  PSĜS is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU Affero General Public License as
+ *  published by the Free Software Foundation, either version 3 of the
+ *  License.
+ *
+ *  PSĜS is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Affero General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Affero General Public License
+ *  along with PSĜS.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+'use strict';
+
 // SECTION 8.1: Create a Node
 exports.create = {
 	type: 'set',
--- a/modules/mod_publish.js
+++ b/modules/mod_publish.js
@@ -1,3 +1,24 @@
+/*
+ *  Copyright (C) 2010  Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
+ *
+ *  This file is part of PSĜS, a PubSub server written in JavaScript.
+ *
+ *  PSĜS is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU Affero General Public License as
+ *  published by the Free Software Foundation, either version 3 of the
+ *  License.
+ *
+ *  PSĜS is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Affero General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Affero General Public License
+ *  along with PSĜS.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+'use strict';
+
 // SECTION 7.1: Publish an Item to a Node
 exports.publish = {
 	type: 'set',
--- a/modules/mod_publish_message.js
+++ b/modules/mod_publish_message.js
@@ -1,3 +1,24 @@
+/*
+ *  Copyright (C) 2010  Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
+ *
+ *  This file is part of PSĜS, a PubSub server written in JavaScript.
+ *
+ *  PSĜS is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU Affero General Public License as
+ *  published by the Free Software Foundation, either version 3 of the
+ *  License.
+ *
+ *  PSĜS is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Affero General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Affero General Public License
+ *  along with PSĜS.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+'use strict';
+
 exports.publishMessage = {
 	stanza: 'message',
 	child: 'body',
--- a/modules/mod_retrieve.js
+++ b/modules/mod_retrieve.js
@@ -1,3 +1,24 @@
+/*
+ *  Copyright (C) 2010  Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
+ *
+ *  This file is part of PSĜS, a PubSub server written in JavaScript.
+ *
+ *  PSĜS is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU Affero General Public License as
+ *  published by the Free Software Foundation, either version 3 of the
+ *  License.
+ *
+ *  PSĜS is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Affero General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Affero General Public License
+ *  along with PSĜS.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+'use strict';
+
 // SECTION 5.6: Retrieve Subscriptions
 exports.retrieveSubscriptions = {
 	type: 'get',
--- a/modules/mod_subscribe.js
+++ b/modules/mod_subscribe.js
@@ -1,3 +1,24 @@
+/*
+ *  Copyright (C) 2010  Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
+ *
+ *  This file is part of PSĜS, a PubSub server written in JavaScript.
+ *
+ *  PSĜS is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU Affero General Public License as
+ *  published by the Free Software Foundation, either version 3 of the
+ *  License.
+ *
+ *  PSĜS is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Affero General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Affero General Public License
+ *  along with PSĜS.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+'use strict';
+
 // SECTION 6.1: Subscribe to a Node
 exports.subscribe = {
 	type: 'set',
--- a/modules/mod_version.js
+++ b/modules/mod_version.js
@@ -1,3 +1,24 @@
+/*
+ *  Copyright (C) 2010  Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
+ *
+ *  This file is part of PSĜS, a PubSub server written in JavaScript.
+ *
+ *  PSĜS is free software: you can redistribute it and/or modify
+ *  it under the terms of the GNU Affero General Public License as
+ *  published by the Free Software Foundation, either version 3 of the
+ *  License.
+ *
+ *  PSĜS is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU Affero General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Affero General Public License
+ *  along with PSĜS.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+'use strict';
+
 // XEP-0092: Software Version
 exports.version = {
 	type: 'get',
--- a/namespaces.js
+++ b/namespaces.js
@@ -1,3 +1,5 @@
+'use strict';
+
 var NS = exports;
 
 NS.DISCO_INFO = 'http://jabber.org/protocol/disco#info';
--- a/nodes.js
+++ b/nodes.js
@@ -17,6 +17,8 @@
  *  along with PSĜS.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+'use strict';
+
 require('./iso8601');
 var errors = require('./errors');
 var config = require('./configuration');
--- a/notifs.js
+++ b/notifs.js
@@ -1,3 +1,5 @@
+'use strict';
+
 var xmpp = require('xmpp');
 var storage = require('./storage');
 var config = require('./configuration');
@@ -6,7 +8,7 @@ var conn;
 function _(obj, color) {
 	var str = require('sys').inspect(obj, false, null);
 	if (color)
-		console.log('\033['+c+';1m' + str + '\033[0m');
+		console.log('\x1b['+c+';1m' + str + '\x1b[0m');
 	else
 		console.log(str);
 };
--- a/psgxs.js
+++ b/psgxs.js
@@ -19,6 +19,8 @@
  *  along with PSĜS.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+'use strict';
+
 var xmpp = require('xmpp');
 var sha1 = require('sha1');
 require('./iso8601');
@@ -45,13 +47,13 @@ conn.log = function (_, m) { console.log
 function _(obj, color) {
 	var str = require('sys').inspect(obj, false, null);
 	if (color)
-		console.log('\033['+c+';1m' + str + '\033[0m');
+		console.log('\x1b['+c+';1m' + str + '\x1b[0m');
 	else
 		console.log(str);
 };
 
 process.addListener('uncaughtException', function (err) {
-	console.log('\033[41;1mUncaught exception (' + err + '), this should never happen:\033[0m\n' + err.stack);
+	console.log('\x1b[41;1mUncaught exception (' + err + '), this should never happen:\x1b[0m\n' + err.stack);
 });
 
 if (typeof xmpp.StanzaBuilder.cnode != 'function' || typeof xmpp.StanzaBuilder.prototype.cnode != 'function') {
--- a/storage.js
+++ b/storage.js
@@ -17,6 +17,8 @@
  *  along with PSĜS.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+'use strict';
+
 var fs = require('fs');
 var sha1hex = require('sha1').hex;
 require('./iso8601');
@@ -493,5 +495,5 @@ storage.getAffiliationsFromNodeID = func
 };
 
 storage.debug = function() {
-	console.log('\033[1;33m' + require('sys').inspect(backend.list, null, null) + '\033[0m');
+	console.log('\x1b[1;33m' + require('sys').inspect(backend.list, null, null) + '\x1b[0m');
 };