24358
|
1 ;;; nnlistserv.el --- retrieving articles via web mailing list archives
|
|
2 ;; Copyright (C) 1997,98 Free Software Foundation, Inc.
|
|
3
|
|
4 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
|
|
5 ;; Keywords: news, mail
|
|
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 by
|
|
11 ;; the Free Software Foundation; either version 2, or (at your option)
|
|
12 ;; any later version.
|
|
13
|
|
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.
|
|
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 ;; Note: You need to have `url' and `w3' installed for this
|
|
27 ;; backend to work.
|
|
28
|
|
29 ;;; Code:
|
|
30
|
|
31 (eval-when-compile (require 'cl))
|
|
32
|
|
33 (require 'nnoo)
|
|
34 (require 'nnweb)
|
|
35
|
|
36 (nnoo-declare nnlistserv
|
|
37 nnweb)
|
|
38
|
|
39 (defvoo nnlistserv-directory (nnheader-concat gnus-directory "nnlistserv/")
|
|
40 "Where nnlistserv will save its files."
|
|
41 nnweb-directory)
|
|
42
|
|
43 (defvoo nnlistserv-name 'kk
|
|
44 "What search engine type is being used."
|
|
45 nnweb-type)
|
|
46
|
|
47 (defvoo nnlistserv-type-definition
|
|
48 '((kk
|
|
49 (article . nnlistserv-kk-wash-article)
|
|
50 (map . nnlistserv-kk-create-mapping)
|
|
51 (search . nnlistserv-kk-search)
|
|
52 (address . "http://www.itk.ntnu.no/ansatte/Andresen_Trond/kk-f/%s/")
|
|
53 (pages "fra160396" "fra160796" "fra061196" "fra160197"
|
|
54 "fra090997" "fra040797" "fra130397" "nye")
|
|
55 (index . "date.html")
|
|
56 (identifier . nnlistserv-kk-identity)))
|
|
57 "Type-definition alist."
|
|
58 nnweb-type-definition)
|
|
59
|
|
60 (defvoo nnlistserv-search nil
|
|
61 "Search string to feed to DejaNews."
|
|
62 nnweb-search)
|
|
63
|
|
64 (defvoo nnlistserv-ephemeral-p nil
|
|
65 "Whether this nnlistserv server is ephemeral."
|
|
66 nnweb-ephemeral-p)
|
|
67
|
|
68 ;;; Internal variables
|
|
69
|
|
70 ;;; Interface functions
|
|
71
|
|
72 (nnoo-define-basics nnlistserv)
|
|
73
|
|
74 (nnoo-import nnlistserv
|
|
75 (nnweb))
|
|
76
|
|
77 ;;; Internal functions
|
|
78
|
|
79 ;;;
|
|
80 ;;; KK functions.
|
|
81 ;;;
|
|
82
|
|
83 (defun nnlistserv-kk-create-mapping ()
|
|
84 "Perform the search and create an number-to-url alist."
|
|
85 (save-excursion
|
|
86 (set-buffer nnweb-buffer)
|
|
87 (let ((case-fold-search t)
|
|
88 (active (or (cadr (assoc nnweb-group nnweb-group-alist))
|
|
89 (cons 1 0)))
|
|
90 (pages (nnweb-definition 'pages))
|
|
91 map url page subject from )
|
|
92 (while (setq page (pop pages))
|
|
93 (erase-buffer)
|
|
94 (when (funcall (nnweb-definition 'search) page)
|
|
95 ;; Go through all the article hits on this page.
|
|
96 (goto-char (point-min))
|
|
97 (nnweb-decode-entities)
|
|
98 (goto-char (point-min))
|
|
99 (while (re-search-forward "^<li> *<a href=\"\\([^\"]+\\)\"><b>\\([^\\>]+\\)</b></a> *<[^>]+><i>\\([^>]+\\)<" nil t)
|
|
100 (setq url (match-string 1)
|
|
101 subject (match-string 2)
|
|
102 from (match-string 3))
|
|
103 (setq url (concat (format (nnweb-definition 'address) page) url))
|
|
104 (unless (nnweb-get-hashtb url)
|
|
105 (push
|
|
106 (list
|
|
107 (incf (cdr active))
|
|
108 (make-full-mail-header
|
|
109 (cdr active) subject from ""
|
|
110 (concat "<" (nnweb-identifier url) "@kk>")
|
|
111 nil 0 0 url))
|
|
112 map)
|
|
113 (nnweb-set-hashtb (cadar map) (car map))
|
|
114 (nnheader-message 5 "%s %s %s" (cdr active) (point) pages)
|
|
115 ))))
|
|
116 ;; Return the articles in the right order.
|
|
117 (setq nnweb-articles
|
|
118 (sort (nconc nnweb-articles map) 'car-less-than-car)))))
|
|
119
|
|
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)
|
|
125 (while headers
|
|
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))))
|
|
141
|
|
142 (defun nnlistserv-kk-search (search)
|
|
143 (url-insert-file-contents
|
|
144 (concat (format (nnweb-definition 'address) search)
|
|
145 (nnweb-definition 'index)))
|
|
146 t)
|
|
147
|
|
148 (defun nnlistserv-kk-identity (url)
|
|
149 "Return an unique identifier based on URL."
|
|
150 url)
|
|
151
|
|
152 (provide 'nnlistserv)
|
|
153
|
|
154 ;;; nnlistserv.el ends here
|