1;;; sb-japantimes.el --- shimbun backend for www.japantimes.co.jp 2 3;; Author: Hidetaka Iwai <tyuyu@mb6.seikyou.ne.jp>, 4;; KASUGA Toru <gen@qb3.so-net.ne.jp> 5 6;; Keywords: news 7 8;;; Copyright: 9 10;; This program 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 program 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 this program; see the file COPYING. If not, write to 22;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 23;; Boston, MA 02110-1301, USA. 24 25;;; Commentary: 26 27;; Original code was nnshimbun.el written by 28;; TSUCHIYA Masatoshi <tsuchiya@namazu.org>. 29 30;;; Code: 31 32(require 'shimbun) 33 34(luna-define-class shimbun-japantimes (shimbun) ()) 35 36(defvar shimbun-japantimes-url 37 "http://www.japantimes.co.jp/") 38(defvar shimbun-japantimes-groups 39 '("general" "business")) 40(defvar shimbun-japantimes-from-address 41 "webmaster@japantimes.co.jp") 42(defvar shimbun-japantimes-content-start 43 "<div id=\"deck\">\\|<div id=\"mainbody\">") 44(defvar shimbun-japantimes-content-end 45 "^</div>") 46 47(defvar shimbun-japantimes-group-table 48 '(("general" "news.htm" "nn") 49 ("business" "news.htm" "nb"))) 50(defvar shimbun-japantimes-expiration-days 7) 51 52(luna-define-method shimbun-index-url ((shimbun shimbun-japantimes)) 53 (concat (shimbun-url-internal shimbun) 54 (nth 1 (assoc (shimbun-current-group-internal shimbun) 55 shimbun-japantimes-group-table)))) 56 57(luna-define-method shimbun-get-headers ((shimbun shimbun-japantimes) 58 &optional range) 59 (let ((regexp 60 (format 61 (eval-when-compile 62 (let ((s0 "[\t\n ]*") 63 (s1 "[\t\n ]+")) 64 (concat "<a href=\"" 65 ;; 1. url 66 "\\(http://search.japantimes.co.jp/cgi-bin/" 67 ;; 2. 68 "\\(%s\\)" 69 ;; 3. year 70 "\\(20[0-9][0-9]\\)" 71 s0 72 ;; 4. month 73 "\\([0-1][0-9]\\)" 74 s0 75 ;; 5. day 76 "\\([0-3][0-9]\\)" 77 s0 78 ;; 6. tag 79 "\\([a-z][0-9]\\)" 80 s0 "\\.html\\)\">" 81 ;; 7. subject 82 s0 "\\([^[<>]+\\)" 83 s0 "</a>"))) 84 (nth 2 (assoc (shimbun-current-group-internal shimbun) 85 shimbun-japantimes-group-table)))) 86 (case-fold-search t) 87 url serial year month day tag subject id date headers) 88 (goto-char (point-min)) 89 (while (re-search-forward regexp nil t) 90 (setq url (match-string 1) 91 serial (match-string 2) 92 year (match-string 3) 93 month (match-string 4) 94 day (match-string 5) 95 tag (match-string 6) 96 subject (match-string 7) 97 id (format "<%s%s%s%s%s%%%s.japantimes.co.jp>" 98 serial 99 year 100 month 101 day 102 tag 103 (shimbun-current-group-internal shimbun)) 104 date (shimbun-make-date-string 105 (string-to-number year) 106 (string-to-number month) 107 (string-to-number day))) 108 (push (shimbun-make-header 109 0 110 (shimbun-mime-encode-string subject) 111 (shimbun-from-address shimbun) 112 date id "" 0 0 url) 113 headers)) 114 headers)) 115 116(provide 'sb-japantimes) 117 118;;; sb-japantimes.el ends here 119