summaryrefslogtreecommitdiffstats
path: root/khelpcenter/searchhandlers/khc_htsearch.pl
diff options
context:
space:
mode:
authorSlávek Banko <[email protected]>2014-02-07 02:51:30 +0100
committerSlávek Banko <[email protected]>2014-02-07 03:35:28 +0100
commite01673a2efa421edb4c3b539afa54868a4f29c1f (patch)
tree1aac3419322749abafee34ddf22ecaee800661e0 /khelpcenter/searchhandlers/khc_htsearch.pl
parent1a452134a7eb0851cdccc0376e792d6c4c8b2216 (diff)
downloadtdebase-e01673a2efa421edb4c3b539afa54868a4f29c1f.tar.gz
tdebase-e01673a2efa421edb4c3b539afa54868a4f29c1f.zip
Add cmake rule to find htsearch binary
Diffstat (limited to 'khelpcenter/searchhandlers/khc_htsearch.pl')
-rwxr-xr-xkhelpcenter/searchhandlers/khc_htsearch.pl117
1 files changed, 0 insertions, 117 deletions
diff --git a/khelpcenter/searchhandlers/khc_htsearch.pl b/khelpcenter/searchhandlers/khc_htsearch.pl
deleted file mode 100755
index 5dc3f5f71..000000000
--- a/khelpcenter/searchhandlers/khc_htsearch.pl
+++ /dev/null
@@ -1,117 +0,0 @@
-#!/usr/bin/perl
-
-use strict;
-
-use Encode;
-use Getopt::Long;
-
-use open IO => ':utf8';
-use open ':std';
-
-my $htsearchpath="/srv/www/cgi-bin/htsearch";
-my $config;
-my $format;
-my $method;
-my $words;
-my $lang;
-my $docbook;
-my $indexdir;
-my $maxnum;
-
-GetOptions (
- 'binary=s' => \$htsearchpath,
- 'config=s' => \$config,
- 'format=s' => \$format,
- 'method=s' => \$method,
- 'words=s' => \$words,
- 'lang=s' => \$lang,
- 'docbook' => \$docbook,
- 'indexdir=s' => \$indexdir,
- 'maxnum=s' => \$maxnum
-);
-
-if ( !$indexdir ) {
- print STDERR "No index dir given.\n";
- exit 1;
-}
-
-if ( !$lang ) { $lang = "en"; }
-
-my $charset = langCharset( $lang );
-
-$words = encode( $charset, $words );
-
-if ( !open( HTSEARCH, "-|", "$htsearchpath", "-c", "$indexdir/$config.conf",
- "format=$format&method=$method&words=$words&matchesperpage=$maxnum&exclude=[index.html]" ) )
-{
- print "Can't execute htsearch at '$htsearchpath'.\n";
- exit 1;
-}
-
-my ($body,$liststart,$ref,$link,$error,$errorOut);
-
-while( <HTSEARCH> ) {
- if ( !$body ) {
- print;
- if ( /^<body/ ) { $body = 1; }
- }
- if ( /^<h3>/ ) {
- print;
- print "<ul>\n";
- $liststart = 1;
- }
- if ( /^<img src.*<a href="(.*)">(.*)<\/a>/ ) {
- $ref = $1;
- $link = $2;
-
- print STDERR "REF: $ref LINK: $link\n";
-
- $ref =~ s/file:\/\/localhost//;
-
- $ref =~ s/http:\/\/localhost\//file:\//;
-
- if ( $docbook ) {
- $ref =~ /help:\/\/(.*)\/index.docbook/;
- my $app = $1;
- $ref = "help:$app";
-
- $link =~ s/apptitle/$app/;
- }
-
- print " <li><a href=\"$ref\">$link</a></li>\n";
- }
- if ( /^<h1>ht:\/\/Dig error/ ) {
- $error = 1;
- print "Htdig error:\n";
- }
- if ( $error && /^<pre>/ ) {
- $errorOut = 1;
- }
- if ( $errorOut ) {
- print;
- if ( /^<\/pre>/ ) { $errorOut = 0; }
- }
-}
-
-close HTSEARCH;
-
-if ( $liststart ) { print "</ul>\n"; }
-
-print "</body></html>\n";
-
-if ( $? != 0 ) { exit $?; }
-
-1;
-
-# Return charset used for given language
-sub langCharset( $ )
-{
- my $lang = shift;
- if ( $lang eq "cz" || $lang eq "hu" ) {
- return "latin2";
- } elsif ( $lang eq "kr" ) {
- return "utf8";
- } else {
- return "latin1";
- }
-}