Move default storage directory; better naming of nodes; fix notification sending.

Mon, 25 Jul 2011 17:35:32 -0700

author
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date
Mon, 25 Jul 2011 17:35:32 -0700
changeset 55
fd69d35cf2e6
parent 54
c2c9c06d6e9d
child 56
99bd1d1ac071

Move default storage directory; better naming of nodes; fix notification sending.

.hgignore file | annotate | diff | revisions
backends/directory.js file | annotate | diff | revisions
iso8601.js file | annotate | diff | revisions
modules/http/mod_atom.js file | annotate | diff | revisions
notifs.js file | annotate | diff | revisions
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/.hgignore	Mon Jul 25 17:35:32 2011 -0700
     1.3 @@ -0,0 +1,2 @@
     1.4 +data/
     1.5 +nohup.out
     2.1 --- a/backends/directory.js	Fri May 06 17:51:15 2011 +0200
     2.2 +++ b/backends/directory.js	Mon Jul 25 17:35:32 2011 -0700
     2.3 @@ -25,7 +25,7 @@
     2.4  
     2.5  backend.save = function(dir) {
     2.6  	if (!dir)
     2.7 -		dir = 'storage';
     2.8 +		dir = 'data';
     2.9  
    2.10  	fs.stat(dir, function(err, stats) {
    2.11  		if (err)
    2.12 @@ -57,7 +57,7 @@
    2.13  			var inspect = require('sys').inspect;
    2.14  
    2.15  			for (var nodeID in data)
    2.16 -				fs.writeFile(dir+'/'+nodeID+'.json', inspect(data[nodeID], false, null));
    2.17 +				fs.writeFile(dir+'/'+encodeURI(nodeID).replace('/', '%2f')+'.json', inspect(data[nodeID], false, null));
    2.18  
    2.19  			var toDelete = [];
    2.20  
    2.21 @@ -68,14 +68,14 @@
    2.22  			}
    2.23  
    2.24  			for (var nodeID in toDelete)
    2.25 -				fs.unlink(dir+'/'+toDelete[nodeID]);
    2.26 +				fs.unlink(dir+'/'+encodeURI(toDelete[nodeID]).replace('/', '%2f'));
    2.27  		});
    2.28  	});
    2.29  }
    2.30  
    2.31  backend.load = function(dir) {
    2.32  	if (!dir)
    2.33 -		dir = 'storage';
    2.34 +		dir = 'data';
    2.35  
    2.36  	fs.stat(dir, function(err, stats) {
    2.37  		if (err)
    2.38 @@ -120,7 +120,7 @@
    2.39  				if (/^\./.test(file))
    2.40  					continue;
    2.41  
    2.42 -				var nodeID = file.replace(/\.json$/, '');
    2.43 +				var nodeID = decodeURI(file.replace(/\.json$/, '').replace('%2f', '/'));
    2.44  
    2.45  				var data = fs.readFileSync(dir+'/'+file).toString();
    2.46  
     3.1 --- a/iso8601.js	Fri May 06 17:51:15 2011 +0200
     3.2 +++ b/iso8601.js	Mon Jul 25 17:35:32 2011 -0700
     3.3 @@ -35,6 +35,6 @@
     3.4  	return this;
     3.5  };
     3.6  
     3.7 -Date.prototype.toString = function () {
     3.8 +Date.prototype.toISO8601 = Date.prototype.toString = function () {
     3.9  	return this.toISOString().replace(/\....Z$/, 'Z');
    3.10  };
     4.1 --- a/modules/http/mod_atom.js	Fri May 06 17:51:15 2011 +0200
     4.2 +++ b/modules/http/mod_atom.js	Mon Jul 25 17:35:32 2011 -0700
     4.3 @@ -23,7 +23,7 @@
     4.4  	url: /^\/atom/,
     4.5  	func: function (req, res) {
     4.6  		var url = require('url').parse(req.url);
     4.7 -		nodeID = url.pathname.substr(url.pathname.indexOf('/', 1)+1);
     4.8 +		var nodeID = url.pathname.substr(url.pathname.indexOf('/', 1)+1);
     4.9  
    4.10  		var children;
    4.11  		if (nodeID && nodeID != '') {
     5.1 --- a/notifs.js	Fri May 06 17:51:15 2011 +0200
     5.2 +++ b/notifs.js	Mon Jul 25 17:35:32 2011 -0700
     5.3 @@ -151,7 +151,7 @@
     5.4  			}
     5.5  		}
     5.6  
     5.7 -		var message = xmpp.message({to: i, from: config.jid, id: conn.getUniqueId()});
     5.8 +		var message = xmpp.message({to: i, from: config.jid, id: conn.getUniqueId(), type: 'headline'});
     5.9  		message.cnode(ev);
    5.10  		conn.send(message);
    5.11  	}
    5.12 @@ -162,7 +162,7 @@
    5.13  	if (sub.digestTimeout)
    5.14  		sub.digestTimeout = false;
    5.15  
    5.16 -	var message = xmpp.message({to: jid, from: config.jid, id: conn.getUniqueId()});
    5.17 +	var message = xmpp.message({to: jid, from: config.jid, id: conn.getUniqueId(), type: 'headline'});
    5.18  	for (var i in sub.digest)
    5.19  		message.cnode(sub.digest[i]);
    5.20  	conn.send(message);

mercurial