1 ;;; nnlistserv.el --- retrieving articles via web mailing list archives
2 ;; Copyright (C) 1997,98,99 Free Software Foundation, Inc.
4 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
5 ;; Keywords: news, mail
7 ;; This file is part of GNU Emacs.
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 by
11 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
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.
26 ;; Note: You need to have `url' and `w3' installed for this
31 (eval-when-compile (require 'cl))
35 (nnoo-declare nnlistserv
38 (defvoo nnlistserv-directory (nnheader-concat gnus-directory "nnlistserv/")
39 "Where nnlistserv will save its files."
42 (defvoo nnlistserv-name 'kk
43 "What search engine type is being used."
46 (defvoo nnlistserv-type-definition
48 (article . nnlistserv-kk-wash-article)
49 (map . nnlistserv-kk-create-mapping)
50 (search . nnlistserv-kk-search)
51 (address . "http://www.itk.ntnu.no/ansatte/Andresen_Trond/kk-f/%s/")
52 (pages "fra160396" "fra160796" "fra061196" "fra160197"
53 "fra090997" "fra040797" "fra130397" "nye")
55 (identifier . nnlistserv-kk-identity)))
56 "Type-definition alist."
57 nnweb-type-definition)
59 (defvoo nnlistserv-search nil
60 "Search string to feed to DejaNews."
63 (defvoo nnlistserv-ephemeral-p nil
64 "Whether this nnlistserv server is ephemeral."
67 ;;; Internal variables
69 ;;; Interface functions
71 (nnoo-define-basics nnlistserv)
73 (nnoo-import nnlistserv
76 ;;; Internal functions
82 (defun nnlistserv-kk-create-mapping ()
83 "Perform the search and create an number-to-url alist."
85 (set-buffer nnweb-buffer)
86 (let ((case-fold-search t)
87 (active (or (cadr (assoc nnweb-group nnweb-group-alist))
89 (pages (nnweb-definition 'pages))
90 map url page subject from )
91 (while (setq page (pop pages))
93 (when (funcall (nnweb-definition 'search) page)
94 ;; Go through all the article hits on this page.
95 (goto-char (point-min))
96 (nnweb-decode-entities)
97 (goto-char (point-min))
98 (while (re-search-forward "^<li> *<a href=\"\\([^\"]+\\)\"><b>\\([^\\>]+\\)</b></a> *<[^>]+><i>\\([^>]+\\)<" nil t)
99 (setq url (match-string 1)
100 subject (match-string 2)
101 from (match-string 3))
102 (setq url (concat (format (nnweb-definition 'address) page) url))
103 (unless (nnweb-get-hashtb url)
107 (make-full-mail-header
108 (cdr active) subject from ""
109 (concat "<" (nnweb-identifier url) "@kk>")
112 (nnweb-set-hashtb (cadar map) (car map))
113 (nnheader-message 5 "%s %s %s" (cdr active) (point) pages)
115 ;; Return the articles in the right order.
117 (sort (nconc nnweb-articles map) 'car-less-than-car)))))
119 (defun nnlistserv-kk-wash-article ()
120 (let ((case-fold-search t)
121 (headers '(sent name email subject id))
122 sent name email subject id)
123 (nnweb-decode-entities)
125 (goto-char (point-min))
126 (re-search-forward (format "<!-- %s=\"\\([^\"]+\\)" (car headers) nil t))
127 (set (pop headers) (match-string 1)))
128 (goto-char (point-min))
129 (search-forward "<!-- body" nil t)
130 (delete-region (point-min) (progn (forward-line 1) (point)))
131 (goto-char (point-max))
132 (search-backward "<!-- body" nil t)
133 (delete-region (point-max) (progn (beginning-of-line) (point)))
134 (nnweb-remove-markup)
135 (goto-char (point-min))
136 (insert (format "From: %s <%s>\n" name email)
137 (format "Subject: %s\n" subject)
138 (format "Message-ID: %s\n" id)
139 (format "Date: %s\n\n" sent))))
141 (defun nnlistserv-kk-search (search)
142 (url-insert-file-contents
143 (concat (format (nnweb-definition 'address) search)
144 (nnweb-definition 'index)))
147 (defun nnlistserv-kk-identity (url)
148 "Return an unique identifier based on URL."
151 (provide 'nnlistserv)
153 ;;; nnlistserv.el ends here