c8adc36001aab3724fc45b760c82b740589a0c1d
[elisp/gnus.git-] / lisp / nnrss.el
1 ;;; nnrss.el --- interfacing with RSS
2 ;; Copyright (C) 2001, 2002  Free Software Foundation, Inc.
3
4 ;; Author: Shenghuo Zhu <zsh@cs.rochester.edu>
5 ;; Keywords: RSS
6
7 ;; This file is part of GNU Emacs.
8
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published
11 ;; by the Free Software Foundation; either version 2, or (at your
12 ;; option) any later version.
13
14 ;; GNU Emacs is distributed in the hope that it will be useful, but
15 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 ;; General Public License for more details.
18
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA.
23
24 ;;; Commentary:
25
26 ;;; Code:
27
28 (eval-when-compile (require 'cl))
29
30 (require 'gnus)
31 (require 'nnoo)
32 (require 'nnmail)
33 (require 'message)
34 (require 'mm-util)
35 (require 'gnus-util)
36 (require 'time-date)
37 (require 'rfc2231)
38 (require 'mm-url)
39 (eval-when-compile
40   (ignore-errors
41     (require 'xml)))
42 (eval '(require 'xml))
43
44 (nnoo-declare nnrss)
45
46 (defvoo nnrss-directory (nnheader-concat gnus-directory "rss/")
47   "Where nnrss will save its files.")
48
49 ;; (group max rss-url)
50 (defvoo nnrss-server-data nil)
51
52 ;; (num timestamp url subject author date extra)
53 (defvoo nnrss-group-data nil)
54 (defvoo nnrss-group-max 0)
55 (defvoo nnrss-group-min 1)
56 (defvoo nnrss-group nil)
57 (defvoo nnrss-group-hashtb nil)
58 (defvoo nnrss-status-string "")
59
60 (defconst nnrss-version "nnrss 1.0")
61
62 (defvar nnrss-group-alist
63   '(("MacWeek"
64      "http://macweek.zdnet.com/macweek.xml"
65      "The Macintosh news authority.")
66     ("Linux.Weekly.News"
67      "http://lwn.net/headlines/rss")
68     ("Motley.Fool"
69      "http://www.fool.com/About/headlines/rss_headlines.asp")
70     ("NewsForge.rdf"
71      "http://www.newsforge.com/newsforge.rdf")
72     ("Slashdot"
73      "http://www.slashdot.com/slashdot.rdf")
74     ("CNN"
75      "http://www.cnn.com/cnn.rss"
76      "The world's news leader.")
77     ("FreshMeat"
78      "http://freshmeat.net/backend/fm-releases.rdf"
79      "The one-stop-shop for all your Linux software needs.")
80     ("The.Guardian.newspaper"
81      "http://www.guardianunlimited.co.uk/rss/1,,,00.xml"
82      "Intelligent news and comment throughout the day from The Guardian newspaper.")
83     ("MonkeyFist.rdf"
84      "http://monkeyfist.com/rdf.php3"
85      "News and opinion on politics, technology, and eclectic miscellany.")
86     ("NewsForge"
87      "http://www.newsforge.com/newsforge.rss")
88     ("Reuters.Health"
89      "http://www.reutershealth.com/eline.rss"
90      "Consumer-oriented health-related news stories.")
91     ("Salon"
92      "http://www.salon.com/feed/RDF/salon_use.rdf")
93     ("Wired"
94      "http://www.wired.com/news_drop/netcenter/netcenter.rdf")
95     ("ITN"
96      "http://www.itn.co.uk/itn.rdf")
97     ("Meerkat"
98      "http://www.oreillynet.com/meerkat/?_fl=rss10"
99      "An Open Wire Service")
100     ("MonkeyFist"
101      "http://monkeyfist.com/rss1.php3"
102      "News and opinion on politics, technology, and eclectic miscellany.")
103     ("Reuters.Health.rdf"
104      "http://www.reutershealth.com/eline.rdf"
105      "Consumer-oriented health-related news stories.")
106 ;;("4xt" "http://4xt.org/news/general.rss10" "Resources for XT users.")
107     ("Aaronland" "http://aaronland.net/xml/abhb.rdf" "A boy and his basement.")
108     ("Art of the Mix" "http://www.artofthemix.org/xml/rss.asp" "A website devoted to the art of making mixed tapes and cds.")
109     ("Dave Beckett's RDF Resource Guide" "http://www.ilrt.bristol.ac.uk/discovery/rdf/resources/rss.rdf" "A comprehensive guide to resources about RDF.")
110     ("David Chess" "http://www.davidchess.com/words/log.rss" "Mostly-daily musings on philosophy, children, culture, technology, the emergence of life from matter, chocolate, Nomic, and all that sort of thing.")
111 ;;("Dublin Core Metadata Intitiative" "http://www.dublincore.org/news.rss" "Latest news from DCMI.")
112     ("Figby Articles" "http://www.figby.com/index-rss.php" "A weblog with daily stories about technology, books and publishing, privacy, science, and occasional humor.")
113 ;;("Figby News" "http://www.figby.com/news.php" "Categorized RSS feeds from various sources.")
114     ("Figby Quickies" "http://www.figby.com/quickies-rss.php" "Quick commented links to other sites from Figby.com.")
115     ("Flutterby!" "http://www.flutterby.com/main.rdf" "News and views from Dan Lyke.")
116     ("Groovelog" "http://groovelog.agora.co.uk/groove+log/groovelog.nsf/today.rss.xml" "The open-access groove users' weblog.")
117 ;;("Groovelog.rss10" "http://groovelog.agora.co.uk/groove+log/groovelog.nsf/today.rss10.xml" "The open-access groove users' weblog.")
118     ("Hit or Miss" "http://hit-or-miss.org/rss/" "Daily weblog and journal.")
119 ;;("Internet.com Feeds" "http://www.webreference.com/services/news/" "News from ")
120     ("Larkfarm News" "http://www.larkfarm.com/Larkfarm.rdf" "Mike Gunderloy's web site.")
121     ("Latest RFCs" "http://x42.com/rss/rfc.rss")
122     ("Linux Today" "http://linuxtoday.com/backend/biglt.rss")
123     ("Linux Today.rdf" "http://linuxtoday.com/backend/my-netscape10.rdf")
124     ("More Like This WebLog" "http://www.whump.com/moreLikeThis/RSS" "Because the more you know, the more jokes you get.")
125     ("Motivational Quotes of the Day" "http://www.quotationspage.com/data/mqotd.rss" "Four motivational quotations each day from the Quotations Page.")
126 ;;("My Netscape Network" "http://www.dmoz.org/Netscape/My_Netscape_Network/")
127     ;;("My UserLand" "http://my.userland.com/choose")
128     ("Network World Fusion NetFlash" "http://www.nwfusion.com/netflash.rss" "Daily breaking news about networking products, technologies and services.")
129 ;;("News Feeds" "http://newsfeeds.manilasites.com/" "Jeff Barr highlights high quality RSS feeds.")
130     ;;("News Is Free Export" "http://www.newsisfree.com/export.php3")
131     ("News Is Free" "http://www.newsisfree.com/news.rdf.php3")
132 ;;("News is Free XML Export" "http://www.newsisfree.com/ocs/directory.xml")
133     ("O'Reilly Network Articles" "http://www.oreillynet.com/cs/rss/query/q/260?x-ver=1.0")
134     ("Quotes of the Day" "http://www.quotationspage.com/data/qotd.rss" "Four humorous quotations each day from the Quotations Page.")
135     ("RDF Interest Group" "http://ilrt.org/discovery/rdf-dev/roads/cgi-bin/desire/ig2rss?list=www-rdf-interest" "An experimental channel scraped from the RDF Interest Group mail archives.")
136     ("RDF Logic List" "http://ilrt.org/discovery/rdf-dev/roads/cgi-bin/desire/ig2rss?list=www-rdf-logic" "An experimental channel scraped from the RDF Logic mail archives.")
137     ("RSS Info" "http://www.blogspace.com/rss/rss10" "News and information on the RSS format")
138 ;;("RSS-DEV listing" "http://www.egroups.com/links/rss-dev/Feeds_000966335046/" "A listing of RSS files from the RSS-DEV list.")
139     ("Semantic Web List" "http://ilrt.org/discovery/rdf-dev/roads/cgi-bin/desire/ig2rss?list=semantic-web" "An experimental channel scraped from the W3C's Semantic Web mail archives.")
140 ;;("Sherch!" "http://www.sherch.com/~pldms/cgi-bin/sherch.pl" "Sherlock for the rest of us.")
141 ;;("Street Fusion Archived Financial Webcasts" "http://partners.streetfusion.com/rdf/archive.rdf")
142 ;;("Street Fusion Upcoming Financial Webcasts" "http://partners.streetfusion.com/rdf/live.rdf")
143 ;;("TNL.net newsletter" "http://www.tnl.net/newsletter/channel100.asp" "A newsletter about Internet technology and issues.")
144     ("W3C" "http://www.w3.org/2000/08/w3c-synd/home.rss" "The latest news at the World Wide Web Consortium.")
145 ;;("XML News: RSS Live Content" "http://www.xmlnews.org/RSS/content.html" "A listing of well-known RSS feeds.")
146     ("|fr| XMLfr" "http://xmlfr.org/actualites/general.rss10"
147      "French speaking portal site dedicated to XML.")
148     ("XMLhack" "http://xmlhack.com/rss10.php"
149      "Developer news from the XML community.")
150     ("The Register"
151      "http://www.theregister.co.uk/tonys/slashdot.rdf"
152      "The Register -- Biting the hand that feeds IT.")
153     ("|de| Heise-Ticker"
154      "http://www.heise.de/newsticker/heise.rdf"
155      "German news ticker about technology.")
156     ("|de| Telepolis News"
157      "http://www.heise.de/tp/news.rdf"
158      "German background news about technology.")
159     ("Kuro5hin"
160      "http://www.kuro5hin.org/backend.rdf"
161      "Technology and culture, from the trenches.")
162     ("JabberCentral"
163      "http://www.jabbercentral.com/rss.php"
164      "News around the Jabber instant messaging system.")))
165
166 (defvar nnrss-use-local nil)
167
168 (defvar nnrss-description-field 'X-Gnus-Description
169   "Field name used for DESCRIPTION.
170 To use the description in headers, put this name into `nnmail-extra-headers'.")
171
172 (defvar nnrss-url-field 'X-Gnus-Url
173   "Field name used for URL.
174 To use the description in headers, put this name into `nnmail-extra-headers'.")
175
176 (defvar nnrss-content-function nil
177   "A function which is called in `nnrss-request-article'.
178 The arguments are (ENTRY GROUP ARTICLE).
179 ENTRY is the record of the current headline. GROUP is the group name.
180 ARTICLE is the article number of the current headline.")
181
182 (nnoo-define-basics nnrss)
183
184 ;;; Interface functions
185
186 (deffoo nnrss-retrieve-headers (articles &optional group server fetch-old)
187   (nnrss-possibly-change-group group server)
188   (let (e)
189     (save-excursion
190       (set-buffer nntp-server-buffer)
191       (erase-buffer)
192       (dolist (article articles)
193         (if (setq e (assq article nnrss-group-data))
194             (insert (number-to-string (car e)) "\t" ;; number
195                     (if (nth 3 e)
196                         (nnrss-format-string (nth 3 e)) "")
197                     "\t" ;; subject
198                     (if (nth 4 e)
199                         (nnrss-format-string (nth 4 e))
200                       "(nobody)")
201                     "\t" ;;from
202                     (or (nth 5 e) "")
203                     "\t" ;; date
204                     (format "<%d@%s.nnrss>" (car e) group)
205                     "\t" ;; id
206                     "\t" ;; refs
207                     "-1" "\t" ;; chars
208                     "-1" "\t" ;; lines
209                     "" "\t" ;; Xref
210                     (if (and (nth 6 e)
211                              (memq nnrss-description-field
212                                    nnmail-extra-headers))
213                         (concat (symbol-name nnrss-description-field)
214                                 ": "
215                                 (nnrss-format-string (nth 6 e))
216                                 "\t")
217                       "")
218                     (if (and (nth 2 e)
219                              (memq nnrss-url-field
220                                    nnmail-extra-headers))
221                         (concat (symbol-name nnrss-url-field)
222                                 ": "
223                                 (nnrss-format-string (nth 2 e))
224                                 "\t")
225                       "")
226                     "\n")))))
227   'nov)
228
229 (deffoo nnrss-request-group (group &optional server dont-check)
230   (nnrss-possibly-change-group group server)
231   (if dont-check
232       t
233     (nnrss-check-group group server)
234     (nnheader-report 'nnrss "Opened group %s" group)
235     (nnheader-insert
236      "211 %d %d %d %s\n" nnrss-group-max nnrss-group-min nnrss-group-max
237      (prin1-to-string group)
238      t)))
239
240 (deffoo nnrss-close-group (group &optional server)
241   t)
242
243 (deffoo nnrss-request-article (article &optional group server buffer)
244   (nnrss-possibly-change-group group server)
245   (let ((e (assq article nnrss-group-data))
246         (nntp-server-buffer (or buffer nntp-server-buffer))
247         post err)
248     (when e
249       (catch 'error
250         (with-current-buffer nntp-server-buffer
251           (erase-buffer)
252           (goto-char (point-min))
253           (if group
254               (insert "Newsgroups: " group "\n"))
255           (if (nth 3 e)
256               (insert "Subject: " (nnrss-format-string (nth 3 e)) "\n"))
257           (if (nth 4 e)
258               (insert "From: " (nnrss-format-string (nth 4 e)) "\n"))
259           (if (nth 5 e)
260               (insert "Date: " (nnrss-format-string (nth 5 e)) "\n"))
261           (insert "Message-ID: " (format "<%d@%s.nnrss>" (car e) group) "\n")
262           (insert "\n")
263           (if (nth 6 e)
264               (let ((point (point)))
265                 (insert (nnrss-string-as-multibyte (nth 6 e)))
266                 (goto-char point)
267                 (while (search-forward "\n" nil t)
268                   (delete-char -1))
269                 (goto-char (point-max))
270                 (insert "\n\n")
271                 (fill-region point (point))))
272           (if (nth 2 e)
273               (insert (nth 2 e) "\n"))
274           (if nnrss-content-function
275               (funcall nnrss-content-function e group article)))))
276     (cond
277      (err
278       (nnheader-report 'nnrss err))
279      ((not e)
280       (nnheader-report 'nnrss "No such id: %d" article))
281      (t
282       (nnheader-report 'nnrss "Article %s retrieved" (car e))
283       ;; We return the article number.
284       (cons nnrss-group (car e))))))
285
286 (deffoo nnrss-request-list (&optional server)
287   (nnrss-possibly-change-group nil server)
288   (nnrss-generate-active)
289   t)
290
291 (deffoo nnrss-open-server (server &optional defs connectionless)
292   (nnrss-read-server-data server)
293   (nnoo-change-server 'nnrss server defs)
294   t)
295
296 (deffoo nnrss-request-expire-articles
297     (articles group &optional server force)
298   (nnrss-possibly-change-group group server)
299   (let (e days not-expirable changed)
300     (dolist (art articles)
301       (if (and (setq e (assq art nnrss-group-data))
302                (nnmail-expired-article-p
303                 group
304                 (if (listp (setq days (nth 1 e))) days
305                   (days-to-time (- days (time-to-days '(0 0)))))
306                 force))
307           (setq nnrss-group-data (delq e nnrss-group-data)
308                 changed t)
309         (push art not-expirable)))
310     (if changed
311         (nnrss-save-group-data group server))
312     not-expirable))
313
314 (deffoo nnrss-request-delete-group (group &optional force server)
315   (nnrss-possibly-change-group group server)
316   (setq nnrss-server-data
317         (delq (assoc group nnrss-server-data) nnrss-server-data))
318   (nnrss-save-server-data server)
319   (let ((file (expand-file-name
320                (nnrss-translate-file-chars
321                 (concat group (and server
322                                    (not (equal server ""))
323                                    "-")
324                         server ".el")) nnrss-directory)))
325     (ignore-errors
326       (delete-file file)))
327   t)
328
329 (deffoo nnrss-request-list-newsgroups (&optional server)
330   (nnrss-possibly-change-group nil server)
331   (save-excursion
332     (set-buffer nntp-server-buffer)
333     (erase-buffer)
334     (dolist (elem nnrss-group-alist)
335       (if (third elem)
336           (insert (car elem) "\t" (third elem) "\n"))))
337   t)
338
339 (nnoo-define-skeleton nnrss)
340
341 ;;; Internal functions
342
343 (defun nnrss-possibly-change-group (&optional group server)
344   (when (and server
345              (not (nnrss-server-opened server)))
346     (nnrss-open-server server))
347   (when (and group (not (equal group nnrss-group)))
348     (nnrss-read-group-data group server)
349     (setq nnrss-group group)))
350
351 (defvar nnrss-extra-categories '(nnrss-snarf-moreover-categories))
352
353 (defun nnrss-generate-active ()
354   (if (y-or-n-p "Fetch extra categories? ")
355       (dolist (func nnrss-extra-categories)
356         (funcall func)))
357   (save-excursion
358     (set-buffer nntp-server-buffer)
359     (erase-buffer)
360     (dolist (elem nnrss-group-alist)
361       (insert (prin1-to-string (car elem)) " 0 1 y\n"))
362     (dolist (elem nnrss-server-data)
363       (unless (assoc (car elem) nnrss-group-alist)
364         (insert (prin1-to-string (car elem)) " 0 1 y\n")))))
365
366 ;;; Data functions
367
368 (defun nnrss-read-server-data (server)
369   (setq nnrss-server-data nil)
370   (let ((file (expand-file-name
371                (nnrss-translate-file-chars
372                 (concat "nnrss" (and server
373                                      (not (equal server ""))
374                                      "-")
375                         server
376                         ".el"))
377                nnrss-directory)))
378     (when (file-exists-p file)
379       (with-temp-buffer
380         (let ((coding-system-for-read 'binary)
381               emacs-lisp-mode-hook)
382           (insert-file-contents file)
383           (emacs-lisp-mode)
384           (goto-char (point-min))
385           (eval-buffer))))))
386
387 (defun nnrss-save-server-data (server)
388   (gnus-make-directory nnrss-directory)
389   (let ((file (expand-file-name
390                (nnrss-translate-file-chars
391                 (concat "nnrss" (and server
392                                      (not (equal server ""))
393                                      "-")
394                         server ".el"))
395                nnrss-directory)))
396     (let ((coding-system-for-write 'binary)
397           print-level print-length)
398       (with-temp-file file
399         (insert "(setq nnrss-server-data '"
400                 (prin1-to-string nnrss-server-data)
401                 ")\n")))))
402
403 (defun nnrss-read-group-data (group server)
404   (setq nnrss-group-data nil)
405   (setq nnrss-group-hashtb (gnus-make-hashtable))
406   (let ((pair (assoc group nnrss-server-data)))
407     (setq nnrss-group-max (or (cadr pair) 0))
408     (setq nnrss-group-min (+ nnrss-group-max 1)))
409   (let ((file (expand-file-name
410                (nnrss-translate-file-chars
411                 (concat group (and server
412                                    (not (equal server ""))
413                                    "-")
414                         server ".el"))
415                nnrss-directory)))
416     (when (file-exists-p file)
417       (with-temp-buffer
418         (let ((coding-system-for-read 'binary)
419               emacs-lisp-mode-hook)
420           (insert-file-contents file)
421           (emacs-lisp-mode)
422           (goto-char (point-min))
423           (eval-buffer)))
424       (dolist (e nnrss-group-data)
425         (gnus-sethash (nth 2 e) e nnrss-group-hashtb)
426         (if (and (car e) (> nnrss-group-min (car e)))
427             (setq nnrss-group-min (car e)))
428         (if (and (car e) (< nnrss-group-max (car e)))
429             (setq nnrss-group-max (car e)))))))
430
431 (defun nnrss-save-group-data (group server)
432   (gnus-make-directory nnrss-directory)
433   (let ((file (expand-file-name
434                (nnrss-translate-file-chars
435                 (concat group (and server
436                                    (not (equal server ""))
437                                    "-")
438                         server ".el"))
439                nnrss-directory)))
440     (let ((coding-system-for-write 'binary)
441           print-level print-length)
442       (with-temp-file file
443         (insert "(setq nnrss-group-data '"
444                 (prin1-to-string nnrss-group-data)
445                 ")\n")))))
446
447 ;;; URL interface
448
449 (defun nnrss-no-cache (url)
450   "")
451
452 (defun nnrss-insert-w3 (url)
453   (mm-with-unibyte-current-buffer
454     (mm-url-insert url)))
455
456 (defun nnrss-decode-entities-unibyte-string (string)
457   (mm-with-unibyte-buffer
458     (insert string)
459     (mm-url-decode-entities-nbsp)
460     (buffer-substring (point-min) (point-max))))
461
462 (defalias 'nnrss-insert 'nnrss-insert-w3)
463
464 (if (featurep 'xemacs)
465     (defalias 'nnrss-string-as-multibyte 'identity)
466   (defalias 'nnrss-string-as-multibyte 'string-as-multibyte))
467
468 ;;; Snarf functions
469
470 (defun nnrss-check-group (group server)
471   (let (file xml subject url extra changed author date)
472     (condition-case err
473         (mm-with-unibyte-buffer
474           (if (and nnrss-use-local
475                    (file-exists-p (setq file (expand-file-name
476                                               (nnrss-translate-file-chars
477                                                (concat group ".xml"))
478                                               nnrss-directory))))
479               (insert-file-contents file)
480             (setq url (or (nth 2 (assoc group nnrss-server-data))
481                           (second (assoc group nnrss-group-alist))))
482             (unless url
483               (setq url
484                     (read-string (format "RSS url of %s: " group "http://")))
485               (let ((pair (assoc group nnrss-server-data)))
486                 (if pair
487                     (setcdr (cdr pair) (list url))
488                   (push (list group nnrss-group-max url) nnrss-server-data)))
489               (setq changed t))
490             (nnrss-insert url))
491           (goto-char (point-min))
492           (while (re-search-forward "\r\n?" nil t)
493             (replace-match "\n"))
494           (goto-char (point-min))
495           (if (re-search-forward "<rdf\\|<rss" nil t)
496               (goto-char (match-beginning 0)))
497           (setq xml (xml-parse-region (point) (point-max))))
498       (error
499        (nnheader-message 1 "Error in group %s: %s" group (cadr err))))
500     (while (and xml (not (assq 'item xml)))
501       (setq xml (cddar xml))
502       (while (not (listp (car xml)))
503         (setq xml (cdr xml))))
504     (dolist (item (nreverse xml))
505       (when (and (listp item)
506                  (eq 'item (car item))
507                  (setq url (nnrss-node-text (assq 'link (cddr item))))
508                  (setq url (nnrss-decode-entities-unibyte-string url))
509                  (not (gnus-gethash url nnrss-group-hashtb)))
510         (setq subject (nnrss-node-text (assq 'title (cddr item))))
511         (setq extra (or (nnrss-node-text (assq 'description (cddr item)))
512                         (nnrss-node-text (assq 'dc:description (cddr item)))))
513         (setq author (nnrss-node-text (assq 'dc:creator (cddr item))))
514         (setq date (or (nnrss-node-text (assq 'dc:date (cddr item)))
515                        (message-make-date)))
516         (push
517          (list
518           (incf nnrss-group-max)
519           (current-time)
520           url
521           (and subject (nnrss-decode-entities-unibyte-string subject))
522           (and author (nnrss-decode-entities-unibyte-string author))
523           date
524           (and extra (nnrss-decode-entities-unibyte-string extra)))
525          nnrss-group-data)
526         (gnus-sethash url (car nnrss-group-data) nnrss-group-hashtb)
527         (setq changed t)))
528     (when changed
529       (nnrss-save-group-data group server)
530       (let ((pair (assoc group nnrss-server-data)))
531         (if pair
532             (setcar (cdr pair) nnrss-group-max)
533           (push (list group nnrss-group-max) nnrss-server-data)))
534       (nnrss-save-server-data server))))
535
536 (defun nnrss-generate-download-script ()
537   "Generate a download script in the current buffer.
538 It is useful when `(setq nnrss-use-local t)'."
539   (interactive)
540   (insert "#!/bin/sh\n")
541   (insert "WGET=wget\n")
542   (insert "RSSDIR='" (expand-file-name nnrss-directory) "'\n")
543   (dolist (elem nnrss-server-data)
544     (let ((url (or (nth 2 elem)
545                    (second (assoc (car elem) nnrss-group-alist)))))
546       (insert "$WGET -q -O \"$RSSDIR\"/'"
547               (nnrss-translate-file-chars (concat (car elem) ".xml"))
548               "' '" url "'\n"))))
549
550 (defun nnrss-translate-file-chars (name)
551   (let ((nnheader-file-name-translation-alist
552          (append nnheader-file-name-translation-alist '((?' . ?_)))))
553     (nnheader-translate-file-chars name)))
554
555 (defvar nnrss-moreover-url
556   "http://w.moreover.com/categories/category_list_rss.html"
557   "The url of moreover.com categories.")
558
559 (defun nnrss-snarf-moreover-categories ()
560   "Snarf RSS links from moreover.com."
561   (interactive)
562   (let (category name url changed)
563     (with-temp-buffer
564       (nnrss-insert nnrss-moreover-url)
565       (goto-char (point-min))
566       (while (re-search-forward
567               "<A NAME=\"\\([^\"]+\\)\">\\|<A HREF=\"\\(http://[^\"]*moreover\\.com[^\"]+page\\?c=\\([^\"&]+\\)&o=rss\\)" nil t)
568         (if (match-string 1)
569             (setq category (match-string 1))
570           (setq url (match-string 2)
571                 name (mm-url-decode-entities-string
572                       (rfc2231-decode-encoded-string
573                        (match-string 3))))
574           (if category
575               (setq name (concat category "." name)))
576           (unless (assoc name nnrss-server-data)
577             (setq changed t)
578             (push (list name 0 url) nnrss-server-data)))))
579     (if changed
580         (nnrss-save-server-data ""))))
581
582 (defun nnrss-format-string (string)
583   (gnus-replace-in-string (nnrss-string-as-multibyte string) " *\n *" " "))
584
585 (defun nnrss-node-text (node)
586   (if (and node (listp node))
587       (mapconcat 'nnrss-node-text (cddr node) "")
588     node))
589
590 (provide 'nnrss)
591
592 ;;; nnrss.el ends here