X-Git-Url: http://git.onelab.eu/?p=myops.git;a=blobdiff_plain;f=web%2Fquery%2Fvendor%2Fcouchapp%2Flib%2Fatom.js;fp=web%2Fquery%2Fvendor%2Fcouchapp%2Flib%2Fatom.js;h=9d4c56440acca148772940023b1ec56cf44d8944;hp=0000000000000000000000000000000000000000;hb=85070b3d456667f238051af1a2f1f2a0c12300ab;hpb=607f0e13927eb18075c375fa9ba5527da4fcbb44 diff --git a/web/query/vendor/couchapp/lib/atom.js b/web/query/vendor/couchapp/lib/atom.js new file mode 100644 index 0000000..9d4c564 --- /dev/null +++ b/web/query/vendor/couchapp/lib/atom.js @@ -0,0 +1,39 @@ +// atom feed generator +// requries E4X support. + +function f(n) { // Format integers to have at least two digits. + return n < 10 ? '0' + n : n; +} + +function rfc3339(date) { + return date.getUTCFullYear() + '-' + + f(date.getUTCMonth() + 1) + '-' + + f(date.getUTCDate()) + 'T' + + f(date.getUTCHours()) + ':' + + f(date.getUTCMinutes()) + ':' + + f(date.getUTCSeconds()) + 'Z'; +}; + +exports.header = function(data) { + var f = ; + f.title = data.title; + f.id = data.feed_id; + f.link.@href = data.feed_link; + f.link.@rel = "self"; + f.generator = "CouchApp on CouchDB"; + f.updated = rfc3339(data.updated); + return f.toXMLString().replace(/\<\/feed\>/,''); +}; + +exports.entry = function(data) { + var entry = ; + entry.id = data.entry_id; + entry.title = data.title; + entry.content = data.content; + entry.content.@type = (data.content_type || 'html'); + entry.updated = rfc3339(data.updated); + entry.author = {data.author}; + entry.link.@href = data.alternate; + entry.link.@rel = "alternate"; + return entry; +} \ No newline at end of file