2 // requries E4X support.
4 function f(n) { // Format integers to have at least two digits.
5 return n < 10 ? '0' + n : n;
8 function rfc3339(date) {
9 return date.getUTCFullYear() + '-' +
10 f(date.getUTCMonth() + 1) + '-' +
11 f(date.getUTCDate()) + 'T' +
12 f(date.getUTCHours()) + ':' +
13 f(date.getUTCMinutes()) + ':' +
14 f(date.getUTCSeconds()) + 'Z';
17 exports.header = function(data) {
18 var f = <feed xmlns="http://www.w3.org/2005/Atom"/>;
21 f.link.@href = data.feed_link;
23 f.generator = "CouchApp on CouchDB";
24 f.updated = rfc3339(data.updated);
25 return f.toXMLString().replace(/\<\/feed\>/,'');
28 exports.entry = function(data) {
30 entry.id = data.entry_id;
31 entry.title = data.title;
32 entry.content = data.content;
33 entry.content.@type = (data.content_type || 'html');
34 entry.updated = rfc3339(data.updated);
35 entry.author = <author><name>{data.author}</name></author>;
36 entry.link.@href = data.alternate;
37 entry.link.@rel = "alternate";