1 ;;; nnlistserv.el --- retrieving articles via web mailing list archives
3 ;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 ;; 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
7 ;; Keywords: news, mail
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation, either version 3 of the License, or
14 ;; (at your option) any later version.
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
28 (eval-when-compile (require 'cl
))
34 (nnoo-declare nnlistserv
37 (defvoo nnlistserv-directory
(nnheader-concat gnus-directory
"nnlistserv/")
38 "Where nnlistserv will save its files."
41 (defvoo nnlistserv-name
'kk
42 "What search engine type is being used."
45 (defvoo nnlistserv-type-definition
47 (article . nnlistserv-kk-wash-article
)
48 (map . nnlistserv-kk-create-mapping
)
49 (search . nnlistserv-kk-search
)
50 (address .
"http://www.itk.ntnu.no/ansatte/Andresen_Trond/kk-f/%s/")
51 (pages "fra160396" "fra160796" "fra061196" "fra160197"
52 "fra090997" "fra040797" "fra130397" "nye")
54 (identifier . nnlistserv-kk-identity
)))
55 "Type-definition alist."
56 nnweb-type-definition
)
58 (defvoo nnlistserv-search nil
59 "Search string to feed to DejaNews."
62 (defvoo nnlistserv-ephemeral-p nil
63 "Whether this nnlistserv server is ephemeral."
66 ;;; Internal variables
68 ;;; Interface functions
70 (nnoo-define-basics nnlistserv
)
72 (nnoo-import nnlistserv
75 ;;; Internal functions
81 (defun nnlistserv-kk-create-mapping ()
82 "Perform the search and create a number-to-url alist."
84 (set-buffer nnweb-buffer
)
85 (let ((case-fold-search t
)
86 (active (or (cadr (assoc nnweb-group nnweb-group-alist
))
88 (pages (nnweb-definition 'pages
))
89 map url page subject from
)
90 (while (setq page
(pop pages
))
92 (when (funcall (nnweb-definition 'search
) page
)
93 ;; Go through all the article hits on this page.
94 (goto-char (point-min))
95 (mm-url-decode-entities)
96 (goto-char (point-min))
97 (while (re-search-forward "^<li> *<a href=\"\\([^\"]+\\)\"><b>\\([^\\>]+\\)</b></a> *<[^>]+><i>\\([^>]+\\)<" nil t
)
98 (setq url
(match-string 1)
99 subject
(match-string 2)
100 from
(match-string 3))
101 (setq url
(concat (format (nnweb-definition 'address
) page
) url
))
102 (unless (nnweb-get-hashtb url
)
106 (make-full-mail-header
107 (cdr active
) subject from
""
108 (concat "<" (nnweb-identifier url
) "@kk>")
111 (nnweb-set-hashtb (cadar map
) (car map
))
112 (nnheader-message 5 "%s %s %s" (cdr active
) (point) pages
)))))
113 ;; Return the articles in the right order.
115 (sort (nconc nnweb-articles map
) 'car-less-than-car
)))))
117 (defun nnlistserv-kk-wash-article ()
118 (let ((case-fold-search t
)
119 (headers '(sent name email subject id
))
120 sent name email subject id
)
121 (mm-url-decode-entities)
123 (goto-char (point-min))
124 (re-search-forward (format "<!-- %s=\"\\([^\"]+\\)" (car headers
)) nil t
)
125 (set (pop headers
) (match-string 1)))
126 (goto-char (point-min))
127 (search-forward "<!-- body" nil t
)
128 (delete-region (point-min) (progn (forward-line 1) (point)))
129 (goto-char (point-max))
130 (search-backward "<!-- body" nil t
)
131 (delete-region (point-max) (progn (beginning-of-line) (point)))
132 (mm-url-remove-markup)
133 (goto-char (point-min))
134 (insert (format "From: %s <%s>\n" name email
)
135 (format "Subject: %s\n" subject
)
136 (format "Message-ID: %s\n" id
)
137 (format "Date: %s\n\n" sent
))))
139 (defun nnlistserv-kk-search (search)
141 (concat (format (nnweb-definition 'address
) search
)
142 (nnweb-definition 'index
)))
145 (defun nnlistserv-kk-identity (url)
146 "Return an unique identifier based on URL."
149 (provide 'nnlistserv
)
151 ;; arch-tag: 7705176f-d332-4a5e-a520-d0d319445617
152 ;;; nnlistserv.el ends here