2000-09-16 iモード対応のはなし―その後―
この度yumi-ii/yuminetがiモードに完全対応しました。今回はサーバサイドスクリプトでHTML4のファイルをiモード形式に変換するのではなくて,HTML4とコンパクトHTMLの二種類を別個に用意しました。いわば正攻法です。
ところで私は相変わらずiモード端末を所有していないので,一度も表示確認しておりません。仕様書どおりに作ったつもりなのでそれなりに仕上がっているハズです。
おまけ
ウェブ掲載に際して原物のソースファイルを一部修正しています。原物には1行当たりの文字数が極端に多い行が含まれていますが,そのような行は複数行に分けています。
#### ユミフォーマッタ
#### ver. 1.22.2000.0916(たぶんこれくらい)
####
$_outputpath ="z:\\~yumi-ii\\yuminet";
$_masterdirectory ="z:\\~yumi-ii\\temp\\master";
main: {
my (@dir, @htmlfile, @indexes);
####
opendir(DIR, $_masterdirectory);
@dir = sort(readdir(DIR));
closedir(DIR);
foreach (@dir) {
/^(.*)\./;
push(@htmlfile, "html-$1.html");
}
for (my $index = 2; $index <= $#dir; $index ++) {
my ($type, $subject, $body, $current, $prev, $next);
####
readfile: {
my $masterfilename = $dir[$index];
open(HANDLE, "$_masterdirectory\\$masterfilename");
while (<HANDLE>) {
($type) = /^type:(.*)$/ unless $type;
($subject) = /^sub:(.*)$/ unless $subject;
($body) = /^body:(.*)$/ unless $body;
}
close HANDLE;
}
$current = $htmlfile[$index];
## write_HTML4_form
##
$prev = $index > 2 ? $htmlfile[$index - 1] : "root.html";
$next = $index < $#dir ? $htmlfile[$index + 1] : "final.html";
open(HANDLE, ">$_outputpath\\$current");
select HANDLE;
doFormating("HTML4", $type, $subject, $body, $current, $prev, $next);
close(HANDLE);
## write_NTTimode_form
##
$prev = ($index > 2) ? $htmlfile[$index - 1] : "html-root.html";
$next = ($index < $#dir) ? $htmlfile[$index + 1] : "html-final.html";
open(HANDLE, ">$_outputpath\\c$current");
select HANDLE;
doFormating("NTT_imode", $type, $subject, $body, "c$current", "c$prev", "c$next");
close(HANDLE);
####
push(@indexes, {uri => $next, title, $body}) if $type eq "eyecatcher";
}
## write_indexfile
##
open(HANDLE, ">index.txt");
foreach (@indexes) {
print qq!<a href="$_->{uri}">$_->{title}</a> |!;
}
print "\n\n";
my $index = 1;
foreach (@indexes) {
print qq!<a href="c$_->{uri}">#$index</a> !;
$index ++;
}
close(HANDLE);
exit;
}
sub doFormating {
sub outputHTML4Form; # 入れ子になったサブルーチンのプロトタイプ宣言
sub outputNTTimodeForm;
####
local ($markupType, $type, $subject, $body, $current, $prev, $next) = @_;
for ($markupType) {
local ($title = "ユミの日記 「$subject」");
/^HTML4/ && do {
outputHTML4Form;
};
/^NTT_imode/ && do {
outputNTTimodeForm;
};
}
return;
####
sub outputHTML4Form {
## HEADER
##
my $styleFile = $type eq 'diary' ? 'style-posi@2000091693.css' : 'style-nega@2000091692.css';
####
print <<EOB;
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
\t<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS">
\t<link rel=stylesheet href="./$styleFile" type="text/css">
\t<script language="JavaScript1.1" src="./js-animation\@2000081741.js"></script>
\t<script language="JavaScript1.1" src="./js-msg\@2000091641.js"></script>
\t<title>$title</title>
</head>
EOB
## BODY
##
for ($type) {
my $imodeUri = "c$current";
####
/^diary/ && do {
print <<EOB;
<body>
<div class=navi>
<a href="./$imodeUri" accesskey="I">
<img src="./imgs/img-\@2000081614.gif" width=16 height=16 alt="*" border=0> iモード
</a>
<a href="$prev" accesskey="P">
<img src="./imgs/img-\@2000081610.gif" width=16 height=16 alt="*" border=0> まえ (P)
</a>
<a href="$next" accesskey="N">
<img src="./imgs/img-\@2000081611.gif" width=16 height=16 alt="*" border=0> つぎ (N)
</a><br>
<a href="./root.html" accesskey="R" onclick="return bye()"
onMouseOver="startAnimation();" onMouseOut="stopAnimation()">
<img src="./imgs/img-128x96\@1998102010.jpg" width="128" height="96" vspace=16
alt="かえるよ (R)" border=0 name=animation>
</a></div>
<div class=content>
\t<h2>$subject</h2>
\t<p>$body</p>
</div>
EOB
};
/^eyecatcher/ && do {
print <<EOB;
<body>
<div class=navi>
<a href="$imodeUri" accesskey="I">
<img src="./imgs/img-\@2000081617.gif" width=16 height=16 alt="*" border=0> iモード
</a>
<a href="$prev" accesskey="P">
<img src="./imgs/img-\@2000081615.gif" width=16 height=16 alt="*" border=0> まえ (P)
</a>
<a href="$next" accesskey="N">
<img src="./imgs/img-\@2000081616.gif" width=16 height=16 alt="*" border=0> つぎ (N)
</a>
<br><a href="./root.html" onclick="return bye()" accesskey="R">
<img src="./imgs/yumititlesn.jpg" width="128" height="96" vspace=16 alt="かえるよ (R)" border=0>
</a>
</div>
<div class=content>
\t<p>$body</p>
</div>
EOB
};
}
## FOOTER
##
print <<"EOB";
</body>
</html>
EOB
} # end of subroutine
sub outputNTTimodeForm {
## HEADER
##
print <<EOB;
<head><title>$title</title></head>
EOB
## BODY
##
for ($type) {
/^diary/ && do {
print <<EOB;
<body>
[0] <a href="./chtml-root.html" accesskey="0">かえるよ</a>
<br>[7] <a href="$prev" accesskey="7">まえ</a> [9] <a href="$next" accesskey="9">つぎ
</a><br>
<h2>$subject</h2>
<br>$body
EOB
};
/^eyecatcher/ && do {
print <<EOB;
<body>
[0] <a href="./chtml-root.html" accesskey="0">かえるよ</a>
<br>[7] <a href="$prev" accesskey="7">まえ</a> [9] <a href="$next" accesskey="9">つぎ</a>
<p>$body</p>
EOB
};
}
## FOOTER
##
print <<"EOB";
</body>
EOB
} # end of subroutine
}