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