2003-01-02 Matthieu Moy <Matthieu.Moy@imag.fr>
[gnus] / lisp / nnrss.el
index e34ff09..075c637 100644 (file)
@@ -1,5 +1,5 @@
 ;;; nnrss.el --- interfacing with RSS
-;; Copyright (C) 2001  Free Software Foundation, Inc.
+;; Copyright (C) 2001, 2002  Free Software Foundation, Inc.
 
 ;; Author: Shenghuo Zhu <zsh@cs.rochester.edu>
 ;; Keywords: RSS
@@ -27,6 +27,7 @@
 
 (eval-when-compile (require 'cl))
 
+(require 'gnus)
 (require 'nnoo)
 (require 'nnmail)
 (require 'message)
 (require 'gnus-util)
 (require 'time-date)
 (require 'rfc2231)
+(require 'mm-url)
 (eval-when-compile
   (ignore-errors
-    (require 'xml)
-    (require 'w3)
-    (require 'w3-forms)
-    (require 'nnweb)))
-;; Report failure to find w3 at load time if appropriate.
-(eval '(progn
-        (require 'xml)
-        (require 'w3)
-        (require 'w3-forms)
-        (require 'nnweb)))
+    (require 'xml)))
+(eval '(require 'xml))
 
 (nnoo-declare nnrss)
 
@@ -81,7 +75,7 @@
      "http://www.cnn.com/cnn.rss"
      "The world's news leader.")
     ("FreshMeat"
-     "http://freshmeat.net/backend/fm.rdf"
+     "http://freshmeat.net/backend/fm-releases.rdf"
      "The one-stop-shop for all your Linux software needs.")
     ("The.Guardian.newspaper"
      "http://www.guardianunlimited.co.uk/rss/1,,,00.xml"
     ("Kuro5hin"
      "http://www.kuro5hin.org/backend.rdf"
      "Technology and culture, from the trenches.")
-    ("JabberCentral"
-     "http://www.jabbercentral.com/rss.php"
-     "News around the Jabber instant messaging system.")))
+    ("Jabber Software Foundation News"
+     "http://www.jabber.org/news/rss.xml"
+     "News and announcements from the Jabber Software Foundation.")
+    ))
 
 (defvar nnrss-use-local nil)
 
@@ -179,6 +174,12 @@ To use the description in headers, put this name into `nnmail-extra-headers'.")
   "Field name used for URL.
 To use the description in headers, put this name into `nnmail-extra-headers'.")
 
+(defvar nnrss-content-function nil
+  "A function which is called in `nnrss-request-article'.
+The arguments are (ENTRY GROUP ARTICLE).
+ENTRY is the record of the current headline. GROUP is the group name.
+ARTICLE is the article number of the current headline.")
+
 (nnoo-define-basics nnrss)
 
 ;;; Interface functions
@@ -204,8 +205,8 @@ To use the description in headers, put this name into `nnmail-extra-headers'.")
                    (format "<%d@%s.nnrss>" (car e) group)
                    "\t" ;; id
                    "\t" ;; refs
-                   "0" "\t" ;; chars
-                   "0" "\t" ;; lines
+                   "-1" "\t" ;; chars
+                   "-1" "\t" ;; lines
                    "" "\t" ;; Xref
                    (if (and (nth 6 e)
                             (memq nnrss-description-field
@@ -262,10 +263,17 @@ To use the description in headers, put this name into `nnmail-extra-headers'.")
          (insert "\n")
          (if (nth 6 e)
              (let ((point (point)))
-               (insert (nnrss-string-as-multibyte (nth 6 e)) "\n\n")
+               (insert (nnrss-string-as-multibyte (nth 6 e)))
+               (goto-char point)
+               (while (search-forward "\n" nil t)
+                 (delete-char -1))
+               (goto-char (point-max))
+               (insert "\n\n")
                (fill-region point (point))))
          (if (nth 2 e)
-             (insert (nth 2 e) "\n")))))
+             (insert (nth 2 e) "\n"))
+         (if nnrss-content-function
+             (funcall nnrss-content-function e group article)))))
     (cond
      (err
       (nnheader-report 'nnrss err))
@@ -389,6 +397,9 @@ To use the description in headers, put this name into `nnmail-extra-headers'.")
     (let ((coding-system-for-write 'binary)
          print-level print-length)
       (with-temp-file file
+       (insert "(setq nnrss-group-alist '"
+               (prin1-to-string nnrss-group-alist)
+               ")\n")
        (insert "(setq nnrss-server-data '"
                (prin1-to-string nnrss-server-data)
                ")\n")))))
@@ -442,23 +453,14 @@ To use the description in headers, put this name into `nnmail-extra-headers'.")
 (defun nnrss-no-cache (url)
   "")
 
-;; TODO:: disable cache.
-;;
-;; (defun nnrss-insert-w3 (url)
-;;   (require 'url)
-;;   (require 'url-cache)
-;;   (let ((url-cache-creation-function 'nnrss-no-cache))
-;;     (mm-with-unibyte-current-buffer
-;;       (nnweb-insert url))))
-
 (defun nnrss-insert-w3 (url)
   (mm-with-unibyte-current-buffer
-    (nnweb-insert url)))
+    (mm-url-insert url)))
 
 (defun nnrss-decode-entities-unibyte-string (string)
   (mm-with-unibyte-buffer
     (insert string)
-    (nnweb-decode-entities)
+    (mm-url-decode-entities-nbsp)
     (buffer-substring (point-min) (point-max))))
 
 (defalias 'nnrss-insert 'nnrss-insert-w3)
@@ -470,8 +472,7 @@ To use the description in headers, put this name into `nnmail-extra-headers'.")
 ;;; Snarf functions
 
 (defun nnrss-check-group (group server)
-  (let ((w3-html-entities (cons '(nbsp . 32) w3-html-entities))
-       file xml subject url extra changed author date)
+  (let (file xml subject url extra changed author date)
     (condition-case err
        (mm-with-unibyte-buffer
          (if (and nnrss-use-local
@@ -501,8 +502,9 @@ To use the description in headers, put this name into `nnmail-extra-headers'.")
       (error
        (nnheader-message 1 "Error in group %s: %s" group (cadr err))))
     (while (and xml (not (assq 'item xml)))
-      (unless (listp (car (setq xml (cddar xml))))
-       (setq xml nil)))
+      (setq xml (cddar xml))
+      (while (not (listp (car xml)))
+       (setq xml (cdr xml))))
     (dolist (item (nreverse xml))
       (when (and (listp item)
                 (eq 'item (car item))
@@ -570,7 +572,7 @@ It is useful when `(setq nnrss-use-local t)'."
        (if (match-string 1)
            (setq category (match-string 1))
          (setq url (match-string 2)
-               name (nnweb-decode-entities-string
+               name (mm-url-decode-entities-string
                      (rfc2231-decode-encoded-string
                       (match-string 3))))
          (if category
@@ -582,7 +584,7 @@ It is useful when `(setq nnrss-use-local t)'."
        (nnrss-save-server-data ""))))
 
 (defun nnrss-format-string (string)
-  (nnweb-replace-in-string (nnrss-string-as-multibyte string) " *\n *" " "))
+  (gnus-replace-in-string (nnrss-string-as-multibyte string) " *\n *" " "))
 
 (defun nnrss-node-text (node)
   (if (and node (listp node))