Mercurial > psgxs
view modules/http/mod_atom.js @ 42:07ca0263a53f
Add an option to hide non-accessible nodes.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Sat, 26 Feb 2011 17:39:49 +0100 |
parents | bc717575e66a |
children | 023f767662d3 |
line wrap: on
line source
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 children; if (nodeID && nodeID != '') { var md = storage.getMetadata(nodeID); if (md['pubsub#type'] != NS.ATOM) return false; var response = xmpp.stanza('feed', {xmlns: 'http://www.w3.org/2005/Atom'}); res.writeHead(200, {'Content-Type': 'text/xml'}); if (!storage.existsNode(nodeID)) return false; if (md['pubsub#title']) response.c('title').t(md['pubsub#title']).up(); if (md['pubsub#description']) response.c('subtitle').t(md['pubsub#description']).up(); if (md['pubsub#creation_date']) response.c('published').t(md['pubsub#creation_date'].toString()).up(); children = storage.getItems(nodeID); if (typeof children == 'number') return false; for (var i in children) response.cnode(children[i].content).up(); } else { res.writeHead(200, {'Content-Type': 'text/xml'}); var response = xmpp.stanza('ul', {xmlns: 'http://www.w3.org/1999/xhtml'}); children = storage.getChildren(); if (typeof children == 'number') return false; for (var i in children) response.c('li').c('a', {href: i}).t(i).up().up(); } res.end(response.toString()); return true; }, }