~ubuntu-branches/ubuntu/vivid/lurker/vivid

« back to all changes in this revision

Viewing changes to render/list.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonas Meurer
  • Date: 2006-12-20 05:05:31 UTC
  • mfrom: (3.1.6 feisty)
  • Revision ID: james.westby@ubuntu.com-20061220050531-79inzy7o6uu95qx7
Tags: 2.1-7
* updated vi debconf translations, thanks to Clytie Siddall
  <clytie@riverland.net.au>
* fixed typo in one template (that you would like, not that
  would you like), thanks as well to Clytie Siddall
  - unfuzzied all translations

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*  $Id: list.cpp,v 1.11 2004/08/27 15:04:05 terpstra Exp $
 
1
/*  $Id: list.cpp,v 1.16 2006/03/01 14:55:45 terpstra Exp $
2
2
 *  
3
3
 *  list.cpp - Handle a list/ command
4
4
 *  
22
22
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23
23
 */
24
24
 
25
 
#define _XOPEN_SOURCE 500
26
25
#define _FILE_OFFSET_BITS 64
27
26
 
28
27
#include <iostream>
47
46
#define NUM_TOPICS      20
48
47
#define NUM_DAYS        14
49
48
 
50
 
int list_format_error(const string& param)
51
 
{
52
 
        cout << "Status: 200 OK\r\n";
53
 
        cout << "Content-Type: text/html\r\n\r\n";
54
 
        cout << error(_("Bad request"), param,
55
 
                _("The given parameter was not of the correct format. "
56
 
                  "A list request must be formatted like: "
57
 
                  "list/listid.xml where listid "
58
 
                  "is the id of an indexed mailing list."));
59
 
        return 1;
60
 
}
61
 
 
62
 
int list_load_error(const string& ok)
63
 
{
64
 
        cout << "Status: 200 OK\r\n";
65
 
        cout << "Content-Type: text/html\r\n\r\n";
66
 
        cout << error(_("Database list pull failure"), ok,
67
 
                _("Something internal to the database failed. "
68
 
                  "Please contact the lurker user mailing list for "
69
 
                  "further assistence."));
70
 
        return 1;
71
 
}
72
 
 
73
49
// nested types break g++ 2.95
74
50
struct NewTopic
75
51
{
102
78
                {
103
79
                        Summary sum(id);
104
80
                        string ok = sum.load(db, cfg);
105
 
                        if (ok != "") return list_load_error(ok);
 
81
                        if (ok != "") 
 
82
                                error(_("Database list pull failure"), ok,
 
83
                                      _("Something internal to the database failed. "
 
84
                                        "Please contact the lurker user mailing list for "
 
85
                                        "further assistence."));
106
86
                        if (!sum.deleted()) t.newest = sum;
107
87
                }
108
88
                
123
103
        Request req = parse_request(param);
124
104
        cfg.options = req.options;
125
105
        
126
 
        if (cfg.lists.find(req.options) == cfg.lists.end())
127
 
        {
128
 
                cout << "Status: 200 OK\r\n";
129
 
                cout << "Content-Type: text/html\r\n\r\n";
130
 
                cout << error(_("No such list"), req.options,
131
 
                        _("The specified mailing list is not available in this "
132
 
                          "archive. Perhaps you misspelled it or went to the "
133
 
                          "wrong server?"));
134
 
                return 1;
135
 
        }
136
 
        
137
 
        const List& list = cfg.lists.find(req.options)->second;
 
106
        const Config::Lists::const_iterator li = cfg.lists.find(req.options);
 
107
        
 
108
        // Identical error message if it's missing or not allowed (security)
 
109
        if (li == cfg.lists.end() || !li->second.allowed)
 
110
                error(_("No such list"), req.options,
 
111
                      _("The specified mailing list is not available in this "
 
112
                        "archive. Perhaps you misspelled it or went to the "
 
113
                        "wrong server?"));
 
114
        
 
115
        const List& list = li->second;
138
116
        
139
117
        // Right! Everything the user did is ok.
140
118
        
183
161
        Cache cache(cfg, "list", param, req.ext);
184
162
        
185
163
        cache.o << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
186
 
                << "<?xml-stylesheet type=\"text/xsl\" href=\"../fmt/list.xsl\"?>\n"
 
164
                << "<?xml-stylesheet type=\"text/xsl\" href=\"../ui/list.xsl\"?>\n"
187
165
                << "<list xml:lang=\"" << req.language << "\">\n"
 
166
                << " <mode>" << req.ext << "</mode>\n"
188
167
                << " " << cfg(req.language) << "\n"
189
168
                << " " << list(req.language) << "\n";
190
169