Debian Codegraph @

Bonus/goodict.cgi

raw
1 #!/usr/bin/perl
2
3 # ~/.w3m/urimethodmap
4 # e: file:/cgi-bin/goodict.cgi?%s Englich-Japanese
5 # w: file:/cgi-bin/goodict.cgi?%s Japanese-English
6 # j: file:/cgi-bin/goodict.cgi?%s Japanese
7 # a: file:/cgi-bin/goodict.cgi?%s All
8 #
9 # e:0:word start with word
10 # e:1:word perfect match
11 # e:2:word end with word
12 # e:3:word search body text
13 # e:6:word search title
14 # e:word perfect match
15
16 use Encode;
17 use Encode::Guess qw/euc-jp utf8/;
18 $url = "http://dictionary.goo.ne.jp";
19 $_ = $ENV{"QUERY_STRING"};
20 if (/^e:/) {
21 $kind = 'ej';
22 } elsif (/^w:/) {
23 $kind = 'je';
24 } elsif (/^j:/) {
25 $kind = 'jn';
26 } elsif (/^a:/) {
27 $kind = 'all'
28 }
29 s@^[ewja]:@@ && s@^//@@ && s@/$@@;
30 if (/^([01236]):/) {
31 $mode=$1;
32 s/^[01236]://;
33 }else{
34 $mode="1";
35 }
36 if ($_) {
37 s/\+/ /g;
38 s/%([\da-f][\da-f])/pack('C', hex($1))/egi;
39 $_ = encode("utf8", decode("Guess", $_));
40 s/[\000-\040\+:#?&%<>"\177-\377]/sprintf('%%%02X', unpack('C', $&))/eg;
41 $url .= "/srch/$kind/$_/m$mode"."u/";
42 } else {
43 $input = "w3m-control: GOTO_LINK";
44 }
45 print <<EOF;
46 w3m-control: GOTO $url
47 w3m-control: DELETE_PREVBUF
48 w3m-control: SEARCH \\[
49 w3m-control: MOVE_RIGHT
50 ${input}
51
52 EOF