annotate lisp/gnus/nnweb.el @ 51:69ce12f60f55

Added tag r19-16b91 for changeset ee648375d8d6
author cvs
date Mon, 13 Aug 2007 08:56:44 +0200
parents 8d2a9b52c682
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
1 ;;; nnweb.el --- retrieving articles via web search engines
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
2 ;; Copyright (C) 1996,97 Free Software Foundation, Inc.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
3
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
4 ;; Author: Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
5 ;; Keywords: news
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
6
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
7 ;; This file is part of GNU Emacs.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
8
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
10 ;; it under the terms of the GNU General Public License as published by
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
11 ;; the Free Software Foundation; either version 2, or (at your option)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
12 ;; any later version.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
13
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
14 ;; GNU Emacs is distributed in the hope that it will be useful,
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
17 ;; GNU General Public License for more details.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
18
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
19 ;; You should have received a copy of the GNU General Public License
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
22 ;; Boston, MA 02111-1307, USA.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
23
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
24 ;;; Commentary:
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
25
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
26 ;; Note: You need to have `url' and `w3' installed for this
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
27 ;; backend to work.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
28
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
29 ;;; Code:
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
30
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
31 (require 'nnoo)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
32 (require 'message)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
33 (require 'gnus-util)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
34 (require 'gnus)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
35 (require 'w3)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
36 (require 'url)
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
37 (require 'nnmail)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
38 (ignore-errors
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
39 (require 'w3-forms))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
40
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
41 (nnoo-declare nnweb)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
42
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
43 (defvoo nnweb-directory (nnheader-concat gnus-directory "nnweb/")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
44 "Where nnweb will save its files.")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
45
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
46 (defvoo nnweb-type 'dejanews
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
47 "What search engine type is being used.")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
48
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
49 (defvar nnweb-type-definition
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
50 '((dejanews
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
51 (article . nnweb-dejanews-wash-article)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
52 (map . nnweb-dejanews-create-mapping)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
53 (search . nnweb-dejanews-search)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
54 (address . "http://xp9.dejanews.com/dnquery.xp")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
55 (identifier . nnweb-dejanews-identity))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
56 (reference
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
57 (article . nnweb-reference-wash-article)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
58 (map . nnweb-reference-create-mapping)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
59 (search . nnweb-reference-search)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
60 (address . "http://www.reference.com/cgi-bin/pn/go")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
61 (identifier . identity))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
62 (altavista
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
63 (article . nnweb-altavista-wash-article)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
64 (map . nnweb-altavista-create-mapping)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
65 (search . nnweb-altavista-search)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
66 (address . "http://www.altavista.digital.com/cgi-bin/query")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
67 (id . "/cgi-bin/news?id@%s")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
68 (identifier . identity)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
69 "Type-definition alist.")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
70
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
71 (defvoo nnweb-search nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
72 "Search string to feed to DejaNews.")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
73
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 16
diff changeset
74 (defvoo nnweb-max-hits 100
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
75 "Maximum number of hits to display.")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
76
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
77 (defvoo nnweb-ephemeral-p nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
78 "Whether this nnweb server is ephemeral.")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
79
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
80 ;;; Internal variables
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
81
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
82 (defvoo nnweb-articles nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
83 (defvoo nnweb-buffer nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
84 (defvoo nnweb-group-alist nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
85 (defvoo nnweb-group nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
86 (defvoo nnweb-hashtb nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
87
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
88 ;;; Interface functions
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
89
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
90 (nnoo-define-basics nnweb)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
91
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
92 (deffoo nnweb-retrieve-headers (articles &optional group server fetch-old)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
93 (nnweb-possibly-change-server group server)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
94 (save-excursion
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
95 (set-buffer nntp-server-buffer)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
96 (erase-buffer)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
97 (let (article header)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
98 (while (setq article (pop articles))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
99 (when (setq header (cadr (assq article nnweb-articles)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
100 (nnheader-insert-nov header)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
101 'nov)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
102
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
103 (deffoo nnweb-request-scan (&optional group server)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
104 (nnweb-possibly-change-server group server)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
105 (funcall (nnweb-definition 'map))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
106 (unless nnweb-ephemeral-p
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
107 (nnweb-write-active)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
108 (nnweb-write-overview group)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
109
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
110 (deffoo nnweb-request-group (group &optional server dont-check)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
111 (nnweb-possibly-change-server nil server)
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
112 (when (and group
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
113 (not (equal group nnweb-group))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
114 (not nnweb-ephemeral-p))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
115 (let ((info (assoc group nnweb-group-alist)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
116 (setq nnweb-group group)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
117 (setq nnweb-type (nth 2 info))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
118 (setq nnweb-search (nth 3 info))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
119 (unless dont-check
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
120 (nnweb-read-overview group))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
121 (cond
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
122 ((not nnweb-articles)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
123 (nnheader-report 'nnweb "No matching articles"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
124 (t
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
125 (let ((active (if nnweb-ephemeral-p
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
126 (cons (caar nnweb-articles)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
127 (caar (last nnweb-articles)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
128 (cadr (assoc group nnweb-group-alist)))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
129 (nnheader-report 'nnweb "Opened group %s" group)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
130 (nnheader-insert
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
131 "211 %d %d %d %s\n" (length nnweb-articles)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
132 (car active) (cdr active) group)))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
133
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
134 (deffoo nnweb-close-group (group &optional server)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
135 (nnweb-possibly-change-server group server)
44
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 42
diff changeset
136 (when (gnus-buffer-live-p nnweb-buffer)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
137 (save-excursion
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
138 (set-buffer nnweb-buffer)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
139 (set-buffer-modified-p nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
140 (kill-buffer nnweb-buffer)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
141 t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
142
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
143 (deffoo nnweb-request-article (article &optional group server buffer)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
144 (nnweb-possibly-change-server group server)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
145 (save-excursion
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
146 (set-buffer (or buffer nntp-server-buffer))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
147 (let* ((header (cadr (assq article nnweb-articles)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
148 (url (and header (mail-header-xref header))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
149 (when (or (and url
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
150 (nnweb-fetch-url url))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
151 (and (stringp article)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
152 (nnweb-definition 'id t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
153 (let ((fetch (nnweb-definition 'id))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
154 art)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
155 (when (string-match "^<\\(.*\\)>$" article)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
156 (setq art (match-string 1 article)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
157 (and fetch
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
158 art
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
159 (nnweb-fetch-url
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
160 (format fetch article))))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
161 (unless nnheader-callback-function
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
162 (funcall (nnweb-definition 'article))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
163 (nnweb-decode-entities))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
164 (nnheader-report 'nnweb "Fetched article %s" article)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
165 t))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
166
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
167 (deffoo nnweb-close-server (&optional server)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
168 (when (and (nnweb-server-opened server)
44
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 42
diff changeset
169 (gnus-buffer-live-p nnweb-buffer))
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
170 (save-excursion
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
171 (set-buffer nnweb-buffer)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
172 (set-buffer-modified-p nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
173 (kill-buffer nnweb-buffer)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
174 (nnoo-close-server 'nnweb server))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
175
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
176 (deffoo nnweb-request-list (&optional server)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
177 (nnweb-possibly-change-server nil server)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
178 (save-excursion
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
179 (set-buffer nntp-server-buffer)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
180 (nnmail-generate-active nnweb-group-alist)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
181 t))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
182
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
183 (deffoo nnweb-request-update-info (group info &optional server)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
184 (nnweb-possibly-change-server group server)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
185 ;;(setcar (cddr info) nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
186 )
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
187
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
188 (deffoo nnweb-asynchronous-p ()
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
189 t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
190
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
191 (deffoo nnweb-request-create-group (group &optional server args)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
192 (nnweb-possibly-change-server nil server)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
193 (nnweb-request-delete-group group)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
194 (push `(,group ,(cons 1 0) ,@args) nnweb-group-alist)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
195 (nnweb-write-active)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
196 t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
197
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
198 (deffoo nnweb-request-delete-group (group &optional force server)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
199 (nnweb-possibly-change-server group server)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
200 (gnus-delete-assoc group nnweb-group-alist)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
201 (gnus-delete-file (nnweb-overview-file group))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
202 t)
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
203
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
204 (nnoo-define-skeleton nnweb)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
205
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
206 ;;; Internal functions
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
207
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
208 (defun nnweb-read-overview (group)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
209 "Read the overview of GROUP and build the map."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
210 (when (file-exists-p (nnweb-overview-file group))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
211 (nnheader-temp-write nil
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
212 (nnheader-insert-file-contents (nnweb-overview-file group))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
213 (goto-char (point-min))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
214 (setq nnweb-hashtb (gnus-make-hashtable
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
215 (count-lines (point-min) (point-max))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
216 (let (header)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
217 (while (not (eobp))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
218 (setq header (nnheader-parse-nov))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
219 (forward-line 1)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
220 (push (list (mail-header-number header)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
221 header (mail-header-xref header))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
222 nnweb-articles)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
223 (nnweb-set-hashtb header (car nnweb-articles)))))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
224
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
225 (defun nnweb-write-overview (group)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
226 "Write the overview file for GROUP."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
227 (nnheader-temp-write (nnweb-overview-file group)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
228 (let ((articles nnweb-articles))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
229 (while articles
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
230 (nnheader-insert-nov (cadr (pop articles)))))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
231
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
232 (defun nnweb-set-hashtb (header data)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
233 (gnus-sethash (nnweb-identifier (mail-header-xref header))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
234 data nnweb-hashtb))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
235
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
236 (defun nnweb-get-hashtb (url)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
237 (gnus-gethash (nnweb-identifier url) nnweb-hashtb))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
238
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
239 (defun nnweb-identifier (ident)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
240 (funcall (nnweb-definition 'identifier) ident))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
241
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
242 (defun nnweb-overview-file (group)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
243 "Return the name of the overview file of GROUP."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
244 (nnheader-concat nnweb-directory group ".overview"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
245
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
246 (defun nnweb-write-active ()
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
247 "Save the active file."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
248 (nnheader-temp-write (nnheader-concat nnweb-directory "active")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
249 (prin1 `(setq nnweb-group-alist ',nnweb-group-alist) (current-buffer))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
250
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
251 (defun nnweb-read-active ()
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
252 "Read the active file."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
253 (load (nnheader-concat nnweb-directory "active") t t t))
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
254
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
255 (defun nnweb-definition (type &optional noerror)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
256 "Return the definition of TYPE."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
257 (let ((def (cdr (assq type (assq nnweb-type nnweb-type-definition)))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
258 (when (and (not def)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
259 (not noerror))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
260 (error "Undefined definition %s" type))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
261 def))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
262
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
263 (defun nnweb-possibly-change-server (&optional group server)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
264 (nnweb-init server)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
265 (when server
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
266 (unless (nnweb-server-opened server)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
267 (nnweb-open-server server)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
268 (unless nnweb-group-alist
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
269 (nnweb-read-active))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
270 (when group
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
271 (when (and (not nnweb-ephemeral-p)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
272 (not (equal group nnweb-group)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
273 (nnweb-request-group group nil t))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
274
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
275 (defun nnweb-init (server)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
276 "Initialize buffers and such."
44
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 42
diff changeset
277 (unless (gnus-buffer-live-p nnweb-buffer)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
278 (setq nnweb-buffer
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
279 (save-excursion
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
280 (nnheader-set-temp-buffer
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
281 (format " *nnweb %s %s %s*" nnweb-type nnweb-search server))))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
282
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
283 (defun nnweb-fetch-url (url)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
284 (save-excursion
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
285 (if (not nnheader-callback-function)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
286 (let ((buf (current-buffer)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
287 (save-excursion
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
288 (set-buffer nnweb-buffer)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
289 (erase-buffer)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
290 (prog1
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
291 (url-insert-file-contents url)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
292 (copy-to-buffer buf (point-min) (point-max)))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
293 (nnweb-url-retrieve-asynch
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
294 url 'nnweb-callback (current-buffer) nnheader-callback-function)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
295 t)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
296
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
297 (defun nnweb-callback (buffer callback)
44
8d2a9b52c682 Import from CVS: tag r19-15prefinal
cvs
parents: 42
diff changeset
298 (when (gnus-buffer-live-p url-working-buffer)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
299 (save-excursion
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
300 (set-buffer url-working-buffer)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
301 (funcall (nnweb-definition 'article))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
302 (nnweb-decode-entities)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
303 (set-buffer buffer)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
304 (goto-char (point-max))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
305 (insert-buffer-substring url-working-buffer))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
306 (funcall callback t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
307 (gnus-kill-buffer url-working-buffer)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
308
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
309 (defun nnweb-url-retrieve-asynch (url callback &rest data)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
310 (let ((url-request-method "GET")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
311 (old-asynch url-be-asynchronous)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
312 (url-request-data nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
313 (url-request-extra-headers nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
314 (url-working-buffer (generate-new-buffer-name " *nnweb*")))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
315 (setq-default url-be-asynchronous t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
316 (save-excursion
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
317 (set-buffer (get-buffer-create url-working-buffer))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
318 (setq url-current-callback-data data
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
319 url-be-asynchronous t
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
320 url-current-callback-func callback)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
321 (url-retrieve url))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
322 (setq-default url-be-asynchronous old-asynch)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
323
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
324 (defun nnweb-encode-www-form-urlencoded (pairs)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
325 "Return PAIRS encoded for forms."
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
326 (mapconcat
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
327 (function
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
328 (lambda (data)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
329 (concat (w3-form-encode-xwfu (car data)) "="
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
330 (w3-form-encode-xwfu (cdr data)))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
331 pairs "&"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
332
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
333 (defun nnweb-fetch-form (url pairs)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
334 (let ((url-request-data (nnweb-encode-www-form-urlencoded pairs))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
335 (url-request-method "POST")
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
336 (url-request-extra-headers
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
337 '(("Content-type" . "application/x-www-form-urlencoded"))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
338 (url-insert-file-contents url)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
339 (setq buffer-file-name nil))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
340 t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
341
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
342 (defun nnweb-decode-entities ()
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
343 (goto-char (point-min))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
344 (while (re-search-forward "&\\([a-z]+\\);" nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
345 (replace-match (char-to-string (or (cdr (assq (intern (match-string 1))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
346 w3-html-entities ))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
347 ?#))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
348 t t)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
349
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
350 (defun nnweb-remove-markup ()
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
351 (goto-char (point-min))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
352 (while (search-forward "<!--" nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
353 (delete-region (match-beginning 0)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
354 (or (search-forward "-->" nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
355 (point-max))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
356 (goto-char (point-min))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
357 (while (re-search-forward "<[^>]+>" nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
358 (replace-match "" t t)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
359
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
360 ;;;
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
361 ;;; DejaNews functions.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
362 ;;;
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
363
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
364 (defun nnweb-dejanews-create-mapping ()
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
365 "Perform the search and create an number-to-url alist."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
366 (save-excursion
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
367 (set-buffer nnweb-buffer)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
368 (erase-buffer)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
369 (when (funcall (nnweb-definition 'search) nnweb-search)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
370 (let ((i 0)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
371 (more t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
372 (case-fold-search t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
373 (active (or (cadr (assoc nnweb-group nnweb-group-alist))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
374 (cons 1 0)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
375 Subject Score Date Newsgroup Author
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
376 map url)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
377 (while more
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
378 ;; Go through all the article hits on this page.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
379 (goto-char (point-min))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
380 (nnweb-decode-entities)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
381 (goto-char (point-min))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
382 (while (re-search-forward "^ +[0-9]+\\." nil t)
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
383 (narrow-to-region
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
384 (point)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
385 (cond ((re-search-forward "^ +[0-9]+\\." nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
386 (match-beginning 0))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
387 ((search-forward "\n\n" nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
388 (point))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
389 (t
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
390 (point-max))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
391 (goto-char (point-min))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
392 (when (looking-at ".*HREF=\"\\([^\"]+\\)\"")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
393 (setq url (match-string 1)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
394 (nnweb-remove-markup)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
395 (goto-char (point-min))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
396 (while (search-forward "\t" nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
397 (replace-match " "))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
398 (goto-char (point-min))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
399 (while (re-search-forward "^ +\\([^:]+\\): +\\(.*\\)$" nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
400 (set (intern (match-string 1)) (match-string 2)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
401 (widen)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
402 (when (string-match "#[0-9]+/[0-9]+ *$" Subject)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
403 (setq Subject (substring Subject 0 (match-beginning 0))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
404 (incf i)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
405 (unless (nnweb-get-hashtb url)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
406 (push
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
407 (list
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
408 (incf (cdr active))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
409 (make-full-mail-header
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
410 (cdr active) (concat "(" Newsgroup ") " Subject) Author Date
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
411 (concat "<" (nnweb-identifier url) "@dejanews>")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
412 nil 0 (string-to-int Score) url))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
413 map)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
414 (nnweb-set-hashtb (cadar map) (car map))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
415 ;; See whether there is a "Get next 20 hits" button here.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
416 (if (or (not (re-search-forward
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
417 "HREF=\"\\([^\"]+\\)\">Get next" nil t))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
418 (>= i nnweb-max-hits))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
419 (setq more nil)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
420 ;; Yup -- fetch it.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
421 (setq more (match-string 1))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
422 (erase-buffer)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
423 (url-insert-file-contents more)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
424 ;; Return the articles in the right order.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
425 (setq nnweb-articles
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
426 (sort (nconc nnweb-articles map)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
427 (lambda (s1 s2) (< (car s1) (car s2)))))))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
428
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
429 (defun nnweb-dejanews-wash-article ()
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
430 (let ((case-fold-search t))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
431 (goto-char (point-min))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
432 (re-search-forward "<PRE>" nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
433 (delete-region (point-min) (point))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
434 (re-search-forward "</PRE>" nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
435 (delete-region (point) (point-max))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
436 (nnweb-remove-markup)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
437 (goto-char (point-min))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
438 (while (and (looking-at " *$")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
439 (not (eobp)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
440 (gnus-delete-line))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
441 (while (looking-at "\\(^[^ ]+:\\) *")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
442 (replace-match "\\1 " t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
443 (forward-line 1))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
444 (when (re-search-forward "\n\n+" nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
445 (replace-match "\n" t t))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
446
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
447 (defun nnweb-dejanews-search (search)
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
448 (nnweb-fetch-form
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
449 (nnweb-definition 'address)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
450 `(("query" . ,search)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
451 ("defaultOp" . "AND")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
452 ("svcclass" . "dncurrent")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
453 ("maxhits" . "100")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
454 ("format" . "verbose")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
455 ("threaded" . "0")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
456 ("showsort" . "score")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
457 ("agesign" . "1")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
458 ("ageweight" . "1")))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
459 t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
460
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
461 (defun nnweb-dejanews-identity (url)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
462 "Return an unique identifier based on URL."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
463 (if (string-match "recnum=\\([0-9]+\\)" url)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
464 (match-string 1 url)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
465 url))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
466
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
467 ;;;
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
468 ;;; InReference
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
469 ;;;
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
470
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
471 (defun nnweb-reference-create-mapping ()
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
472 "Perform the search and create an number-to-url alist."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
473 (save-excursion
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
474 (set-buffer nnweb-buffer)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
475 (erase-buffer)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
476 (when (funcall (nnweb-definition 'search) nnweb-search)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
477 (let ((i 0)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
478 (more t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
479 (case-fold-search t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
480 (active (or (cadr (assoc nnweb-group nnweb-group-alist))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
481 (cons 1 0)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
482 Subject Score Date Newsgroups From Message-ID
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
483 map url)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
484 (while more
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
485 ;; Go through all the article hits on this page.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
486 (goto-char (point-min))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
487 (search-forward "</pre><hr>" nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
488 (delete-region (point-min) (point))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
489 ;(nnweb-decode-entities)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
490 (goto-char (point-min))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
491 (while (re-search-forward "^ +[0-9]+\\." nil t)
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
492 (narrow-to-region
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
493 (point)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
494 (if (re-search-forward "^$" nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
495 (match-beginning 0)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
496 (point-max)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
497 (goto-char (point-min))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
498 (when (looking-at ".*href=\"\\([^\"]+\\)\"")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
499 (setq url (match-string 1)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
500 (nnweb-remove-markup)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
501 (goto-char (point-min))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
502 (while (search-forward "\t" nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
503 (replace-match " "))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
504 (goto-char (point-min))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
505 (while (re-search-forward "^\\([^:]+\\): \\(.*\\)$" nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
506 (set (intern (match-string 1)) (match-string 2)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
507 (widen)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
508 (search-forward "</pre>" nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
509 (incf i)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
510 (unless (nnweb-get-hashtb url)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
511 (push
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
512 (list
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
513 (incf (cdr active))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
514 (make-full-mail-header
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
515 (cdr active) (concat "(" Newsgroups ") " Subject) From Date
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
516 Message-ID
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
517 nil 0 (string-to-int Score) url))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
518 map)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
519 (nnweb-set-hashtb (cadar map) (car map))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
520 (setq more nil))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
521 ;; Return the articles in the right order.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
522 (setq nnweb-articles
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
523 (sort (nconc nnweb-articles map)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
524 (lambda (s1 s2) (< (car s1) (car s2)))))))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
525
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
526 (defun nnweb-reference-wash-article ()
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
527 (let ((case-fold-search t))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
528 (goto-char (point-min))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
529 (re-search-forward "^</center><hr>" nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
530 (delete-region (point-min) (point))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
531 (search-forward "<pre>" nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
532 (forward-line -1)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
533 (let ((body (point-marker)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
534 (search-forward "</pre>" nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
535 (delete-region (point) (point-max))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
536 (nnweb-remove-markup)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
537 (goto-char (point-min))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
538 (while (looking-at " *$")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
539 (gnus-delete-line))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
540 (narrow-to-region (point-min) body)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
541 (while (and (re-search-forward "^$" nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
542 (not (eobp)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
543 (gnus-delete-line))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
544 (goto-char (point-min))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
545 (while (looking-at "\\(^[^ ]+:\\) *")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
546 (replace-match "\\1 " t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
547 (forward-line 1))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
548 (goto-char (point-min))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
549 (when (re-search-forward "^References:" nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
550 (narrow-to-region
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
551 (point) (if (re-search-forward "^$\\|^[^:]+:" nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
552 (match-beginning 0)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
553 (point-max)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
554 (goto-char (point-min))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
555 (while (not (eobp))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
556 (unless (looking-at "References")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
557 (insert "\t")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
558 (forward-line 1)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
559 (goto-char (point-min))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
560 (while (search-forward "," nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
561 (replace-match " " t t)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
562 (widen)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
563 (set-marker body nil))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
564
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
565 (defun nnweb-reference-search (search)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
566 (prog1
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
567 (url-insert-file-contents
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
568 (concat
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
569 (nnweb-definition 'address)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
570 "?"
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
571 (nnweb-encode-www-form-urlencoded
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
572 `(("search" . "advanced")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
573 ("querytext" . ,search)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
574 ("subj" . "")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
575 ("name" . "")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
576 ("login" . "")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
577 ("host" . "")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
578 ("organization" . "")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
579 ("groups" . "")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
580 ("keywords" . "")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
581 ("choice" . "Search")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
582 ("startmonth" . "Jul")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
583 ("startday" . "25")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
584 ("startyear" . "1996")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
585 ("endmonth" . "Aug")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
586 ("endday" . "24")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
587 ("endyear" . "1996")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
588 ("mode" . "Quick")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
589 ("verbosity" . "Verbose")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
590 ("ranking" . "Relevance")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
591 ("first" . "1")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
592 ("last" . "25")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
593 ("score" . "50")))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
594 (setq buffer-file-name nil))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
595 t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
596
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
597 ;;;
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
598 ;;; Alta Vista
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
599 ;;;
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
600
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
601 (defun nnweb-altavista-create-mapping ()
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
602 "Perform the search and create an number-to-url alist."
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
603 (save-excursion
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
604 (set-buffer nnweb-buffer)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
605 (erase-buffer)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
606 (let ((part 0))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
607 (when (funcall (nnweb-definition 'search) nnweb-search part)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
608 (let ((i 0)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
609 (more t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
610 (case-fold-search t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
611 (active (or (cadr (assoc nnweb-group nnweb-group-alist))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
612 (cons 1 0)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
613 subject date from id group
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
614 map url)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
615 (while more
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
616 ;; Go through all the article hits on this page.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
617 (goto-char (point-min))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
618 (search-forward "<dt>" nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
619 (delete-region (point-min) (match-beginning 0))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
620 (goto-char (point-min))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
621 (while (search-forward "<dt>" nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
622 (replace-match "\n<blubb>"))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
623 (nnweb-decode-entities)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
624 (goto-char (point-min))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
625 (while (re-search-forward "<blubb>.*href=\"\\([^\"]+\\)\"><strong>\\([^>]*\\)</strong></a><dd>\\([^-]+\\)- <b>\\([^<]+\\)<.*href=\"news:\\([^\"]+\\)\">.*\">\\(.+\\)</a><P>"
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
626 nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
627 (setq url (match-string 1)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
628 subject (match-string 2)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
629 date (match-string 3)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
630 group (match-string 4)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
631 id (concat "<" (match-string 5) ">")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
632 from (match-string 6))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
633 (incf i)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
634 (unless (nnweb-get-hashtb url)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
635 (push
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
636 (list
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
637 (incf (cdr active))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
638 (make-full-mail-header
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
639 (cdr active) (concat "(" group ") " subject) from date
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
640 id nil 0 0 url))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
641 map)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
642 (nnweb-set-hashtb (cadar map) (car map))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
643 ;; See if we want more.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
644 (when (or (not nnweb-articles)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
645 (>= i nnweb-max-hits)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
646 (not (funcall (nnweb-definition 'search)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
647 nnweb-search (incf part))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
648 (setq more nil)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
649 ;; Return the articles in the right order.
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
650 (setq nnweb-articles
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
651 (sort (nconc nnweb-articles map)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
652 (lambda (s1 s2) (< (car s1) (car s2))))))))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
653
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
654 (defun nnweb-altavista-wash-article ()
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
655 (goto-char (point-min))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
656 (let ((case-fold-search t))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
657 (when (re-search-forward "^<strong>" nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
658 (delete-region (point-min) (match-beginning 0)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
659 (goto-char (point-min))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
660 (while (looking-at "<strong>\\([^ ]+\\) +</strong> +\\(.*\\)$")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
661 (replace-match "\\1: \\2" t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
662 (forward-line 1))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
663 (when (re-search-backward "^References:" nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
664 (narrow-to-region (point) (progn (forward-line 1) (point)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
665 (goto-char (point-min))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
666 (while (re-search-forward "<A.*\\?id@\\([^\"]+\\)\">[0-9]+</A>" nil t)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
667 (replace-match "&lt;\\1&gt; " t)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
668 (widen)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
669 (nnweb-remove-markup)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
670
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
671 (defun nnweb-altavista-search (search &optional part)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
672 (prog1
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
673 (url-insert-file-contents
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
674 (concat
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
675 (nnweb-definition 'address)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
676 "?"
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
677 (nnweb-encode-www-form-urlencoded
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
678 `(("pg" . "aq")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
679 ("what" . "news")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
680 ,@(when part `(("stq" . ,(int-to-string (* part 30)))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
681 ("fmt" . "d")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
682 ("q" . ,search)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
683 ("r" . "")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
684 ("d0" . "")
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
685 ("d1" . "")))))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
686 (setq buffer-file-name nil)))
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
687
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
688 (provide 'nnweb)
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
689
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents:
diff changeset
690 ;;; nnweb.el ends here