1;;; sb-the-register.el --- The Register shimbun backend
2
3;; Copyright (C) 2004, 2005, 2006, 2007, 2008 David Hansen
4
5;; Author: David Hansen <david.hansen@physik.fu-berlin.de>
6;; Keywords: news
7
8;; This file is a part of shimbun.
9
10;; This is free software; you can redistribute it and/or modify
11;; it under the terms of the GNU General Public License as published by
12;; the Free Software Foundation; either version 2, or (at your option)
13;; any later version.
14
15;; This is distributed in the hope that it will be useful,
16;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18;; GNU General Public License for more details.
19
20;; You should have received a copy of the GNU General Public License
21;; along with GNU Emacs; see the file COPYING.  If not, write to the
22;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23;; Boston, MA 02110-1301, USA.
24
25;;; Commentary:
26
27;;; Code:
28
29(require 'shimbun)
30(require 'sb-rss)
31
32(luna-define-class shimbun-the-register (shimbun-rss) ())
33
34(defvar shimbun-the-register-url "http://www.theregister.co.uk/")
35(defvar shimbun-the-register-from-address  "invalid@theregister.co.uk")
36(defvar shimbun-the-register-content-start "<h2>")
37(defvar shimbun-the-register-content-end
38  "<p class=\"Furniture\">\\|<p id=\"Copyright\">")
39(defvar shimbun-the-register-x-face-alist
40  '(("default" . "X-Face: 'r-3ZQiX|_[TrM[|LF34{X#MX`MHFuL$_2w4Cs\"ET_jx9/JsL)k\
41xvY~i(,cv8ho2=\\L!Tz# @=+.N^%}G<@JRS<ZeD90JN/,oDx.o:\\-kBeyKN%DzZ)s|Ck69P6WY6^\
42IPf~GT+xfvp:1-BRTK7'f&\"\"mr'CflD?Q2R%IkV>")))
43
44(defvar shimbun-the-register-path-alist
45  '(("news" . "headlines.rss")
46    ("enterprise" . "enterprise/headlines.rss")
47    ("software" . "software/headlines.rss")
48    ("personal" . "personal/headlines.rss")
49    ("internet" . "internet/headlines.rss")
50    ("mobile" . "mobile/headlines.rss")
51    ("security" . "security/headlines.rss")
52    ("management" . "management/headlines.rss")
53    ("channel" . "channel/headlines.rss")
54    ("odds" . "odds/headlines.rss")))
55
56(defvar shimbun-the-register-groups
57  (mapcar 'car shimbun-the-register-path-alist))
58
59(luna-define-method shimbun-index-url ((shimbun shimbun-the-register))
60  (concat shimbun-the-register-url
61	  (cdr (assoc (shimbun-current-group-internal shimbun)
62		      shimbun-the-register-path-alist))))
63
64(luna-define-method shimbun-get-headers :around
65  ((shimbun shimbun-the-register) &optional range)
66  (mapcar
67   (lambda (header)
68     (shimbun-header-set-xref
69      header (concat (shimbun-header-xref header) "print.html"))
70     header)
71   (luna-call-next-method)))
72
73(luna-define-method shimbun-make-contents
74  :before ((shimbun shimbun-the-register) header)
75  (save-excursion
76    ;; remove annoying stuff
77    (dolist (junk '(("(?<span class=\"URL\">" . "</span>)?")
78                    ("<div \\(class\\|id\\)=\"[^\"]*Ad\"" . "</div>")
79                    ("<a href=\"http://ad\\." . "</a>")))
80      (goto-char (point-min))
81      (message "%s" (car junk))
82      (while (re-search-forward (car junk) nil t)
83        (let ((beg (match-beginning 0)))
84          (when (re-search-forward (cdr junk) nil t)
85            (delete-region beg (point))))))))
86
87(provide 'sb-the-register)
88
89;;; sb-the-register.el ends here
90