--- Begin Message ---
ええと先ほど本名を名乗ったlightcyanです。
一応自分で書いたので送っておきます。
でも段落で改行とか出来てないので駄目な感じです。
一応添削とかしていただけるとありがたいです。
これでどうでしょう。
--
lightcyan
From: lightcyan@xxxxxxxxxxxxxxxxxxx
Subject: [emacs-w3m:08973] Re: sb-sankei.el 使えなくなっているようです
Date: Fri, 01 Dec 2006 20:35:23 +0900 (LMT)
> From: Katsumi Yamaoka <yamaoka@xxxxxxx>
> Subject: [emacs-w3m:08972] Re: sb-sankei.el 使えなくなっているようです
> Date: Fri, 01 Dec 2006 20:17:30 +0900
>
> > >>>>> In [emacs-w3m : No.08971] lightcyan@xxxxxxxxxxxxxxxxxxx wrote:
> >
> > > どうもお世話になっております。lightcyanです。
> >
> > 私は本名を名乗らない方とはお話ししないことにしているのですが、
> > 今回は原則を破ります。
>
> ありがとうございます。遅ればせながら名乗りますと
> 本名は澁谷 博久というのですが、何というか名乗るほどでもないので、
> 気分など悪くされたら申し訳ございません。
>
> > > http://www.sankei.co.jp/ が変更されたようです。
> >
> > CVS 幹の sb-sankei.el は来週中に直します。
>
> お待ちしております。よろしくお願いします(_ _)
> --
> lightcyan
>
>
>
;;; sb-sankei.el --- shimbun backend for www.sankei.co.jp -*- coding: iso-2022-7bit; -*-
;; Author: lightcyan
;; Keywords: news
;;; Copyright:
;; This program 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 program 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 this program; if not, you can either send email to this
;; program's maintainer or write to: The Free Software Foundation,
;; Inc.; 59 Temple Place, Suite 330; Boston, MA 02111-1307, USA.
;;; Commentary:
;; Original code was sb-yomiuri.el(emacs-w3m-1.3.5) written by
;; TSUCHIYA Masatoshi <tsuchiya@xxxxxxxxxx>,
;; Yuuichi Teranishi <teranisi@xxxxxxxxxx>
;; Katsumi Yamaoka <yamaoka@xxxxxxx>
;;; Code:
(require 'shimbun)
(require 'sb-text)
(luna-define-class shimbun-sankei
(shimbun-japanese-newspaper shimbun-text) ())
(defvar shimbun-sankei-top-level-domain "sankei.co.jp"
"Name of the top level domain for the Sankei Web.")
(defvar shimbun-sankei-url
(concat "http://www." shimbun-sankei-top-level-domain "/")
"Name of the parent url.")
(defvar shimbun-sankei-group-table
(let ((default
(list
(concat
"<[\t\n ]*a[\t\n ]+href[\t\n ]*=[\t\n ]*\""
;; 1. url
"\\([^0-9]+/"
"0[0-9][01][0-9][0-3][0-9]/"
;; 2. serial number
"\\([^0-9]+[0-9]+\\)" "\\.htm\\)"
"\"[\t\n ]*>[\t\n ]*"
;; 3. subject
"\\(.+\\)" "[\t\n ]*<[\t\n ]*/a[\t\n ]*>[\t\n ]*"
;; 4. month
"(\\([0-9]+\\)" "[\t\n ]*/[\t\n ]*"
;; 5. day
"\\([0-9]+\\)" "[\t\n ]+"
;; 6. hour:minute
"\\([012][0-9]:[0-5][0-9]\\)"
"[\t\n ]*[))][\t\n ]*.*<[\t\n ]*/li[\t\n ]*>"
)
1 2 3 4 5 6)))
`(("keizai" "経済面" "keizai/keizai.htm" ,@default)
("shakai" "社会面" "shakai/shakai.htm" ,@default)
("seiji" "政治面" "seiji/seiji.htm" ,@default)
("sports" "スポーツ面" "sports/sports.htm" ,@default)
("kokusai" "国際面" "kokusai/kokusai.htm" ,@default)
("editoria" "主張" "menu.htm"
,(concat
"[0-9]\(20[0-9][0-9])年"
;; 1. month
"\\([12]?[0-9]\\)月"
;; 2.day
"\\([1-3]?[0-9]\\)日[^]+"
"<[\t\n ]*a[\t\n ]+href[\t\n ]*=[\t\n ]*\""
;; 3. url
"/news/\\(editoria\\.htm\\)"
"\"[\t\n ]*>[\t\n ]*"
;; 4. subject
"\\(主張\\)" "[\t\n ]*<[\t\n ]*/a[\t\n ]*>[\t\n ]*"
)
3 nil 4 1 2 nil)))
"Alist of group names, their Japanese translations, index pages,
regexps and numbers.
Regexp may have the \"%s\" token which is replaced with a
regexp-quoted group name. Numbers point to the search result in order
of a url, a serial number, a subject, a month, a day, an hour:minute
and an extra keyword.")
(defvar shimbun-sankei-content-start "\\(\n<!--hombun-->\\|\n[ ]*<!--hombun-->\\|\n<!--ad.end-->\\|\n<!--editoria-->\\)\n")
(defvar shimbun-sankei-content-end "\n\\(<!--hbnend-->\n\\|[ ]*<!--hbnend-->[ ]*\n\\|<table border\\|<p>\n*<br>\\|[ ]*</td>\\|</div>\\)")
(defvar shimbun-sankei-x-face-alist nil)
(defvar shimbun-sankei-expiration-days 7)
(luna-define-method initialize-instance :after ((shimbun shimbun-sankei)
&rest init-args)
(shimbun-set-server-name-internal shimbun "産経新聞")
(shimbun-set-from-address-internal shimbun
(concat "webmaster@"
shimbun-sankei-top-level-domain))
;; To share class variables between `shimbun-sankei' and its
;; successor `shimbun-sankei-html'.
(shimbun-set-x-face-alist-internal shimbun shimbun-sankei-x-face-alist)
(shimbun-set-expiration-days-internal shimbun
shimbun-sankei-expiration-days)
shimbun)
(luna-define-method shimbun-groups ((shimbun shimbun-sankei))
(mapcar 'car shimbun-sankei-group-table))
(luna-define-method shimbun-current-group-name ((shimbun shimbun-sankei))
(nth 1 (assoc (shimbun-current-group-internal shimbun)
shimbun-sankei-group-table)))
(luna-define-method shimbun-index-url ((shimbun shimbun-sankei))
(let ((group (shimbun-current-group-internal shimbun)))
(concat shimbun-sankei-url
(nth 2 (assoc group shimbun-sankei-group-table)))))
(defmacro shimbun-sankei-japanese-string-to-number (string)
"Convert a Japanese zenkaku number to just a number."
(let ((alist ''((?0 . 0) (?1 . 1) (?2 . 2) (?3 . 3) (?4 . 4)
(?5 . 5) (?6 . 6) (?7 . 7) (?8 . 8) (?9 . 9))))
(if (= (length "0") 1)
`(let* ((str ,string)
(alist ,alist)
(len (length str))
(idx 0)
(num 0))
(while (< idx len)
(setq num (+ (cdr (assq (aref str idx) alist)) (* num 10))
idx (1+ idx)))
num)
`(let* ((str ,string)
(alist ,alist)
(len (length str))
(idx 0)
(num 0)
char)
(while (< idx len)
(setq char (sref str idx)
num (+ (cdr (assq char alist)) (* num 10))
idx (+ idx (char-bytes char))))
num))))
(defun shimbun-sankei-shorten-brackets-in-string (string)
"Replace Japanes zenkaku brackets with ascii characters in STRING.
It does also shorten too much spaces."
(with-temp-buffer
(insert string)
(let ((alist '(("(" . " (") (")" . ") ") ("[" . " [")
("]" . "] ") ("{" . " {") ("}" . "} ")))
elem)
(while alist
(setq elem (pop alist))
(goto-char (point-min))
(while (search-forward (car elem) nil t)
(replace-match (cdr elem))))
(goto-char (point-min))
(while (re-search-forward "[\t ]+" nil t)
(replace-match " "))
(goto-char (point-min))
(while (re-search-forward "\\([])}]\\) \\([])}]\\)" nil t)
(replace-match "\\1\\2")
(forward-char -1))
(goto-char (point-min))
(while (re-search-forward "\\([[({]\\) \\([[({]\\)" nil t)
(replace-match "\\1\\2")
(forward-char -1))
(goto-char (point-min))
(while (re-search-forward " ?\\([「」]\\) ?" nil t)
(replace-match "\\1"))
(goto-char (point-min))
(while (re-search-forward "^ \\| $" nil t)
(replace-match "")))
(buffer-string)))
(defun shimbun-sankei-get-headers (shimbun)
"Return a list of headers."
(let ((group (shimbun-current-group-internal shimbun))
(from (shimbun-from-address shimbun))
(case-fold-search t)
regexp numbers cyear cmonth cday month year day headers)
(setq regexp (assoc group shimbun-sankei-group-table)
numbers (nthcdr 4 regexp)
regexp (format (nth 3 regexp) (regexp-quote group))
cyear (decode-time)
cday (nth 3 cyear)
cmonth (nth 4 cyear)
cyear (nth 5 cyear))
(while (re-search-forward regexp nil t)
(setq day (cond ((nth 4 numbers)
(string-to-number (match-string (nth 4 numbers))))
((nth 7 numbers)
(shimbun-sankei-japanese-string-to-number
(match-string (nth 7 numbers))))
(t
1))
month (cond ((nth 3 numbers)
(string-to-number (match-string (nth 3 numbers))))
((nth 6 numbers)
(shimbun-sankei-japanese-string-to-number
(match-string (nth 6 numbers))))
(t
1))
year (cond ((and (= 12 month) (= 1 cmonth))
(1- cyear))
((and (= 1 month) (= 12 cmonth))
(1+ cyear))
(t
cyear)))
(push (shimbun-make-header
;; number
0
;; subject
(if (and (nth 6 numbers) (nth 7 numbers))
(shimbun-mime-encode-string
(format "%02d/%02d %s"
month day
(shimbun-sankei-shorten-brackets-in-string
(match-string (nth 2 numbers)))))
(shimbun-mime-encode-string (match-string (nth 2 numbers))))
;; from
from
;; date
(shimbun-make-date-string year month day
(when (nth 5 numbers)
(match-string (nth 5 numbers))))
;; id
(format "<%d%02d%02d.%s%%%s.%s>"
year month day (when (nth 1 numbers)
(match-string (nth 1 numbers))) group
shimbun-sankei-top-level-domain)
;; references, chars, lines
"" 0 0
;; xref
(concat shimbun-sankei-url (concat group "/")
(match-string (nth 0 numbers))))
headers))
headers))
(luna-define-method shimbun-get-headers ((shimbun shimbun-sankei)
&optional range)
(shimbun-sankei-get-headers shimbun))
(defun shimbun-sankei-adjust-date-header (shimbun header)
"Adjust a date header if there is a correct information available."
(let ((case-fold-search t)
(group (shimbun-current-group-internal shimbun))
end)
(when (and (re-search-forward (shimbun-content-start-internal shimbun)
nil t)
(re-search-forward (shimbun-content-end-internal shimbun)
nil t)
(progn
(setq end (match-beginning 0))
(beginning-of-buffer)
(re-search-forward "(\\(20[0-9][0-9]\\))年\\(1?[0-9]\\)月\
\\([123]?[0-9]\\)日"
end t)))
(shimbun-header-set-date
header
(shimbun-make-date-string
(string-to-number (match-string 1))
(string-to-number (match-string 2))
(string-to-number (match-string 3))))))
(goto-char (point-min)))
(luna-define-method shimbun-make-contents :before ((shimbun shimbun-sankei)
header)
(shimbun-sankei-adjust-date-header shimbun header))
(provide 'sb-sankei)
;;; sb-sankei.el ends here
--- End Message ---