From: Koichi KAMICHI Date: Mon, 1 Mar 2010 06:45:00 +0000 (+0000) Subject: renew source. X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e9a7271024b84991d53f25cf547b1f9fa104fc06;p=chise%2Fkage.git renew source. --- diff --git a/linkmap/map.cgi b/linkmap/map.cgi index 646fdd4..27f2701 100755 --- a/linkmap/map.cgi +++ b/linkmap/map.cgi @@ -1,23 +1,26 @@ #!/usr/bin/perl $PERL = "/usr/bin/perl"; -$LINKMAP_DIR = "/var/www/chiseperl"; - -$random = "linkmap_".(sprintf "%05X", int(rand()*0x100000)); +#$LINKMAP_DIR = "/var/www/fonts.jp/chise_linkmap"; +$LINKMAP_DIR = "/var/www/chise_linkmap"; use CGI; $cgi = new CGI; -$target = $cgi->param('code'); -$target =~ s/[^a-zA-Z0-9]//g; - -$dummy = `$PERL $LINKMAP_DIR/map.pl $target $random 2>/dev/null`; - -$buffer = ""; -open FH, "<${random}.html"; -while(!eof(FH)){ - $buffer .= ; +$target = lc($cgi->param('code')); +if($target !~ m/^[0-9a-f]{4,5}$/){ + $buffer = "Request error!"; +} else { + if(!-e "$LINKMAP_DIR/data/linkmap_$target.html"){ + $dummy = `$PERL $LINKMAP_DIR/map.pl $target data/linkmap_$target 2>/dev/null`; + } + + $buffer = ""; + open FH, "<$LINKMAP_DIR/data/linkmap_$target.html"; + while(!eof(FH)){ + $buffer .= ; + } + close FH; } -close FH; print "Content-type: text/html\n\n"; print $buffer; diff --git a/linkmap/map.pl b/linkmap/map.pl index f7df3f6..8a0a143 100755 --- a/linkmap/map.pl +++ b/linkmap/map.pl @@ -1,12 +1,12 @@ #----------------------------------------------------------------------------- use utf8; binmode STDOUT, ":utf8"; -require 'chiseperl.pl'; +use chise; use Encode; $rate = 0.75; -$x = -10; -$y = 14; +$x = -5; +$y = 10; %char = (); %link = (); %family = (); @@ -18,10 +18,14 @@ $png = "png"; $svg = "svg"; $graphviz = '/usr/bin/dot'; $html = "html"; +$EXPR_STYLE = 'x="([0-9.-]+)" y="([0-9.-]+)" style="font-family:Times New Roman;font-size:14.00;"'; +$SERVER = 'mousai.kanji.zinbun.kyoto-u.ac.jp'; +$SERVER2 = 'kanji.zinbun.kyoto-u.ac.jp'; #----------------------------------------------------------------------------- -&init_chise; +$chise = new chise; +@chise_feature = $chise->get_feature_list(); foreach(@chise_feature){ if($_ !~ m/sources/){ push(@list, $_); @@ -73,31 +77,28 @@ print FH2 < EOT foreach(){ - if(m/x\=\"([0-9]+)\" y\=\"([0-9]+)\"\>\=cns11643\&\#45\;([1-9])\:([0-9A-F]{4})/){ + if(m/=cns11643\&\#45;([1-9]):([0-9A-F]{4})/){ $left = int($1 / $rate) + $x; - $top = int($2 / $rate) + $y; + $top = $cy + int($2 / $rate) + $y; print FH2 "
"; - print FH2 "\r\n"; + print FH2 "\r\n"; print FH2 "
"; - } elsif(m/x\=\"([0-9]+)\" y\=\"([0-9]+)\"\>\=jef\&\#45\;china3\:([0-9A-F]{4})/){ + } elsif(m/$EXPR_STYLE>\=jef\&\#45\;china3\:([0-9A-F]{4})/){ $left = int($1 / $rate) + $x; - $top = int($2 / $rate) + $y; + $top = $cy + int($2 / $rate) + $y; $target = $3; $target =~ tr/A-F/a-f/; print FH2 "
"; - print FH2 "\r\n"; + print FH2 "\r\n"; print FH2 "
"; - #} elsif(m/x\=\"([0-9]+)\" y\=\"([0-9]+)\"\>\=gb2312\:([0-9A-F]{4})/){ - # $left = int($1 / $rate) + $x; - # $top = int($2 / $rate) + $y; - # print FH2 "
"; - # $ku = int(eval('0x'.$3) / 0x100) - 0x20; - # $ten = sprintf "%02d", eval('0x'.$3) % 0x100 - 0x20; - # print FH2 "\r\n"; - # print FH2 "
"; - } elsif(m/x\=\"([0-9]+)\" y\=\"([0-9]+)\"\>\=gb2312\:([0-9A-F]{4})/){ + } elsif(m/$EXPR_STYLE>\=gb2312\:([0-9A-F]{4})/){ $left = int($1 / $rate) + $x; - $top = int($2 / $rate) + $y; + $top = $cy + int($2 / $rate) + $y; print FH2 "
"; $char = $3; $char =~ s/([0-9A-F]{2})/pack('H2', $1)/eg; @@ -105,37 +106,37 @@ foreach(){ utf8::decode($char); print FH2 "$char\r\n"; print FH2 "
"; - } elsif(m/x\=\"([0-9]+)\" y\=\"([0-9]+)\"\>\=jis\&\#45\;x0208\@19(78|83|90|97)\:([0-9A-F]{4})/){ + } elsif(m/$EXPR_STYLE>\=jis\&\#45\;x0208\@19(78|83|90|97)\:([0-9A-F]{4})/){ $left = int($1 / $rate) + $x; - $top = int($2 / $rate) + $y; + $top = $cy + int($2 / $rate) + $y; print FH2 "
"; $ku = int(eval('0x'.$4) / 0x100) - 0x20; $ten = sprintf "%02d", eval('0x'.$4) % 0x100 - 0x20; - print FH2 "\r\n"; + print FH2 "\r\n"; print FH2 "
"; - } elsif(m/x\=\"([0-9]+)\" y\=\"([0-9]+)\"\>\=jis\&\#45\;x0212\:([0-9A-F]{4})/){ + } elsif(m/$EXPR_STYLE>\=jis\&\#45\;x0212\:([0-9A-F]{4})/){ $left = int($1 / $rate) + $x; - $top = int($2 / $rate) + $y; + $top = $cy + int($2 / $rate) + $y; print FH2 "
"; $ku = int(eval('0x'.$3) / 0x100) - 0x20; $ten = sprintf "%02d", eval('0x'.$3) % 0x100 - 0x20; - print FH2 "\r\n"; + print FH2 "\r\n"; print FH2 "
"; - } elsif(m/x\=\"([0-9]+)\" y\=\"([0-9]+)\"\>\=zinbun\&\#45;oracle\:([0-9A-F]{1,4})/){ + } elsif(m/$EXPR_STYLE>\=zinbun\&\#45;oracle\:([0-9A-F]{1,4})/){ $left = int($1 / $rate) + $x - 20; - $top = int($2 / $rate) + $y; + $top = $cy + int($2 / $rate) + $y; my $number = sprintf "%04d", eval('0x'.$3); - print FH2 ""; + print FH2 ""; print FH2 ""; - } elsif(m/x\=\"([0-9]+)\" y\=\"([0-9]+)\"\>\=ucs\:([0-9A-F]{4,6})/){ + } elsif(m/$EXPR_STYLE>\=ucs\:([0-9A-F]{4,6})/){ $left = int($1 / $rate) + $x - 20; - $top = int($2 / $rate) + $y; + $top = $cy + int($2 / $rate) + $y; print FH2 "
"; print FH2 "[".pack('U',eval('0x'.$3))."]\r\n"; print FH2 "
"; - } elsif(m/x\=\"([0-9]+)\" y\=\"([0-9]+)\"\>\=big5\:([0-9A-F]{4,6})/){ + } elsif(m/$EXPR_STYLE>\=big5\:([0-9A-F]{4,6})/){ $left = int($1 / $rate) + $x; - $top = int($2 / $rate) + $y; + $top = $cy + int($2 / $rate) + $y; print FH2 "
"; $char = $3; $char =~ s/([0-9A-F]{2})/pack('H2', $1)/eg; @@ -143,32 +144,15 @@ foreach(){ utf8::decode($char); print FH2 "$char\r\n"; print FH2 "
"; - #} elsif(m/x\=\"([0-9]+)\" y\=\"([0-9]+)\"\>\=hanziku\&\#45\;([0-9]{1,2})\:([0-9A-F]{4})/){ - # $left = int($1 / $rate) + $x; - # $top = int($2 / $rate) + $y; - # #$number = sprintf "%02d", $3; - # $number = $3; - # $numberk = $3; - # $numberk =~ tr/12345678/一二三四五六七八/; - # #print FH2 "
"; - # print FH2 "
"; - # #printf FH2 pack('U', chise::chise_ds_decode_char($chise_ds, chise_tools::get_uchar("=hanziku-$number"), eval('0x'.$4))); - # #printf FH2 pack('U', chise::chise_ds_decode_char($chise_ds, chise_tools::get_uchar("=big5"), eval('0x'.$4))); - # $char = $4; - # $char =~ s/([0-9A-F]{2})/pack('H2', $1)/eg; - # Encode::from_to($char, 'big5', 'utf-8'); - # utf8::decode($char); - # print FH2 "$char\r\n"; - # print FH2 "
"; - } elsif(m/x\=\"([0-9]+)\" y\=\"([0-9]+)\"\>\=big5\&\#45\;cdp\:([0-9A-F]{4,6})/){ + } elsif(m/$EXPR_STYLE>\=big5\&\#45\;cdp\:([0-9A-F]{4,6})/){ $left = int($1 / $rate) + $x; - $top = int($2 / $rate) + $y; + $top = $cy + int($2 / $rate) + $y; print FH2 "
"; - printf FH2 pack('U', chise::chise_ds_decode_char($chise_ds, chise::get_uchar('=big5-pua'), eval('0x'.$3))); + printf FH2 pack('U', $chise->ds_decode_char('=big5-pua', eval('0x'.$3))); print FH2 "
"; - } elsif(m/x\=\"([0-9]+)\" y\=\"([0-9]+)\"\>\=jis\&\#45\;x0208\:([0-9A-F]{4,6})/){ + } elsif(m/$EXPR_STYLE>\=jis\&\#45\;x0208\:([0-9A-F]{4,6})/){ $left = int($1 / $rate) + $x; - $top = int($2 / $rate) + $y; + $top = $cy + int($2 / $rate) + $y; print FH2 "
"; $char = $3; $char =~ s/([0-9A-F]{2})/pack('H2', $1)/eg; @@ -176,9 +160,9 @@ foreach(){ utf8::decode($char); print FH2 "$char\r\n"; print FH2 "
"; - } elsif(m/x\=\"([0-9]+)\" y\=\"([0-9]+)\"\>\=ks\&\#45\;x1001\:([0-9A-F]{4,6})/){ + } elsif(m/$EXPR_STYLE>\=ks\&\#45\;x1001\:([0-9A-F]{4,6})/){ $left = int($1 / $rate) + $x; - $top = int($2 / $rate) + $y; + $top = $cy + int($2 / $rate) + $y; print FH2 "
"; $char = $3; $char =~ s/([0-9A-F]{2})/pack('H2', $1)/eg; @@ -186,9 +170,9 @@ foreach(){ utf8::decode($char); print FH2 "$char\r\n"; print FH2 "
"; - } elsif(m/x\=\"([0-9]+)\" y\=\"([0-9]+)\"\>\=gt\&\#45\;pj\&\#45\;([0-9]{1,2}):([0-9A-F]{4})/){ + } elsif(m/$EXPR_STYLE>\=gt\&\#45\;pj\&\#45\;([0-9]{1,2}):([0-9A-F]{4})/){ $left = int($1 / $rate) + $x; - $top = int($2 / $rate) + $y; + $top = $cy + int($2 / $rate) + $y; $number = sprintf("%02d", $3); print FH2 "
"; $char = $4; @@ -197,9 +181,9 @@ foreach(){ utf8::decode($char); print FH2 "$char\r\n"; print FH2 "
"; - } elsif(m/x\=\"([0-9]+)\" y\=\"([0-9]+)\"\>\=gt\&\#45\;pj\&\#45\;(k[12]):([0-9A-F]{4})/){ + } elsif(m/$EXPR_STYLE>\=gt\&\#45\;pj\&\#45\;(k[12]):([0-9A-F]{4})/){ $left = int($1 / $rate) + $x; - $top = int($2 / $rate) + $y; + $top = $cy + int($2 / $rate) + $y; print FH2 "
"; $char = $4; $char =~ s/([0-9A-F]{2})/pack('H2', $1)/eg; @@ -216,7 +200,7 @@ $i = 0; foreach(){ if($i == 1){ m/points=\"[0-9]+,[0-9]+ ([0-9]+),([0-9]+) [0-9]+,[0-9]+ ([0-9]+),([0-9]+) /; - print FH2 "\n"; + print FH2 "\n"; $i = 0; } elsif(m/^(2{0,1}[0-9A-F]{4})<\/title>\n$/){ @@ -233,8 +217,6 @@ print FH2 <<EOT; EOT close FH2; -&close_chise; - #----------------------------------------------------------------------------- sub process{ my ($buffer, @buffer, $feature); @@ -251,7 +233,7 @@ sub process{ #ccs-feature foreach(@list){ if((substr($_,0,1) eq '=' && substr($_,1,1) ne '>') || $_ eq "morohashi-daikanwa"){ - $buffer = get_feature_value($_, $_[0]); + $buffer = $chise->char_gets_feature_value($_[0], $_); if($buffer ne ""){ if($_ eq "=daikanwa" || $_ eq "=gt" || $_ eq "=gt-k"){ $char{$_[0]} .= sprintf("$_:%05d\\n", $buffer); @@ -271,7 +253,7 @@ sub process{ #goto-feature foreach(@list){ if(substr($_,0,2) eq '->'){ - $buffer = get_feature_value($_, $_[0]); + $buffer = $chise->char_gets_feature_value($_[0], $_); if($buffer ne ""){ $feature = $_; @buffer = &parse($buffer); @@ -294,7 +276,7 @@ sub process{ #comefrom-feature foreach(@list){ if(substr($_,0,2) eq '<-'){ - $buffer = get_feature_value($_, $_[0]); + $buffer = $chise->char_gets_feature_value($_[0], $_); if($buffer ne ""){ $feature = $_; @buffer = &parse($buffer); @@ -311,7 +293,7 @@ sub process{ #nearlyequal-feature foreach(@list){ if(substr($_,0,2) eq '=>'){ - $buffer = get_feature_value($_, $_[0]); + $buffer = $chise->char_gets_feature_value($_[0], $_); if($buffer ne ""){ $feature = $_; @buffer = &parse($buffer);