RSS feed generator
[citadel.git] / webcit / feed_generator.c
1 /*
2  * RSS/Atom feed generator
3  *
4  * Copyright (c) 2005-2010 by the citadel.org team
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #include "webcit.h"
22 #include "webserver.h"
23
24
25
26 /*
27  * Main entry point for GroupDAV requests
28  */
29 void feed_rss(void) {
30
31         output_headers(0, 0, 0, 1, 1, 0);
32         hprintf("Content-type: text/xml\r\n");
33         hprintf(
34                 "Server: %s / %s\r\n"
35                 "Connection: close\r\n"
36         ,
37                 PACKAGE_STRING, ChrPtr(WC->serv_info->serv_software)
38         );
39         begin_burst();
40
41         wc_printf("<?xml version=\"1.0\"?>"
42                 "<rss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\">"
43                 "<channel>"
44         );
45
46         wc_printf("<title>");
47         escputs(ChrPtr(WC->CurRoom.name));
48         wc_printf("</title>");
49
50         wc_printf("<link>");
51         urlescputs(ChrPtr(site_prefix));
52         wc_printf("</link>");
53
54         //      <language>en-us</language>
55         //      <description>Linux Today News Service</description>
56         //      <atom:link href="http://linuxtoday.com/biglt.rss" rel="self" type="application/rss+xml" />
57
58         //    <image>
59         //      <title>Linux Today</title>
60         //      <url>http://linuxtoday.com/pics/ltnet.png</url>
61         //      <link>http://linuxtoday.com</link>
62         //    </image>
63
64 #if 0
65     <item>
66       <title>lorem ipsum dolor sit amet</title>
67       <pubDate>Wed, 08 Sep 2010 20:03:21 GMT</pubDate>
68       <link>http://xxxxx.xxxx.xxxxxx.xxxx.xxx</link>
69       <description>&#60;b&#62;foo bar baz:&#60;/b&#62; lorem ipsum dolor sit amet, foo bar eek</description>
70       <guid>xxxx-xxxx-xxxx-xxxx-xxxx-xxxx</guid>
71     </item>
72 #endif
73
74         wc_printf("</channel>"
75                 "</rss>"
76                 "\r\n\r\n"
77         );
78
79         wDumpContent(0);
80         end_webcit_session();
81 }
82
83
84 void 
85 InitModule_RSS
86 (void)
87 {
88         WebcitAddUrlHandler(HKEY("feed_rss"), "", 0, feed_rss, ANONYMOUS|COOKIEUNNEEDED|FORCE_SESSIONCLOSE);
89 }