1 ;;; nnweb.el --- retrieving articles via web search engines
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
4 ;; 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
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/>.
26 ;; Note: You need to have `w3' installed for some functions to work.
30 (eval-when-compile (require 'cl))
42 (autoload 'w3-parse-buffer "w3-parse")
46 (defvoo nnweb-directory (nnheader-concat gnus-directory "nnweb/")
47 "Where nnweb will save its files.")
49 (defvoo nnweb-type 'google
50 "What search engine type is being used.
51 Valid types include `google', `dejanews', and `gmane'.")
53 (defvar nnweb-type-definition
55 (id . "http://www.google.com/groups?as_umsgid=%s&hl=en&dmode=source")
56 (result . "http://groups.google.com/group/%s/msg/%s?dmode=source")
57 (article . nnweb-google-wash-article)
58 (reference . identity)
59 (map . nnweb-google-create-mapping)
60 (search . nnweb-google-search)
61 (address . "http://groups.google.com/groups")
62 (base . "http://groups.google.com")
63 (identifier . nnweb-google-identity))
64 (dejanews ;; alias of google
65 (id . "http://www.google.com/groups?as_umsgid=%s&hl=en&dmode=source")
66 (result . "http://groups.google.com/group/%s/msg/%s?dmode=source")
67 (article . nnweb-google-wash-article)
68 (reference . identity)
69 (map . nnweb-google-create-mapping)
70 (search . nnweb-google-search)
71 (address . "http://groups.google.com/groups")
72 (base . "http://groups.google.com")
73 (identifier . nnweb-google-identity))
75 (article . nnweb-gmane-wash-article)
76 (id . "http://gmane.org/view.php?group=%s")
77 (reference . identity)
78 (map . nnweb-gmane-create-mapping)
79 (search . nnweb-gmane-search)
80 (address . "http://search.gmane.org/nov.php")
81 (identifier . nnweb-gmane-identity)))
82 "Type-definition alist.")
84 (defvoo nnweb-search nil
85 "Search string to feed to Google.")
87 (defvoo nnweb-max-hits 999
88 "Maximum number of hits to display.")
90 (defvoo nnweb-ephemeral-p nil
91 "Whether this nnweb server is ephemeral.")
93 ;;; Internal variables
95 (defvoo nnweb-articles nil)
96 (defvoo nnweb-buffer nil)
97 (defvoo nnweb-group-alist nil)
98 (defvoo nnweb-group nil)
99 (defvoo nnweb-hashtb nil)
101 ;;; Interface functions
103 (nnoo-define-basics nnweb)
105 (deffoo nnweb-retrieve-headers (articles &optional group server fetch-old)
106 (nnweb-possibly-change-server group server)
108 (set-buffer nntp-server-buffer)
110 (let (article header)
111 (mm-with-unibyte-current-buffer
112 (while (setq article (pop articles))
113 (when (setq header (cadr (assq article nnweb-articles)))
114 (nnheader-insert-nov header))))
117 (deffoo nnweb-request-scan (&optional group server)
118 (nnweb-possibly-change-server group server)
119 (if nnweb-ephemeral-p
120 (setq nnweb-hashtb (gnus-make-hashtable 4095))
121 (unless nnweb-articles
122 (nnweb-read-overview group)))
123 (funcall (nnweb-definition 'map))
124 (unless nnweb-ephemeral-p
126 (nnweb-write-overview group)))