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