1 ;;; nnlistserv.el --- retrieving articles via web mailing list archives
3 ;; Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6 ;; Keywords: news, mail
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
27 ;; Note: You need to have `url' and `w3' installed for this
32 (eval-when-compile (require 'cl
))
37 (nnoo-declare nnlistserv
40 (defvoo nnlistserv-directory
(nnheader-concat gnus-directory
"nnlistserv/")
41 "Where nnlistserv will save its files."
44 (defvoo nnlistserv-name
'kk
45 "What search engine type is being used."
48 (defvoo nnlistserv-type-definition
50 (article . nnlistserv-kk-wash-article
)
51 (map . nnlistserv-kk-create-mapping
)
52 (search . nnlistserv-kk-search
)
53 (address .
"http://www.itk.ntnu.no/ansatte/Andresen_Trond/kk-f/%s/")
54 (pages "fra160396" "fra160796" "fra061196" "fra160197"
55 "fra090997" "fra040797" "fra130397" "nye")
57 (identifier . nnlistserv-kk-identity
)))
58 "Type-definition alist."
59 nnweb-type-definition
)
61 (defvoo nnlistserv-search nil
62 "Search string to feed to DejaNews."
65 (defvoo nnlistserv-ephemeral-p nil
66 "Whether this nnlistserv server is ephemeral."
69 ;;; Internal variables
71 ;;; Interface functions
73 (nnoo-define-basics nnlistserv
)
75 (nnoo-import nnlistserv
78 ;;; Internal functions
84 (defun nnlistserv-kk-create-mapping ()
85 "Perform the search and create an number-to-url alist."
87 (set-buffer nnweb-buffer
)
88 (let ((case-fold-search t
)
89 (active (or (cadr (assoc nnweb-group nnweb-group-alist
))
91 (pages (nnweb-definition 'pages
))
92 map url page subject from
)
93 (while (setq page
(pop pages
))
95 (when (funcall (nnweb-definition 'search
) page
)
96 ;; Go through all the article hits on this page.
97 (goto-char (point-min))
98 (nnweb-decode-entities)
99 (goto-char (point-min))
100 (while (re-search-forward "^<li> *<a href=\"\\([^\"]+\\)\"><b>\\([^\\>]+\\)</b></a> *<[^>]+><i>\\([^>]+\\)<" nil t
)
101 (setq url
(match-string 1)
102 subject
(match-string 2)
103 from
(match-string 3))
104 (setq url
(concat (format (nnweb-definition 'address
) page
) url
))
105 (unless (nnweb-get-hashtb url
)
109 (make-full-mail-header
110 (cdr active
) subject from
""
111 (concat "<" (nnweb-identifier url
) "@kk>")
114 (nnweb-set-hashtb (cadar map
) (car map
))
115 (nnheader-message 5 "%s %s %s" (cdr active
) (point) pages
)))))
116 ;; Return the articles in the right order.
118 (sort (nconc nnweb-articles map
) 'car-less-than-car
)))))
120 (defun nnlistserv-kk-wash-article ()
121 (let ((case-fold-search t
)
122 (headers '(sent name email subject id
))
123 sent name email subject id
)
124 (nnweb-decode-entities)
126 (goto-char (point-min))
127 (re-search-forward (format "<!-- %s=\"\\([^\"]+\\)" (car headers
) nil t
))
128 (set (pop headers
) (match-string 1)))
129 (goto-char (point-min))
130 (search-forward "<!-- body" nil t
)
131 (delete-region (point-min) (progn (forward-line 1) (point)))
132 (goto-char (point-max))
133 (search-backward "<!-- body" nil t
)
134 (delete-region (point-max) (progn (beginning-of-line) (point)))
135 (nnweb-remove-markup)
136 (goto-char (point-min))
137 (insert (format "From: %s <%s>\n" name email
)
138 (format "Subject: %s\n" subject
)
139 (format "Message-ID: %s\n" id
)
140 (format "Date: %s\n\n" sent
))))
142 (defun nnlistserv-kk-search (search)
143 (url-insert-file-contents
144 (concat (format (nnweb-definition 'address
) search
)
145 (nnweb-definition 'index
)))
148 (defun nnlistserv-kk-identity (url)
149 "Return an unique identifier based on URL."
152 (provide 'nnlistserv
)
154 ;;; nnlistserv.el ends here