1;;; sb-ffii.el --- shimbun backend for <http://www.ffii.org/news/rss/>
2
3;; Copyright (C) 2004, 2005
4;; Felix E. Klee <felix.klee@inka.de>
5;; Andreas Seltenreich <seltenreich@gmx.de>
6
7;; Authors:
8;; * Felix E. Klee <felix.klee@inka.de>
9;; * Andreas Seltenreich <seltenreich@gmx.de> (author of sb-n24-de.el
10;;   which was used as a base for this module)
11;; Keywords: news
12;; Created: Feb 09, 2005
13
14;; This program is free software; you can redistribute it and/or modify
15;; it under the terms of the GNU General Public License as published by
16;; the Free Software Foundation; either version 2, or (at your option)
17;; any later version.
18
19;; This program is distributed in the hope that it will be useful,
20;; but WITHOUT ANY WARRANTY; without even the implied warranty of
21;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22;; GNU General Public License for more details.
23
24;; You should have received a copy of the GNU General Public License
25;; along with this program; see the file COPYING.  If not, write to
26;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
27;; Boston, MA 02110-1301, USA.
28
29;;; Code:
30
31(require 'shimbun)
32(require 'sb-rss)
33
34(luna-define-class shimbun-ffii (shimbun-rss) ())
35
36(defvar shimbun-ffii-group-alist
37  '(("en.software-patents" . "SwpatcninoEn")
38    ("en.software-patents.ffii" . "SwpatcninoEn-ffii")
39    ("en.information-infrastructure" . "FfiinewsEn")
40    ("en.project" . "FfiiprojNewsEn")
41    ("de.software-patente" . "SwpatcninoDe")
42    ("de.software-patente.ffii" . "SwpatcninoDe-ffii")
43    ("de.informations-infrastruktur" . "FfiinewsDe")
44    ("fr.brevets-logiciels" . "SwpatcninoFr")
45    ("fr.brevets-logiciels.ffii" . "SwpatcninoFr-ffii")
46    ("nl.softwarepatenten" . "SwpatcninoNl")
47    ("nl.softwarepatenten.ffii" . "SwpatcninoNl-ffii")))
48
49(defvar shimbun-ffii-server-name "FFII")
50(defvar shimbun-ffii-from-address "info@ffii.org")
51
52(luna-define-method shimbun-groups ((shimbun shimbun-ffii))
53  (mapcar 'car shimbun-ffii-group-alist))
54
55;; Returns a Message-ID created from the URL url and the date date.
56(luna-define-method shimbun-rss-build-message-id ((shimbun shimbun-ffii)
57						  url date)
58  (let (page host datedesc)
59    ;; Sometimes URLs are broken (e.g. I've seen something like http:http://x/).
60    ;; The following expression tries to deal with cases like this.
61    (unless (string-match "[^:]*:\\/\\/\\([^\/]+\\)\\([^@<>]*\\)" url)
62      (error "Cannot parse URL for message-id base"))
63    (setq host (match-string-no-properties 1 url)
64	  page (match-string-no-properties 2 url))
65    ;; Sometimes dates are broken, therefore the following expression is very
66    ;; fault tolerant.
67    (unless (string-match "\\([^@<>]*\\)" date)
68      (error "Cannot parse date for message-id base"))
69    (setq datedesc (concat (match-string-no-properties 1 date)
70			   (match-string-no-properties 2 date)
71			   (match-string-no-properties 3 date)
72			   (match-string-no-properties 4 date)
73			   (match-string-no-properties 5 date)))
74    (format "<%s%%%s@%s>" datedesc page host)))
75
76(luna-define-method shimbun-index-url ((shimbun shimbun-ffii))
77  (concat "http://www.ffii.org/news/rss/"
78	  (cdr (assoc (shimbun-current-group-internal shimbun)
79		      shimbun-ffii-group-alist))
80	  ".rss"))
81
82;; Provides a dummy date string if date information is lacking.
83(luna-define-method shimbun-rss-process-date :around ((shimbun shimbun-ffii)
84						      date)
85  (if (stringp date)
86      (luna-call-next-method)
87    (let ((time (decode-time)))
88      (shimbun-make-date-string (nth 5 time)
89				(nth 1 time)
90				(nth 3 time)))))
91
92(provide 'sb-ffii)
93
94;;; sb-ffii.el ends here
95