root/main/trunk/greenstone2/runtime-src/src/recpt/rssaction.cpp @ 24958

Revision 24958, 4.3 KB (checked in by ak19, 8 years ago)

First commit to do with Greenstone's support for RSS. Committing Dr Bainbridge's code which was already working for windows. This has now been tested on Linux, where it can be got to work with changes to zextra.dm and base.dm and if the rss-items.rdf file generated by the update to BasePlugout? is moved to the index folder). The next set of commits will make the way rssaction.cpp accesses the rss-items.rdf file independent of where the GS server is located, with changes to the protocol class.

  • Property svn:executable set to *
Line 
1/**********************************************************************
2 *
3 * rssaction.cpp --
4 * Copyright (C) 1999  The New Zealand Digital Library Project
5 *
6 * A component of the Greenstone digital library software
7 * from the New Zealand Digital Library Project at the
8 * University of Waikato, New Zealand.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 *
24 *********************************************************************/
25
26#include "gsdl_modules_cfg.h"
27#ifdef USE_RSS
28
29#include "fileutil.h"
30
31#include "rssaction.h"
32
33rssaction::rssaction () {
34  // this action uses cgi variable "a"
35  cgiarginfo arg_ainfo;
36  arg_ainfo.shortname = "a";
37  arg_ainfo.longname = "action";
38  arg_ainfo.multiplechar = true;
39  arg_ainfo.multiplevalue = false;
40  arg_ainfo.defaultstatus = cgiarginfo::weak;
41  arg_ainfo.argdefault = "rss";
42  arg_ainfo.savedarginfo = cgiarginfo::must;
43
44  argsinfo.addarginfo (NULL, arg_ainfo);
45
46}
47
48void rssaction::get_cgihead_info (cgiargsclass &/*args*/, recptprotolistclass * /*protos*/,
49                   response_t &response, text_t &response_data,
50                   ostream &/*logout*/) {
51  response = content;
52  response_data = "application/rdf+xml";
53}
54
55void rssaction::generate_rss_header( displayclass &disp,
56                     outconvertclass &outconvert, ostream &textout,
57                     ostream &logout)
58{
59  textout << outconvert << disp
60      << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
61      << "<rss version=\"2.0\"\n"
62      << "xmlns:content=\"http://purl.org/rss/1.0/modules/content/\"\n"
63      << "  xmlns:taxo=\"http://purl.org/rss/1.0/modules/taxonomy/\"\n"
64      << "  xmlns:dc=\"http://purl.org/dc/elements/1.1/\"\n"
65      << "  xmlns:syn=\"http://purl.org/rss/1.0/modules/syndication/\"\n"
66      << "  xmlns:admin=\"http://webns.net/mvcb/\">\n"
67
68      << "<channel>\n"
69      << "  <title>_collectionname_</title>\n"
70      << "  <link>_httppageabout_</link>\n"
71      << "  <description>_collectionextra_</description>\n"
72      << "  <language>_cgiargl_</language>\n"
73      << "  <pubDate>Thu, 23 Aug 1999 07:00:00 GMT</pubDate>\n"
74      << "  <lastBuildDate>Thu, 23 Aug 1999 16:20:26 GMT</lastBuildDate>\n"
75      << "  <managingEditor>_creator_</managingEditor>\n"
76      << "  <webMaster>_maintainer_</webMaster>\n"
77
78      << "<image>\n"
79      << "  <title>_collectionname_</title>\n"
80      << "  <url>_iconcollection_</url>\n"
81      << "  <link>_httppageabout_</link>\n"
82      << "  <description>_collectionextra_</description>\n"
83      << "</image>\n";
84}
85
86void rssaction::generate_rss_content(text_t& rss_filename, displayclass &disp,
87                     outconvertclass &outconvert, ostream &textout,
88                     ostream &logout)
89{
90  text_t rss_items;
91
92  if (read_file(rss_filename,rss_items)) {
93    textout << outconvert << disp << rss_items;
94  }
95
96
97}
98
99void rssaction::generate_rss_footer( displayclass &disp,
100                     outconvertclass &outconvert, ostream &textout,
101                     ostream &logout)
102{
103
104  textout << outconvert << disp
105      << "  </channel>\n"
106      << "</rss>\n";
107}
108
109
110
111
112bool rssaction::do_action (cgiargsclass &args, recptprotolistclass *protos,
113                browsermapclass * /*browsers*/, displayclass& disp,
114                outconvertclass &outconvert, ostream &textout,
115                ostream &logout) {
116  //bool wassuccess = false;
117  //comerror_t err;
118 
119
120  /*
121  recptproto *collectproto = protos->getrecptproto (args["c"], logout);
122  if (!args["c"].empty() && (collectproto != NULL)) {
123    collectproto->ping (args["c"], wassuccess, err, logout);
124    if (err != noError) wassuccess = false; // a communication error
125  }
126  */
127
128  text_t rss_filename = filename_cat(gsdlhome,"collect",args["c"],"index","rss-items.rdf");
129
130  generate_rss_header(disp,outconvert,textout,logout);
131  generate_rss_content(rss_filename,disp,outconvert,textout,logout);
132  generate_rss_footer(disp,outconvert,textout,logout);
133
134  return true;
135};
136
137#endif //USE_RSS
Note: See TracBrowser for help on using the browser.