1 |
wakaba |
1.1 |
|
2 |
|
|
=head1 NAME
|
3 |
|
|
|
4 |
|
|
Suikawari::TomikouNikki --- Suikawari module for Tomikou Nikki
|
5 |
|
|
E<lt>http://tomikou.net/nikki/E<gt>
|
6 |
|
|
|
7 |
|
|
=cut
|
8 |
|
|
|
9 |
|
|
## This file is written in EUC-japan encoding.
|
10 |
|
|
|
11 |
|
|
package Suikawari::TomikouNikki;
|
12 |
|
|
use strict;
|
13 |
|
|
use vars qw/$VERSION/;
|
14 |
|
|
$VERSION=do{my @r=(q$Revision: 1.1 $=~/\d+/g);sprintf "%d."."%02d" x $#r,@r};
|
15 |
|
|
use Message::MIME::Charset::Jcode 'jcode.pl';
|
16 |
|
|
|
17 |
|
|
sub msg_regex ($) {
|
18 |
|
|
<<'EOH',
|
19 |
|
|
<a name="[0-9]+"><dt><a href="#[0-9]+"><img src="[^"]+" width=10 height=10 hspace=2 vspace=2 border=0></a><b>([0-9]+)月([0-9]+)日[^<]+</b> <i>([^<]*)</i>
|
20 |
|
|
<img (?:src="([^"]+)" )?width=240 height=180 hspace=4 vspace=2 align=right alt="([^"]*?)">
|
21 |
|
|
<dd>([\x00-\xFF]*?)</a><br clear=right>
|
22 |
|
|
EOH
|
23 |
|
|
qw (date_month date_day subject misc_img_src_uri misc_img_alt body);
|
24 |
|
|
}
|
25 |
|
|
|
26 |
|
|
sub meta_regex ($) {
|
27 |
|
|
<<'EOH',
|
28 |
|
|
<CENTER><TABLE WIDTH=90%><TR><TD>
|
29 |
|
|
<a href="([^"]+)"><img src="([^"]+)" width=57 height=100 hspace=4 border=0 align=right alt="([^"]+)"></a>
|
30 |
|
|
<img src="[^"]+" width=16 height=16 hspace=5 vspace=3><font size=6><b>富校日記</b></font>[^<]+<b>担当[^<]+<a href="[^"]+">[^0-9]+([0-9]+)期生[^<]+</a></b><br>
|
31 |
|
|
(?:\xA1\xA1)?([^<]+)<br>
|
32 |
|
|
[^<]+<b>日記記者にメールを送る</b>[^<]+<a href="mailto:([^?"]+)\?Subject=富校日記"><b><i>[^<]+</i></b></a><br>
|
33 |
|
|
(?:\xA1\xA1)?([^<]+)
|
34 |
|
|
</TD></TR></TABLE></CENTER>
|
35 |
|
|
EOH
|
36 |
|
|
qw (misc_kisha_shoukai_uri misc_kisha_kao_uri from_name
|
37 |
|
|
misc_kisha_kai list_info from_mail reply_info);
|
38 |
|
|
}
|
39 |
|
|
|
40 |
|
|
sub on_load_source ($$) {shift;
|
41 |
|
|
my $b = shift;
|
42 |
|
|
$b->set_hook_function (code_conversion => sub { jcode::euc ($_[1]) });
|
43 |
|
|
}
|
44 |
|
|
|
45 |
|
|
sub source ($) {
|
46 |
|
|
(uri => 'http://tomikou.net/nikki/'.((gmtime)[5]+1900).'/');
|
47 |
|
|
#(file => '../../nikki.html');
|
48 |
|
|
}
|
49 |
|
|
|
50 |
|
|
sub face ($) {
|
51 |
|
|
my %face;
|
52 |
|
|
$face{'high-c@tomikou.net'} = <<'EOH';
|
53 |
|
|
q:G5-(BB7)u*C6yv4c]Y9T`OX[;eLZwZf"[Q6HAjHZ*0[.%]GUUqPNZVP]M-
|
54 |
|
|
w,Q{<J|VZQ67rS0v>{blX>~"_crO_a#L{}k^bNd-D5d4"V(|SWFhnF{Uw/
|
55 |
|
|
mfK-fCZNmLayiDN#SLjq)2?CbyUq8#-.j1\wD#aF8@p?463=hX2mW8z\D$mk
|
56 |
|
|
pqx3^UvUXe{Kub/4+Ihl.wl1|(lij2+`?X4gHqdLBh?BVrN]6W)FBc.y;=>4
|
57 |
|
|
f8*KM;HtoIa0~c2O.s<dpsVu,9:_Y$[
|
58 |
|
|
EOH
|
59 |
|
|
(faces => \%face);
|
60 |
|
|
}
|
61 |
|
|
|
62 |
|
|
sub on_make ($$) {shift;
|
63 |
|
|
my $b = shift;
|
64 |
|
|
$b->default_parameter (date_zone => '+0900');
|
65 |
|
|
$b->default_parameter (list_name => '富校日記');
|
66 |
|
|
$b->default_parameter (list_id => 'nikki.tomikou.net');
|
67 |
|
|
$b->default_parameter (msg_id_from => 'news@list.suika.fam.cx');
|
68 |
|
|
$b->default_parameter (newsgroups => 'suika.tomikou');
|
69 |
|
|
$b->default_parameter (urn_template => 'urn:x-tomikou-net:nikki:%YYYY;:%MM;:%DD;');
|
70 |
|
|
$b->set_hook_function (msg_header_add => sub {
|
71 |
|
|
shift;
|
72 |
|
|
my ($msg, $p) = @_;
|
73 |
|
|
my $hdr = $msg->header;
|
74 |
|
|
## From
|
75 |
|
|
my $from = $hdr->field ('from')->item ($p->{from_mail}, -by => 'addr-spec');
|
76 |
|
|
$from->display_name ($p->{from_name} . '@' . $p->{misc_kisha_kai});
|
77 |
|
|
## Reply-to
|
78 |
|
|
my $replyto = $from->clone;
|
79 |
|
|
$replyto->comment_add ($p->{reply_info});
|
80 |
|
|
$hdr->add (reply_to => $replyto);
|
81 |
|
|
## Newsgroups
|
82 |
|
|
my $group = $p->{newsgroups};
|
83 |
|
|
$group = 'suika.test' if $Bunshin::DEBUG;
|
84 |
|
|
$hdr->replace (newsgroups => $group);
|
85 |
|
|
## Subject
|
86 |
|
|
$hdr->replace (subject => $p->{list_name}.
|
87 |
|
|
(length $p->{subject}? ' '.$p->{subject}: '')
|
88 |
|
|
);
|
89 |
|
|
});
|
90 |
|
|
$b->set_hook_function (msg_body => sub {
|
91 |
|
|
shift;
|
92 |
|
|
my ($msg, $body, $p) = @_;
|
93 |
|
|
## Construct multipart
|
94 |
|
|
$msg->header->add (content_type => 'multipart/mixed');
|
95 |
|
|
$msg->header->add (content_location => $p->{base_uri}) if $p->{base_uri};
|
96 |
|
|
## Text part
|
97 |
|
|
my $part1 = $msg->body->item (0);
|
98 |
|
|
$body =~ s/^\xA1\xA1//;
|
99 |
|
|
my @p = split /<br>\x0D\x0A(?:\xA1\xA1)?/, $body;
|
100 |
|
|
my $ct = $part1->header->field ('content-type');
|
101 |
|
|
$ct->media_type ('text/plain');
|
102 |
|
|
$ct->parameter (format => 'flowed');
|
103 |
|
|
$ct->parameter (charset => 'iso-2022-jp');
|
104 |
|
|
$part1->header->replace (content_language => 'ja');
|
105 |
|
|
$part1->body->value ([ map { my $s = $_; $s =~ s/\x0D\x0A/\x20/gs; {value => $s} } @p ]);
|
106 |
|
|
## Image part
|
107 |
|
|
if ($p->{misc_img_src_uri}) {
|
108 |
|
|
my $part2 = $msg->body->item (1);
|
109 |
|
|
$part2->header->add (content_type => 'multipart/alternative');
|
110 |
|
|
$part2->header->add (content_description => $p->{misc_img_alt});
|
111 |
|
|
## message/external-body
|
112 |
|
|
my $part2_1 = $part2->body->item (0);
|
113 |
|
|
my $ct = $part2_1->header->field ('content-type');
|
114 |
|
|
$ct->value ('text/html');
|
115 |
|
|
$ct->parameter (charset => 'iso-2022-jp');
|
116 |
|
|
my $html = <<EOH;
|
117 |
|
|
<?xml version="1.0" encoding="iso-2022-jp"?>
|
118 |
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
|
119 |
|
|
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
120 |
|
|
<html xml:lang="ja" xmlns="http://www.w3.org/1999/xhtml">
|
121 |
|
|
<head>
|
122 |
|
|
<base href="$p->{base_uri}" />
|
123 |
|
|
<title>$p->{list_name}</title>
|
124 |
|
|
</head>
|
125 |
|
|
<body>
|
126 |
|
|
<div>
|
127 |
|
|
<img src="$p->{misc_img_src_uri}" alt="$p->{misc_img_alt}" />
|
128 |
|
|
</div>
|
129 |
|
|
</body>
|
130 |
|
|
EOH
|
131 |
|
|
$part2_1->body->value ($html);
|
132 |
|
|
## message/external-body
|
133 |
|
|
my $part2_2 = $part2->body->item (1);
|
134 |
|
|
$part2_2->header->add (content_type => 'message/external-body');
|
135 |
|
|
require URI::WithBase;
|
136 |
|
|
my $uri = URI::WithBase->new ($p->{misc_img_src_uri}, $p->{base_uri});
|
137 |
|
|
$part2_2->body->set_reference (url =>
|
138 |
|
|
ct => 'image/jpeg',
|
139 |
|
|
url => $uri->abs,
|
140 |
|
|
);
|
141 |
|
|
$part2_2->body->option (msg_id_from => $p->{msg_id_from});
|
142 |
|
|
}
|
143 |
|
|
});
|
144 |
|
|
}
|
145 |
|
|
|
146 |
|
|
=head1 SEE ALSO
|
147 |
|
|
|
148 |
|
|
Suikawari, Bunshin
|
149 |
|
|
|
150 |
|
|
=head1 LICENSE
|
151 |
|
|
|
152 |
|
|
Copyright 2002 wakaba E<lt>w@suika.fam.cxE<gt>.
|
153 |
|
|
|
154 |
|
|
This program is free software; you can redistribute it and/or modify
|
155 |
|
|
it under the terms of the GNU General Public License as published by
|
156 |
|
|
the Free Software Foundation; either version 2 of the License, or
|
157 |
|
|
(at your option) any later version.
|
158 |
|
|
|
159 |
|
|
This program is distributed in the hope that it will be useful,
|
160 |
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
161 |
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
162 |
|
|
GNU General Public License for more details.
|
163 |
|
|
|
164 |
|
|
You should have received a copy of the GNU General Public License
|
165 |
|
|
along with this program; see the file COPYING. If not, write to
|
166 |
|
|
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
167 |
|
|
Boston, MA 02111-1307, USA.
|
168 |
|
|
|
169 |
|
|
=head1 CHANGE
|
170 |
|
|
|
171 |
|
|
See F<ChangeLog>.
|
172 |
|
|
$Date: 2002/06/16 02:50:54 $
|
173 |
|
|
|
174 |
|
|
=cut
|
175 |
|
|
|
176 |
|
|
1;
|
177 |
|
|
### Suikawari::TomikouNikki ends here
|