w3mman support for section number during keyword search
Origin: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=916968#5
This commit is contained in:
committed by
Tatsuya Kinoshita
parent
87b2653b5e
commit
13c0ff5567
@@ -30,6 +30,8 @@ w3mman \- an interface to the on-line reference manuals via w3m(1)
|
|||||||
.B w3mman
|
.B w3mman
|
||||||
[
|
[
|
||||||
.BI \-M " path"
|
.BI \-M " path"
|
||||||
|
] [
|
||||||
|
.I section
|
||||||
]
|
]
|
||||||
.BI \-k " keyword"
|
.BI \-k " keyword"
|
||||||
.br
|
.br
|
||||||
|
@@ -6,8 +6,8 @@ $SCRIPT = 'file:///$LIB/w3mman2html.cgi';
|
|||||||
|
|
||||||
sub usage {
|
sub usage {
|
||||||
($_ = $0) =~ s@.*/@@;
|
($_ = $0) =~ s@.*/@@;
|
||||||
print STDERR "$_ [-M <path>] [[<section>] <command>]\n";
|
print STDERR "$_ [-M <path>] [<section>] <command>]\n";
|
||||||
print STDERR "$_ [-M <path>] [-k <keyword>]\n";
|
print STDERR "$_ [-M <path>] [<section>] [-k <keyword>]\n";
|
||||||
print STDERR "$_ [-l <file>]\n";
|
print STDERR "$_ [-l <file>]\n";
|
||||||
exit 1;
|
exit 1;
|
||||||
}
|
}
|
||||||
@@ -20,7 +20,8 @@ while (@ARGV) {
|
|||||||
$ENV{'MANPATH'} = shift @ARGV;
|
$ENV{'MANPATH'} = shift @ARGV;
|
||||||
} elsif (/^-k$/) {
|
} elsif (/^-k$/) {
|
||||||
@ARGV || &usage();
|
@ARGV || &usage();
|
||||||
$query = "?keyword=" . &form_encode(shift @ARGV);
|
if ( $query eq "" ) { $query = "?quit=ok"; }
|
||||||
|
$query .= "&keyword=" . &form_encode(shift @ARGV);
|
||||||
} elsif (/^-l$/) {
|
} elsif (/^-l$/) {
|
||||||
@ARGV || &usage();
|
@ARGV || &usage();
|
||||||
$query = "?quit=ok&local=" . &form_encode(shift @ARGV);
|
$query = "?quit=ok&local=" . &form_encode(shift @ARGV);
|
||||||
@@ -28,11 +29,11 @@ while (@ARGV) {
|
|||||||
} elsif (/^-/) {
|
} elsif (/^-/) {
|
||||||
&usage();
|
&usage();
|
||||||
} elsif (/^\d/ || $_ eq 'n') {
|
} elsif (/^\d/ || $_ eq 'n') {
|
||||||
@ARGV || &usage();
|
if ( $query eq "" ) { $query = "?quit=ok"; }
|
||||||
$query = "?quit=ok&man=" . &form_encode(shift @ARGV);
|
|
||||||
$query .= "§ion=" . &form_encode($_);
|
$query .= "§ion=" . &form_encode($_);
|
||||||
} else {
|
} else {
|
||||||
$query = "?quit=ok&man=" . &form_encode($_);
|
if ( $query eq "" ) { $query = "?quit=ok"; }
|
||||||
|
$query .= "&man=" . &form_encode($_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -23,17 +23,23 @@ if ((! $query{"man"}) && (! $query{"local"})) {
|
|||||||
if ($query{"keyword"}) {
|
if ($query{"keyword"}) {
|
||||||
$keyword = $query{"keyword"};
|
$keyword = $query{"keyword"};
|
||||||
$k = &html_quote($keyword);
|
$k = &html_quote($keyword);
|
||||||
|
if ($query{"section"}) {
|
||||||
|
$section = $query{"section"};
|
||||||
|
$sectionopt = "-s $section ";
|
||||||
|
} else {
|
||||||
|
$sectionopt = "";
|
||||||
|
}
|
||||||
print <<EOF;
|
print <<EOF;
|
||||||
Content-Type: text/html
|
Content-Type: text/html
|
||||||
|
|
||||||
<html>
|
<html>
|
||||||
<head><title>man -k $k</title></head>
|
<head><title>man $sectionopt-k $k</title></head>
|
||||||
<body>
|
<body>
|
||||||
<h2>man -k <b>$k</b></h2>
|
<h2>man $sectionopt-k <b>$k</b></h2>
|
||||||
<ul>
|
<ul>
|
||||||
EOF
|
EOF
|
||||||
$keyword =~ s:([^-\w\200-\377.,])::g;
|
$keyword =~ s:([^-\w\200-\377.,])::g;
|
||||||
open(F, "$MAN -k $keyword 2> /dev/null |");
|
open(F, "$MAN $sectionopt -k $keyword 2> /dev/null |");
|
||||||
while(<F>) {
|
while(<F>) {
|
||||||
chop;
|
chop;
|
||||||
$_ = &html_quote($_);
|
$_ = &html_quote($_);
|
||||||
@@ -58,10 +64,10 @@ Content-Type: text/html
|
|||||||
<body>
|
<body>
|
||||||
<form action="$CGI">
|
<form action="$CGI">
|
||||||
<table>
|
<table>
|
||||||
<tr><td>Manual:<td><input name=man>
|
<tr><td>Manual:<td><input name=man />
|
||||||
<tr><td>Section:<td><input name=section>
|
<tr><td>Section:<td><input name=section />
|
||||||
<tr><td>Keyword:<td><input name=keyword>
|
<tr><td>Keyword:<td><input name=keyword />
|
||||||
<tr><td><td><input type=submit> <input type=reset>
|
<tr><td><td><input type=submit /> <input type=reset />
|
||||||
</table>
|
</table>
|
||||||
</form>
|
</form>
|
||||||
</body>
|
</body>
|
||||||
|
Reference in New Issue
Block a user