;;; nnweb.el --- retrieving articles via web search engines
-;; Copyright (C) 1996,97,98 Free Software Foundation, Inc.
+;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
+;; Free Software Foundation, Inc.
;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
;; Keywords: news
;;; Commentary:
-;; Note: You need to have `url' and `w3' installed for this
-;; backend to work.
+;; Note: You need to have `w3' installed for some functions to work.
;;; Code:
(require 'message)
(require 'gnus-util)
(require 'gnus)
-(require 'w3)
-(require 'url)
(require 'nnmail)
-(ignore-errors
- (require 'w3-forms))
+(require 'mm-util)
+(require 'mm-url)
+(eval-and-compile
+ (ignore-errors
+ (require 'url)))
+(autoload 'w3-parse-buffer "w3-parse")
(nnoo-declare nnweb)
(defvoo nnweb-directory (nnheader-concat gnus-directory "nnweb/")
"Where nnweb will save its files.")
-(defvoo nnweb-type 'dejanews
- "What search engine type is being used.")
-
-(defvoo nnweb-type-definition
- '((dejanews
- (article . nnweb-dejanews-wash-article)
- (map . nnweb-dejanews-create-mapping)
- (search . nnweb-dejanews-search)
- (address . "http://x8.dejanews.com/dnquery.xp")
- (identifier . nnweb-dejanews-identity))
- (dejanewsold
- (article . nnweb-dejanews-wash-article)
- (map . nnweb-dejanews-create-mapping)
- (search . nnweb-dejanewsold-search)
- (address . "http://x8.dejanews.com/dnquery.xp")
- (identifier . nnweb-dejanews-identity))
- (reference
- (article . nnweb-reference-wash-article)
- (map . nnweb-reference-create-mapping)
- (search . nnweb-reference-search)
- (address . "http://www.reference.com/cgi-bin/pn/go")
- (identifier . identity))
- (altavista
- (article . nnweb-altavista-wash-article)
- (map . nnweb-altavista-create-mapping)
- (search . nnweb-altavista-search)
- (address . "http://www.altavista.digital.com/cgi-bin/query")
- (id . "/cgi-bin/news?id@%s")
- (identifier . identity)))
+(defvoo nnweb-type 'google
+ "What search engine type is being used.
+Valid types include `google', `dejanews', and `gmane'.")
+
+(defvar nnweb-type-definition
+ '((google
+ (article . ignore)
+ (id . "http://groups.google.com/groups?selm=%s&output=gplain")
+ (reference . identity)
+ (map . nnweb-google-create-mapping)
+ (search . nnweb-google-search)
+ (address . "http://groups.google.com/groups")
+ (identifier . nnweb-google-identity))
+ (dejanews ;; alias of google
+ (article . ignore)
+ (id . "http://groups.google.com/groups?selm=%s&output=gplain")
+ (reference . identity)
+ (map . nnweb-google-create-mapping)
+ (search . nnweb-google-search)
+ (address . "http://groups.google.com/groups")
+ (identifier . nnweb-google-identity))
+ (gmane
+ (article . nnweb-gmane-wash-article)
+ (id . "http://gmane.org/view.php?group=%s")
+ (reference . identity)
+ (map . nnweb-gmane-create-mapping)
+ (search . nnweb-gmane-search)
+ (address . "http://gmane.org/")
+ (identifier . nnweb-gmane-identity)))
"Type-definition alist.")
(defvoo nnweb-search nil
- "Search string to feed to DejaNews.")
+ "Search string to feed to Google.")
(defvoo nnweb-max-hits 999
"Maximum number of hits to display.")
(set-buffer nntp-server-buffer)
(erase-buffer)
(let (article header)
- (while (setq article (pop articles))
- (when (setq header (cadr (assq article nnweb-articles)))
- (nnheader-insert-nov header)))
+ (mm-with-unibyte-current-buffer
+ (while (setq article (pop articles))
+ (when (setq header (cadr (assq article nnweb-articles)))
+ (nnheader-insert-nov header))))
'nov)))
(deffoo nnweb-request-scan (&optional group server)
(nnweb-possibly-change-server group server)
- (setq nnweb-hashtb (gnus-make-hashtable 4095))
+ (if nnweb-ephemeral-p
+ (setq nnweb-hashtb (gnus-make-hashtable 4095)))
(funcall (nnweb-definition 'map))
(unless nnweb-ephemeral-p
(nnweb-write-active)
(when (and group
(not (equal group nnweb-group))
(not nnweb-ephemeral-p))
+ (setq nnweb-group group
+ nnweb-articles nil)
(let ((info (assoc group nnweb-group-alist)))
- (setq nnweb-group group)
- (setq nnweb-type (nth 2 info))
- (setq nnweb-search (nth 3 info))
- (unless dont-check
- (nnweb-read-overview group))))
+ (when info
+ (setq nnweb-type (nth 2 info))
+ (setq nnweb-search (nth 3 info))
+ (unless dont-check
+ (nnweb-read-overview group)))))
(cond
((not nnweb-articles)
(nnheader-report 'nnweb "No matching articles"))
(let* ((header (cadr (assq article nnweb-articles)))
(url (and header (mail-header-xref header))))
(when (or (and url
- (nnweb-fetch-url url))
+ (mm-with-unibyte-current-buffer
+ (mm-url-insert url)))
(and (stringp article)
(nnweb-definition 'id t)
(let ((fetch (nnweb-definition 'id))
- art)
+ art active)
(when (string-match "^<\\(.*\\)>$" article)
(setq art (match-string 1 article)))
- (and fetch
- art
- (nnweb-fetch-url
- (format fetch article))))))
+ (when (and fetch art)
+ (setq url (format fetch art))
+ (mm-with-unibyte-current-buffer
+ (mm-url-insert url))
+ (if (nnweb-definition 'reference t)
+ (setq article
+ (funcall (nnweb-definition
+ 'reference) article)))))))
(unless nnheader-callback-function
- (funcall (nnweb-definition 'article))
- (nnweb-decode-entities))
+ (funcall (nnweb-definition 'article)))
(nnheader-report 'nnweb "Fetched article %s" article)
- t))))
+ (cons group (and (numberp article) article))))))
(deffoo nnweb-close-server (&optional server)
(when (and (nnweb-server-opened server)
t))
(deffoo nnweb-request-update-info (group info &optional server)
- (nnweb-possibly-change-server group server)
- ;;(setcar (cddr info) nil)
- )
+ (nnweb-possibly-change-server group server))
(deffoo nnweb-asynchronous-p ()
- t)
+ nil)
(deffoo nnweb-request-create-group (group &optional server args)
(nnweb-possibly-change-server nil server)
(deffoo nnweb-request-delete-group (group &optional force server)
(nnweb-possibly-change-server group server)
- (gnus-pull group nnweb-group-alist)
+ (gnus-pull group nnweb-group-alist t)
+ (nnweb-write-active)
(gnus-delete-file (nnweb-overview-file group))
t)
(defun nnweb-read-overview (group)
"Read the overview of GROUP and build the map."
(when (file-exists-p (nnweb-overview-file group))
- (nnheader-temp-write nil
+ (mm-with-unibyte-buffer
(nnheader-insert-file-contents (nnweb-overview-file group))
(goto-char (point-min))
(let (header)
(defun nnweb-write-overview (group)
"Write the overview file for GROUP."
- (nnheader-temp-write (nnweb-overview-file group)
+ (with-temp-file (nnweb-overview-file group)
(let ((articles nnweb-articles))
(while articles
(nnheader-insert-nov (cadr (pop articles)))))))
(defun nnweb-write-active ()
"Save the active file."
- (nnheader-temp-write (nnheader-concat nnweb-directory "active")
+ (gnus-make-directory nnweb-directory)
+ (with-temp-file (nnheader-concat nnweb-directory "active")
(prin1 `(setq nnweb-group-alist ',nnweb-group-alist) (current-buffer))))
(defun nnweb-read-active ()