Mercurial > psgxs
changeset 55:fd69d35cf2e6
Move default storage directory; better naming of nodes; fix notification sending.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Mon, 25 Jul 2011 17:35:32 -0700 |
parents | c2c9c06d6e9d |
children | 99bd1d1ac071 |
files | .hgignore backends/directory.js iso8601.js modules/http/mod_atom.js notifs.js |
diffstat | 5 files changed, 11 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/backends/directory.js +++ b/backends/directory.js @@ -25,7 +25,7 @@ var backend = exports; backend.save = function(dir) { if (!dir) - dir = 'storage'; + dir = 'data'; fs.stat(dir, function(err, stats) { if (err) @@ -57,7 +57,7 @@ backend.save = function(dir) { var inspect = require('sys').inspect; for (var nodeID in data) - fs.writeFile(dir+'/'+nodeID+'.json', inspect(data[nodeID], false, null)); + fs.writeFile(dir+'/'+encodeURI(nodeID).replace('/', '%2f')+'.json', inspect(data[nodeID], false, null)); var toDelete = []; @@ -68,14 +68,14 @@ backend.save = function(dir) { } for (var nodeID in toDelete) - fs.unlink(dir+'/'+toDelete[nodeID]); + fs.unlink(dir+'/'+encodeURI(toDelete[nodeID]).replace('/', '%2f')); }); }); } backend.load = function(dir) { if (!dir) - dir = 'storage'; + dir = 'data'; fs.stat(dir, function(err, stats) { if (err) @@ -120,7 +120,7 @@ backend.load = function(dir) { if (/^\./.test(file)) continue; - var nodeID = file.replace(/\.json$/, ''); + var nodeID = decodeURI(file.replace(/\.json$/, '').replace('%2f', '/')); var data = fs.readFileSync(dir+'/'+file).toString();
--- a/iso8601.js +++ b/iso8601.js @@ -35,6 +35,6 @@ Date.prototype.setFromISO8601 = function return this; }; -Date.prototype.toString = function () { +Date.prototype.toISO8601 = Date.prototype.toString = function () { return this.toISOString().replace(/\....Z$/, 'Z'); };
--- a/modules/http/mod_atom.js +++ b/modules/http/mod_atom.js @@ -23,7 +23,7 @@ exports.atom = { url: /^\/atom/, func: function (req, res) { var url = require('url').parse(req.url); - nodeID = url.pathname.substr(url.pathname.indexOf('/', 1)+1); + var nodeID = url.pathname.substr(url.pathname.indexOf('/', 1)+1); var children; if (nodeID && nodeID != '') {
--- a/notifs.js +++ b/notifs.js @@ -151,7 +151,7 @@ exports.send = function(notifs, type, no } } - var message = xmpp.message({to: i, from: config.jid, id: conn.getUniqueId()}); + var message = xmpp.message({to: i, from: config.jid, id: conn.getUniqueId(), type: 'headline'}); message.cnode(ev); conn.send(message); } @@ -162,7 +162,7 @@ exports.sendDigest = function(jid, nodeI if (sub.digestTimeout) sub.digestTimeout = false; - var message = xmpp.message({to: jid, from: config.jid, id: conn.getUniqueId()}); + var message = xmpp.message({to: jid, from: config.jid, id: conn.getUniqueId(), type: 'headline'}); for (var i in sub.digest) message.cnode(sub.digest[i]); conn.send(message);