comparison server.js @ 2:eb5b6d3ab09b

Better import of ns and jid; fix email and missing ns.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Wed, 13 Jul 2011 13:11:54 +0200
parents 82905edac9d8
children 2e2a2154efbb
comparison
equal deleted inserted replaced
1:82905edac9d8 2:eb5b6d3ab09b
7 var util = require('util'); 7 var util = require('util');
8 var http = require('http'); 8 var http = require('http');
9 var fs = require('fs'); 9 var fs = require('fs');
10 var xmpp = require('node-xmpp'); 10 var xmpp = require('node-xmpp');
11 var Element = xmpp.Element; 11 var Element = xmpp.Element;
12 var JID = require('./jid').JID; 12 var JID = require('./jid');
13 var ns = require('./ns').ns; 13 var ns = require('./ns');
14 var forms = require('./forms'); 14 var forms = require('./forms');
15 require('./date'); 15 require('./date');
16 16
17 var received = {}; 17 var received = {};
18 18
131 131
132 payload = stanza.getChild('pubsub', ns.ps); 132 payload = stanza.getChild('pubsub', ns.ps);
133 if (payload) 133 if (payload)
134 return handlePubSub(payload, stanza.attrs.from); 134 return handlePubSub(payload, stanza.attrs.from);
135 135
136 } else if (stanza.is('message')) { 136 } else if (stanza.is('message', ns.j)) {
137 var type = stanza.attrs.type; 137 var type = stanza.attrs.type;
138 if (type === 'error') 138 if (type === 'error')
139 return; 139 return;
140 140
141 if (type !== 'headline') 141 if (type !== 'headline')
175 footer.c('cite').t(name); 175 footer.c('cite').t(name);
176 } 176 }
177 177
178 try { 178 try {
179 var email = author.getChild('email', ns.atom).getText(); 179 var email = author.getChild('email', ns.atom).getText();
180 footer.t(', (').c('a', {href: email}).t('email').up().t(')'); 180 footer.t(' (').c('a', {href: 'mailto:' + email}).t('email').up().t(')');
181 } catch (e) { } 181 } catch (e) { }
182 footer.up(); 182 footer.up();
183 } 183 }
184 184
185 var published = atom.getChild('published', ns.atom).getText(); 185 var published = atom.getChild('published', ns.atom).getText();
240 var item = data[id]; 240 var item = data[id];
241 var article = parseAtom(item, id, jid); 241 var article = parseAtom(item, id, jid);
242 body = article + body; 242 body = article + body;
243 } 243 }
244 body = '<div e:jid="' + jid.full + '">' + body; 244 body = '<div e:jid="' + jid.full + '">' + body;
245 245
246 home(res, form['pubsub#title'], form['pubsub#description'], body, 'Node created the <time>' + form['pubsub#creation_date'] + '</time> by <cite>' + form['pubsub#creator'] + '</cite> with <a href="http://linkmauve.fr/dev/eldonilo/blog">Eldonilo blog</a>.', noscript); 246 home(res, form['pubsub#title'], form['pubsub#description'], body, 'Node created the <time>' + form['pubsub#creation_date'] + '</time> by <cite>' + form['pubsub#creator'] + '</cite> with <a href="http://linkmauve.fr/dev/eldonilo/blog">Eldonilo blog</a>.', noscript);
247 }; 247 };
248 248
249 var servePage = function(url, res) { 249 var servePage = function(url, res) {
250 util.log(url.href); 250 util.log(url.href);