Mercurial > psgxs
comparison backends/file.js @ 56:99bd1d1ac071
Migration to node-xmpp, done!
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Wed, 10 Aug 2011 15:11:22 -0700 |
parents | 023f767662d3 |
children |
comparison
equal
deleted
inserted
replaced
55:fd69d35cf2e6 | 56:99bd1d1ac071 |
---|---|
48 | 48 |
49 fs.writeFile(file, require('sys').inspect(data, null, null)); | 49 fs.writeFile(file, require('sys').inspect(data, null, null)); |
50 } | 50 } |
51 | 51 |
52 backend.load = function(file) { | 52 backend.load = function(file) { |
53 var xmpp = require('xmpp'); | 53 var parse = require('ltx').parse; |
54 function parseStanza(path, content) { | |
55 var stanza = null; | |
56 var stream = new xmpp.Stream({ | |
57 stanza: function (stanza) { | |
58 path[content] = stanza; | |
59 } | |
60 }); | |
61 stream.opened = true; | |
62 stream.data(path[content]); | |
63 } | |
64 | |
65 function endParsing(o) { | 54 function endParsing(o) { |
66 var regexp = /\d{4}-\d\d-\d\dT\d\d:\d\d:\d\dZ/; | 55 var regexp = /\d{4}-\d\d-\d\dT\d\d:\d\d:\d\dZ/; |
67 for (var i in o) { | 56 for (var i in o) { |
68 if (typeof o[i] == 'string' && i == 'content') | 57 if (typeof o[i] == 'string' && i == 'content') |
69 parseStanza(o, i); | 58 o[i] = parse(o[i]); |
70 else if (typeof o[i] == 'string' && regexp(o[i])) { | 59 else if (typeof o[i] == 'string' && regexp(o[i])) { |
71 var today = new Date(); | 60 var today = new Date(); |
72 today.setFromISO8601(o[i]); | 61 today.setFromISO8601(o[i]); |
73 o[i] = today; | 62 o[i] = today; |
74 } else if (typeof o[i] == 'object') | 63 } else if (typeof o[i] == 'object') |