1 ;;; sb-fml.el --- shimbun backend class for fml archiver.
3 ;; Author: TSUCHIYA Masatoshi <tsuchiya@pine.kuee.kyoto-u.ac.jp>
4 ;; Akihiro Arisawa <ari@atesoft.advantest.co.jp>
5 ;; Yuuichi Teranishi <teranisi@gohome.org>
11 ;; This program is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; This program is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with this program; if not, you can either send email to this
23 ;; program's maintainer or write to: The Free Software Foundation,
24 ;; Inc.; 59 Temple Place, Suite 330; Boston, MA 02111-1307, USA.
28 ;; Original code was nnshimbun.el written by
29 ;; TSUCHIYA Masatoshi <tsuchiya@pine.kuee.kyoto-u.ac.jp>.
35 (luna-define-class shimbun-fml (shimbun) ())
37 (luna-define-method shimbun-get-headers ((shimbun shimbun-fml))
38 (let ((case-fold-search t)
42 (if (re-search-forward "<a href=\"\\([0-9]+\\(\\.week\\|\\.month\\)?\\)/index.html\">" nil t)
43 (setq auxs (append auxs (list (match-string 1)))))
48 (concat (shimbun-url-internal shimbun) (setq aux (car auxs)) "/"))
49 (subst-char-in-region (point-min) (point-max) ?\t ? t)
50 (let ((case-fold-search t)
51 id url date subject from)
52 (goto-char (point-min))
53 (while (re-search-forward
54 "<LI><A HREF=\"\\([0-9]+\\.html\\)\">Article .*</A> <DIV><SPAN CLASS=article>Article <SPAN CLASS=article-value>\\([0-9]+\\)</SPAN></SPAN> at <SPAN CLASS=Date-value>\\([^<]*\\)</SPAN> <SPAN CLASS=Subject>Subject: <SPAN CLASS=Subject-value>\\([^<]*\\)</SPAN></SPAN></DIV><DIV><SPAN CLASS=From>From: <SPAN CLASS=From-value>\\([^<]*\\)</SPAN></SPAN></DIV>"
56 (setq url (concat (shimbun-url-internal shimbun)
57 aux "/" (match-string 1))
58 id (format "<%s%05d%%%s>"
60 (string-to-number (match-string 2))
61 (shimbun-current-group-internal shimbun))
63 subject (match-string 4)
64 from (match-string 5))
66 (push (shimbun-make-header
68 (shimbun-mime-encode-string subject)
69 from date id "" 0 0 url)
71 (setq auxs (cdr auxs))))
74 (luna-define-method shimbun-make-contents ((shimbun shimbun-fml) header)
76 (if (search-forward "<SPAN CLASS=mailheaders>" nil t)
77 (delete-region (point-min) (point))
79 (if (search-forward "</PRE>")
82 (delete-region (point) (point-max)))
84 (if (search-backward "</SPAN>")
90 (narrow-to-region (point-min) (point))
91 (subst-char-in-region (point-min) (point-max) ?\t ? t)
92 (shimbun-decode-entities)
93 (goto-char (point-min))
94 (let ((header (shimbun-make-header))
95 field value start value-beg end)
96 (while (and (setq start (point))
97 (re-search-forward "<SPAN CLASS=\\(.*\\)>\\(.*\\)</SPAN>:"
99 (setq field (match-string 2))
101 (concat "<SPAN CLASS=" (match-string 1) "-value>") nil t)
102 (setq value-beg (point))
103 (search-forward "</SPAN>" nil t)
105 (setq value (buffer-substring value-beg
106 (progn (search-backward "</SPAN>")
108 (delete-region start end)
109 (cond ((string= field "Date")
110 (shimbun-header-set-date header value))
111 ((string= field "From")
112 (shimbun-header-set-from header value))
113 ((string= field "Subject")
114 (shimbun-header-set-subject header value))
115 ((string= field "Message-Id")
116 (shimbun-header-set-id header value))
117 ((string= field "References")
118 (shimbun-header-set-references header value))
120 (insert (concat field ": " value "\n")))))
121 (goto-char (point-min))
122 (shimbun-header-insert header))
123 (goto-char (point-max)))
126 (narrow-to-region (point) (point-max))
127 (shimbun-remove-markup)
128 (shimbun-decode-entities)))
129 (encode-coding-string (buffer-string)
130 (mime-charset-to-coding-system "ISO-2022-JP")))
134 ;;; sb-fml.el ends here