[Date Prev][Date Next][Thread Prev][][Date Index][Thread Index]

Re: sb-spiegel.el --- spiegel online shimbun backend



And, I have posted an adivce.

-- 
TSUCHIYA Masatoshi
--- Begin Message ---
Hi,

Your backend can be simplified to the attached version by using
inheritance feature provided by luna.el.  For more detail, please
check the docstring of `luna-define-method'.

-- 
TSUCHIYA Masatoshi

;;; sb-spiegel.el --- spiegel online shimbun backend

;; Copyright (C) 2004 David Hansen

;; Author: David Hansen <david.hansen@physik.fu-berlin.de>
;; Version: 0.1
;; URL: http://www.emacswiki.org/cgi-bin/wiki/WThreeMShimbun
;; Keywords: emacs-w3m, gnus, hypermedia

;; This file is not part of GNU Emacs.

;; This is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.

;; This is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING.  If not, write to the
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.

;;; Commentary:
;;
;; Read the fine emacs-w3m manual to find out more about the shimbun module.
;;
;; Install:
;;
;;   Put this file in e.g. ~/.elisp/ and add
;;
;;     (setq shimbun-server-additional-path '("~/.elisp"))
;;
;;   to your ~/.emacs.

;;; Code:

(require 'shimbun)
(require 'sb-rss)

(luna-define-class shimbun-spiegel (shimbun-rss) ())

(defvar shimbun-spiegel-url
  "http://www.spiegel.de/schlagzeilen/rss/0,5291,,00.xml")
(defvar shimbun-spiegel-groups '("news"))
(defvar shimbun-spiegel-from-address  "spiegel_online@spiegel.de")
(defvar shimbun-spiegel-content-start "<p>")
(defvar shimbun-spiegel-content-end
  "\\(<hr size=\"1\" noshade>\\|<div align=right>\\)")

(luna-define-method shimbun-index-url ((shimbun shimbun-spiegel))
  shimbun-spiegel-url)

(luna-define-method shimbun-get-headers :around ((shimbun shimbun-spiegel)
						 &optional range)
  (mapcar
   (lambda (header)
     (let ((url (shimbun-header-xref header)))
       (when (string-match "\\([0-9]+\\),[0-9]+\\.html" url)
	 (shimbun-header-set-xref header
				  (replace-match "druck-\\1" t nil url 1))))
     header)
   (luna-call-next-method)))

(luna-define-method shimbun-rss-build-message-id
  ((shimbun shimbun-spiegel) url date)
  (unless (string-match "[0-9,]+\\.html" url)
    (error "Cannot find message-id base"))
  (concat "<"
          (replace-regexp-in-string "\\(,\\|druck-\\|\\.html\\)"
                                    "" (match-string 0 url))
          "@spiegel.de>"))

(provide 'sb-spiegel)

;;; sb-spiegel.el ends here
--- End Message ---