comparison server.js @ 7:7ab6b48122af

Add support for content in Atom and improve published display.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Wed, 02 Nov 2011 09:35:46 -0700
parents 29becdd02dea
children 360186772aa3
comparison
equal deleted inserted replaced
6:29becdd02dea 7:7ab6b48122af
147 return handlePubSub(payload, stanza.attrs.from); 147 return handlePubSub(payload, stanza.attrs.from);
148 } 148 }
149 }); 149 });
150 150
151 var parseAtom = function(atom, id, jid) { 151 var parseAtom = function(atom, id, jid) {
152 var article = new Element('article', {'e:id': id, 'e:date': '2011-06-02T10:59:39Z'}); 152 var article = new Element('article', {'e:id': id});
153 153
154 var avatar = article.c('aside').c('img') 154 var avatar = article.c('aside').c('img')
155 article.up(); 155 article.up();
156 156
157 try { 157 try {
181 footer.t(' (').c('a', {href: 'mailto:' + email}).t('email').up().t(')'); 181 footer.t(' (').c('a', {href: 'mailto:' + email}).t('email').up().t(')');
182 } catch (e) { } 182 } catch (e) { }
183 footer.up(); 183 footer.up();
184 } 184 }
185 185
186 var published = atom.getChild('published', ns.atom).getText(); 186 var published = (function() {
187 if (published) { 187 try {
188 if (author) 188 var elem = atom.getChild('published', ns.atom);
189 footer.t(', '); 189 var iso8601 = elem.getText();
190 footer.c('time', {datetime: published}).t((new Date).set8601(published).getRelative()).up(); 190 var d = (new Date).set8601(iso8601);
191 } 191 var relative = d.getRelative();
192
193 return {iso8601: iso8601, relative: relative};
194 } catch (e) {
195 var d = new Date;
196 return {iso8601: d.to8601(), relative: d.getRelative()};
197 }
198 })();
199
200 if (author)
201 footer.t(', ');
202 footer.c('time', {datetime: published.iso8601}).t(published.relative).up();
203 article.attrs['e:date'] = published.iso8601;
192 204
193 try { 205 try {
194 var summary = atom.getChild('summary', ns.atom).getText(); 206 var summary = atom.getChild('summary', ns.atom).getText();
195 if (summary) 207 if (summary)
196 article.c('p').t(summary).up(); 208 article.c('p').t(summary).up();