-
Notifications
You must be signed in to change notification settings - Fork 32
/
rss.js
66 lines (60 loc) · 2.18 KB
/
rss.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
function (head, req) {
var fixDate = function(s) {
if (Date.parse) {
try {
var d = new Date(Date.parse(s));
return d.toUTCString();
} catch (e) {
}
}
return s;
};
var escape = function(s){
if (!s) { s = ""; }
s = s.toString();
return s.replace(/"/g, '"')
.replace(/>/g, '>')
.replace(/</g, '<')
.replace(/&/g, '&');
};
var appDBPrefix = 'acra-';
start({ "headers" : {"Content-type" : "application/rss+xml"}});
var NB_ITEMS_MAX = 30;
send('<rss version="0.91">');
send('<channel>');
var appName = req.path[0].substring(appDBPrefix.length);
send('<title>' + appName + ' latest Crash Reports</title>');
send('<link>http://' + req.headers.Host + '/acralyzer/_design/acralyzer/index.html#/dashboard/' + appName + '</link>');
send('<description>Acralyzer latest crash reports.</description>');
var nbItems = 0;
while ((nbItems < NB_ITEMS_MAX) && (row = getRow())) {
nbItems++;
send('<item>');
send('<title>');
if(row.value.signature) {
send(row.value.signature.digest);
}
send('</title>');
send('<link>http://'+ req.headers.Host);
send('/acralyzer/_design/acralyzer/index.html#/report-details/' + appName + '/' + row.id +'</link>');
send('<description><![CDATA[');
if(row.value.application_version_name) {
send('<p>app_version: ' + escape(row.value.application_version_name) + '</p>');
}
if(row.value.android_version) {
send('<p>android_version: ' + escape(row.value.android_version) + '</p>');
}
if(row.value.device) {
send('<p>device: ' + escape(row.value.device) + '</p>');
}
if(row.value.signature) {
send('<p>crash line: ' + escape(row.value.signature.full) + '</p>');
}
send(']]></description>');
send('<guid isPermaLink="false">' + row.id + '</guid>');
send('<pubDate>' + fixDate(row.key) + '</pubDate>');
send('</item>');
}
send('</channel>');
send('</rss>');
}