# HG changeset patch # User Emmanuel Gil Peyrot # Date 1311640532 25200 # Node ID fd69d35cf2e680b5228e7b54df4334aa714d746b # Parent c2c9c06d6e9d0693992ded3a36e2d7bdbfd2d234 Move default storage directory; better naming of nodes; fix notification sending. diff --git a/.hgignore b/.hgignore new file mode 100644 --- /dev/null +++ b/.hgignore @@ -0,0 +1,2 @@ +data/ +nohup.out diff --git a/backends/directory.js b/backends/directory.js --- 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(); diff --git a/iso8601.js b/iso8601.js --- 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'); }; diff --git a/modules/http/mod_atom.js b/modules/http/mod_atom.js --- 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 != '') { diff --git a/notifs.js b/notifs.js --- 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);