summaryrefslogtreecommitdiffstats
path: root/khelpcenter/searchhandlers
diff options
context:
space:
mode:
Diffstat (limited to 'khelpcenter/searchhandlers')
-rw-r--r--khelpcenter/searchhandlers/CMakeLists.txt44
-rw-r--r--khelpcenter/searchhandlers/Makefile.am10
-rw-r--r--khelpcenter/searchhandlers/README.searchhandlers61
-rw-r--r--khelpcenter/searchhandlers/docbook.desktop6
-rw-r--r--khelpcenter/searchhandlers/htdig.desktop6
-rw-r--r--khelpcenter/searchhandlers/htdig_long.html2
-rw-r--r--khelpcenter/searchhandlers/khc_beagle_index.pl49
-rw-r--r--khelpcenter/searchhandlers/khc_beagle_search.pl88
-rwxr-xr-xkhelpcenter/searchhandlers/khc_docbookdig.pl.in223
-rwxr-xr-xkhelpcenter/searchhandlers/khc_htdig.pl.in148
-rw-r--r--khelpcenter/searchhandlers/khc_htsearch.pl.in117
-rwxr-xr-xkhelpcenter/searchhandlers/khc_mansearch.pl84
-rw-r--r--khelpcenter/searchhandlers/man.desktop5
13 files changed, 843 insertions, 0 deletions
diff --git a/khelpcenter/searchhandlers/CMakeLists.txt b/khelpcenter/searchhandlers/CMakeLists.txt
new file mode 100644
index 000000000..9c2f7b527
--- /dev/null
+++ b/khelpcenter/searchhandlers/CMakeLists.txt
@@ -0,0 +1,44 @@
+#################################################
+#
+# (C) 2010-2011 Serghei Amelian
+# serghei (DOT) amelian (AT) gmail.com
+#
+# Improvements and feedback are welcome
+#
+# This file is released under GPL >= 2
+#
+#################################################
+
+set( prefix ${CMAKE_INSTALL_PREFIX} )
+if( NOT DEFINED HTDIG_SEARCH_BINARY )
+ message( STATUS "Looking for htsearch" )
+ find_program( HTDIG_SEARCH_BINARY htsearch
+ HINTS
+ /srv/www/cgi-bin
+ /usr/lib/cgi-bin
+ )
+ if( HTDIG_SEARCH_BINARY )
+ message( STATUS "Looking for htsearch - ${HTDIG_SEARCH_BINARY}" )
+ else( HTDIG_SEARCH_BINARY )
+ tde_message_fatal( "htsearch not found!\n Please, install htdig or set HTDIG_SEARCH_BINARY." )
+ endif( HTDIG_SEARCH_BINARY )
+endif( NOT DEFINED HTDIG_SEARCH_BINARY )
+
+configure_file( khc_docbookdig.pl.in khc_docbookdig.pl @ONLY )
+configure_file( khc_htdig.pl.in khc_htdig.pl @ONLY )
+configure_file( khc_htsearch.pl.in khc_htsearch.pl @ONLY )
+
+install( FILES
+ htdig.desktop man.desktop docbook.desktop
+ DESTINATION ${DATA_INSTALL_DIR}/khelpcenter/searchhandlers )
+
+install( PROGRAMS
+ ${CMAKE_CURRENT_BINARY_DIR}/khc_htdig.pl
+ ${CMAKE_CURRENT_BINARY_DIR}/khc_htsearch.pl
+ ${CMAKE_CURRENT_BINARY_DIR}/khc_docbookdig.pl
+ khc_beagle_search.pl khc_mansearch.pl khc_beagle_index.pl
+ DESTINATION ${BIN_INSTALL_DIR} )
+
+install( FILES
+ htdig_long.html
+ DESTINATION ${DATA_INSTALL_DIR}/khelpcenter/searchhandlers/htdig )
diff --git a/khelpcenter/searchhandlers/Makefile.am b/khelpcenter/searchhandlers/Makefile.am
new file mode 100644
index 000000000..f2ebd57ff
--- /dev/null
+++ b/khelpcenter/searchhandlers/Makefile.am
@@ -0,0 +1,10 @@
+searchhandlers_DATA = htdig.desktop man.desktop docbook.desktop
+
+searchhandlersdir = $(kde_datadir)/khelpcenter/searchhandlers
+
+kde_bin_SCRIPTS = khc_htdig.pl khc_htsearch.pl khc_mansearch.pl \
+ khc_docbookdig.pl khc_beagle_search.pl khc_beagle_index.pl
+
+htdigdata_DATA = htdig_long.html
+
+htdigdatadir = $(kde_datadir)/khelpcenter/searchhandlers/htdig
diff --git a/khelpcenter/searchhandlers/README.searchhandlers b/khelpcenter/searchhandlers/README.searchhandlers
new file mode 100644
index 000000000..cbbfbbbd7
--- /dev/null
+++ b/khelpcenter/searchhandlers/README.searchhandlers
@@ -0,0 +1,61 @@
+KHelpcenter Search Handlers
+===========================
+
+Searching documents in KHelpcenter is handled by document-type-specific search
+handlers. Each searchable document provides provides a document type in its meta
+data and if a corresponding handler is found, it can be searched.
+
+Search handlers are described by a desktop file which is put in the khelpcenter
+app directory in a "searchhandlers" directory. The desktop file contains the
+information about which document types the handler covers, how to do a search
+query and how to create a search index.
+
+A search handler has to provide a command line tool based interface. There has
+to be a command to do a query and, if previous creation of an index is required,
+a command to create a search index. The search commands returns its results as
+HTML on stdout.
+
+
+Search Query
+------------
+
+KHelpcenter reads the command to execute for submitting a search query from the
+search handler's desktop file ("SearchCommand"). The search command can contain
+some symbols which are replaced by KHelpcenter with the data for the concrete
+search request:
+
+%i Identifier of document (usually the name of the document's desktop file)
+%w Words to be searched for
+%o Operation for combining multiple search words. Allowed values: "and" and
+ "or".
+%m Maximum number of results
+%d Directory containing search indices
+
+Search Query Result
+-------------------
+
+The result has to be returned as HTML page. The content of the <body> tag will
+be extracted and inserted in the search results page. If there is no body tag,
+the complete result text will be inserted.
+
+
+Building a Search Index
+-----------------------
+
+KHelpcenter reads the command to build a search index from the search handler's
+desktop file ("IndexCommand"). The indexing command can contain some symbols
+which are replaced by KHelpcenter with the data for the concrete index creation
+call:
+
+%i Identifier of document (usually the name of the document's desktop file)
+%d Directory containing search indices
+%p Path to document to be indexed
+
+Index Creation Result
+---------------------
+
+As result of the indexing command an index is created in the directory specified
+by KHelpcenter. The format and structure of the index is handler-specific. When
+index creation is finished the indexing command has to create a special file
+with the name "<identifier>.exists", where <identifier> has to have the value
+passed by the %i symbol. This file indicates the existance of the index.
diff --git a/khelpcenter/searchhandlers/docbook.desktop b/khelpcenter/searchhandlers/docbook.desktop
new file mode 100644
index 000000000..08208c187
--- /dev/null
+++ b/khelpcenter/searchhandlers/docbook.desktop
@@ -0,0 +1,6 @@
+[Desktop Entry]
+
+DocumentTypes=text/docbook
+
+SearchCommand=khc_htsearch.pl --docbook --indexdir=%d --config=%i --words=%w --method=%o --maxnum=%m --lang=en
+IndexCommand=khc_docbookdig.pl --indexdir=%d --docpath=%p --identifier=%i
diff --git a/khelpcenter/searchhandlers/htdig.desktop b/khelpcenter/searchhandlers/htdig.desktop
new file mode 100644
index 000000000..08cff6ec2
--- /dev/null
+++ b/khelpcenter/searchhandlers/htdig.desktop
@@ -0,0 +1,6 @@
+[Desktop Entry]
+
+DocumentTypes=text/html
+
+SearchCommand=khc_htsearch.pl --indexdir=%d --config=%i --words=%w --method=%o --maxnum=%m --lang=%l
+IndexCommand=khc_htdig.pl --indexdir=%d --docpath=%p --identifier=%i --lang=%l
diff --git a/khelpcenter/searchhandlers/htdig_long.html b/khelpcenter/searchhandlers/htdig_long.html
new file mode 100644
index 000000000..a2e6e2188
--- /dev/null
+++ b/khelpcenter/searchhandlers/htdig_long.html
@@ -0,0 +1,2 @@
+$(STARSRIGHT) <a href="$&(URL)">$&(TITLE) ($(MODIFIED))</a><br>
+$(EXCERPT)<br>
diff --git a/khelpcenter/searchhandlers/khc_beagle_index.pl b/khelpcenter/searchhandlers/khc_beagle_index.pl
new file mode 100644
index 000000000..aaec63607
--- /dev/null
+++ b/khelpcenter/searchhandlers/khc_beagle_index.pl
@@ -0,0 +1,49 @@
+#!/usr/bin/perl
+# vim:sw=4:et
+
+use warnings;
+
+sub getKDEDocDir()
+{
+ my $prefix = `tde-config --prefix`;
+ chomp $prefix;
+
+ $prefix = "/opt/kde" if (not defined($prefix));
+ return "$prefix/share/doc";
+}
+
+sub addRoot()
+{
+ my $kdedocdir = &getKDEDocDir;
+
+ open (IN, "-|") || exec "beagle-config", "indexing", "ListRoots";
+
+ my $kdedoc_found = 0;
+ while(<IN>) {
+ if (/^$kdedocdir/o) {
+ $kdedoc_found = 1;
+ last;
+ }
+ }
+ close(IN);
+
+ if (not $kdedoc_found) {
+ `beagle-config indexing AddRoot $kdedocdir`;
+ `beagle-config indexing AddRoot $kdedocdir-bundle`;
+ }
+}
+
+sub createExistsFile($$)
+{
+ my ($idir, $ident) = @_;
+
+ open(OUT, ">", "$idir/$idir");
+ close(OUT);
+}
+
+my $idir = $ARGV[0];
+my $ident = $ARGV[1];
+
+if (addRoot) {
+ createExistsFile($idir, $ident);
+}
diff --git a/khelpcenter/searchhandlers/khc_beagle_search.pl b/khelpcenter/searchhandlers/khc_beagle_search.pl
new file mode 100644
index 000000000..d7a1f44b8
--- /dev/null
+++ b/khelpcenter/searchhandlers/khc_beagle_search.pl
@@ -0,0 +1,88 @@
+#!/usr/bin/perl -w
+# vim:sw=4:et
+
+use warnings;
+use strict;
+use Getopt::Long;
+
+sub isBeagleRunning()
+{
+ open(IN, "-|") || exec "beagle-ping";
+ while(<IN>) {
+ if (/^Daemon version:/) {
+ close(IN);
+ return 1;
+ }
+ }
+ close(IN);
+ return 0;
+}
+
+sub formatHTML($$)
+{
+ my ($query, $hits) = @_;
+
+ print "<html>\n<body\n<ul>\n";
+
+ foreach my $hit(@$hits) {
+ print "<li>$hit</li>\n";
+ }
+ print "</ul>\n</body>\n</html>\n";
+}
+
+sub beagleQuery($$$)
+{
+ my ($words, $method, $maxnum) = @_;
+
+ my @hits = ();
+
+ open(IN, "-|") || exec "beagle-query", "--type", "DocbookEntry", "--type", "File", "--max-hits", $maxnum, @$words, "ext:docbook";
+ while(<IN>) {
+ chop;
+ next if (/^Debug:/);
+
+ my $uri = $_;
+ $uri = $1 if ($uri =~ /^file:\/\/(.*)$/);
+
+ print "uri: $uri\n";
+ my $helpLink = &makeHelpLink($uri);
+
+ push(@hits, $helpLink) if (!grep { /^$helpLink$/ } @hits);
+ }
+ close(IN);
+ return @hits;
+}
+
+sub makeHelpLink($)
+{
+ # Try to figure out the name of the application from the path to its index.docbook file
+
+ my ($path) = @_;
+ my @pathcomponents = split '/', $path;
+
+ my $appName = $pathcomponents[-2];
+ my $appName2 = $pathcomponents[-3];
+
+ if ($appName eq $appName2 or $appName2 eq "doc"
+ or (-d "/usr/share/locale/$appName2")) {
+ return "<a href=\"help:/$appName\">$appName</a>";
+ }
+ return "<a href=\"help:/$appName2/$appName\">$appName ($appName2)</a>";
+}
+
+my $method = "and";
+my $maxnum = 100;
+
+GetOptions("method=s", \$method, "maxnum=i", \$maxnum);
+
+my @hits = ("The Beagle daemon is not running, search is not available");
+
+my @words = @ARGV;
+
+if (isBeagleRunning()) {
+ @hits = beagleQuery(\@words, $method, $maxnum);
+}
+
+@hits = ("There are no search results") if ($#hits < 0);
+
+formatHTML(\@words, \@hits);
diff --git a/khelpcenter/searchhandlers/khc_docbookdig.pl.in b/khelpcenter/searchhandlers/khc_docbookdig.pl.in
new file mode 100755
index 000000000..dfc826ab8
--- /dev/null
+++ b/khelpcenter/searchhandlers/khc_docbookdig.pl.in
@@ -0,0 +1,223 @@
+#!/usr/bin/perl
+#
+# Wrapper script for creating search indices for htdig.
+#
+# This file is part of KHelpcenter.
+#
+# Copyright (C) 2002 SuSE Linux AG, Nuernberg
+#
+# Author: Cornelius Schumacher <cschum@suse.de>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+use strict;
+
+use Getopt::Long;
+
+my $htdigdata = "/etc/htdig";
+my $htdigbin = "/usr/bin";
+my $kdeprefix = "@prefix@";
+my $kdehtmldir = `tde-config --expandvars --install html`;
+chomp $kdeprefix;
+chomp $kdehtmldir;
+
+my $dbg = 1;
+
+my ($indexdir, $docpath, $identifier, $lang, $help );
+
+GetOptions (
+ 'indexdir=s' => \$indexdir,
+ 'docpath=s' => \$docpath,
+ 'identifier=s' => \$identifier,
+ 'lang=s' => \$lang,
+ 'help' => \$help,
+);
+
+if ( $help ) {
+ usage();
+}
+
+if ( !$indexdir || !$docpath || !$identifier ) {
+ print STDERR "Missing arguments.\n";
+ usage();
+}
+
+&dbg( "INDEXDIR: $indexdir" );
+
+if ( !$lang ) { $lang = "en"; }
+
+my $tmpdir = "$indexdir/$identifier.tmp";
+if ( ! -e $tmpdir ) {
+ mkdir $tmpdir;
+}
+
+print "Creating index for <b>'$identifier'</b>\n";
+
+my $htdigconf = $indexdir;
+my $htdigdb = $indexdir;
+
+my $conffile = "$htdigconf/$identifier.conf";
+
+my $commondir = "$htdigdata/$lang";
+if ( !$lang || !-e $commondir ) {
+ $commondir = "$htdigdata/en";
+}
+if ( !-e $commondir ) { $commondir = $htdigdata; }
+
+my $locale;
+if ( $lang eq "de" ) { $locale = "de_DE"; }
+else { $locale = $lang; }
+
+my $startfile = "$tmpdir/index.html";
+
+if ( !open( START, ">$startfile" ) ) {
+ print STDERR "Unable to open '$startfile' for writing.\n";
+ exit 1;
+}
+
+$ENV{ PATH } = '/bin:/usr/bin';
+$ENV{ CDPATH } = '';
+$ENV{ ENV } = '';
+
+my $findpath = "$kdehtmldir/$lang/";
+my $findcmd = "find $findpath -name index.docbook";
+
+print STDERR "FINDCMD: $findcmd\n";
+
+if ( !open FIND, "$findcmd|" ) {
+ print STDERR "Unable to find docs.\n";
+ exit 1;
+}
+while ( <FIND> ) {
+ chomp;
+ my $path = $_;
+ $path =~ /$findpath(.*)\/index.docbook$/;
+ my $app = $1;
+ print START "<a href=\"help://$app/index.docbook\">$path</a>\n";
+}
+close START;
+
+my $mimetypefile = "$tmpdir/htdig_mime";
+if ( !open( MIME, ">$mimetypefile" ) ) {
+ print STDERR "Unable to open '$mimetypefile' for writing.\n";
+ exit 1;
+}
+print MIME << "EOT";
+text/html html
+text/docbook docbook
+EOT
+close MIME;
+
+my $parserfile = "$tmpdir/docbookparser";
+if ( !open( PARSER, ">$parserfile" ) ) {
+ print STDERR "Unable to open '$parserfile' for writing.\n";
+ exit 1;
+}
+print PARSER << "EOT";
+#! /bin/sh
+
+file=\$1
+shift
+mime=\$1
+shift
+
+if test "\$#" -gt 0; then
+ orig=\${1#file:/}
+ shift
+fi
+
+case "\$orig" in
+ help:/*)
+ orig=\${orig#help:/}
+ orig=\${orig%\/index.docbook}
+ cd $kdehtmldir/en/\$orig
+ file=index.docbook
+ ;;
+ *)
+ file=\$orig
+ cd `dirname \$orig`
+ ;;
+esac
+
+echo "t apptitle"
+$kdeprefix/bin/meinproc --htdig "\$file"
+EOT
+close PARSER;
+chmod 0755, $parserfile;
+
+if ( !open( CONF, ">$conffile" ) ) {
+ print STDERR "Unable to open '$conffile' for writing.\n";
+ exit 1;
+}
+print CONF << "EOT";
+# htdig configuration for doc '$identifier'
+#
+# This file has been automatically created by KHelpcenter
+common_dir: $commondir
+locale: $locale
+database_dir: $htdigdb
+database_base: \${database_dir}/$identifier
+local_urls: help://=$kdehtmldir/en/ file://=/
+local_urls_only: true
+limit_urls_to: file:// help:/
+ignore_noindex: true
+max_hop_count: 4
+robotstxt_name: kdedig
+compression_level: 6
+template_map: Long long $kdeprefix/share/apps/khelpcenter/searchhandlers/htdig/htdig_long.html
+search_algorithm: exact:1 prefix:0.8
+maximum_pages: 1
+matches_per_page: 10
+start_url: file://$tmpdir/index.html
+external_parsers: text/docbook $parserfile
+valid_extensions: .docbook .html
+mime_types: $mimetypefile
+EOT
+close CONF;
+
+my $ret = system( "$htdigbin/htdig", "-v", "-s", "-i", "-c", $conffile );
+if ( $ret != 0 ) {
+ print STDERR "htdig failed\n";
+} else {
+ $ret = system( "$htdigbin/htmerge", "-c", $conffile );
+ if ( $ret != 0 ) { print STDERR "htmerge failed\n"; }
+}
+
+if ( $ret == 0 ) {
+ my $existsfile = "$indexdir/$identifier.exists";
+
+ if ( !open( EXISTS, ">$existsfile" ) ) {
+ print STDERR "Unable to open '$existsfile' for writing.\n";
+ exit 1;
+ }
+ print EXISTS "$identifier\n";
+ close EXISTS;
+
+ print "Finished successfully.\n";
+}
+
+exit $ret;
+
+sub dbg($)
+{
+ $dbg && print STDERR shift, "\n";
+}
+
+sub usage()
+{
+ print "Usage: khc_docbookdig.pl --indexdir <indexdir> --docpath <path> ";
+ print "--identifier <identifier>\n";
+ exit 1;
+}
diff --git a/khelpcenter/searchhandlers/khc_htdig.pl.in b/khelpcenter/searchhandlers/khc_htdig.pl.in
new file mode 100755
index 000000000..a9eb25de6
--- /dev/null
+++ b/khelpcenter/searchhandlers/khc_htdig.pl.in
@@ -0,0 +1,148 @@
+#!/usr/bin/perl
+#
+# Wrapper script for creating search indices for htdig.
+#
+# This file is part of the SuSE help system.
+#
+# Copyright (C) 2002 SuSE Linux AG, Nuernberg
+#
+# Author: Cornelius Schumacher <cschum@suse.de>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+use strict;
+
+use Getopt::Long;
+
+my $htdigdata = "/etc/htdig";
+my $htdigbin = "/usr/bin";
+my $kdeprefix = "@prefix@";
+chomp $kdeprefix;
+
+my $dbg = 1;
+
+my ($indexdir, $docpath, $identifier, $lang, $help );
+
+GetOptions (
+ 'indexdir=s' => \$indexdir,
+ 'docpath=s' => \$docpath,
+ 'identifier=s' => \$identifier,
+ 'lang=s' => \$lang,
+ 'help' => \$help,
+);
+
+if ( $help ) {
+ usage();
+}
+
+if ( !$indexdir || !$docpath || !$identifier ) {
+ print STDERR "Missing arguments.\n";
+ usage();
+}
+
+if ( !$lang ) { $lang = "en"; }
+
+&dbg( "INDEXDIR: $indexdir" );
+
+print "Creating index for <b>'$identifier'</b>\n";
+
+my $htdigconf = $indexdir;
+my $htdigdb = $indexdir;
+
+my $conffile = "$htdigconf/$identifier.conf";
+
+if ( !open( CONF, ">$conffile" ) ) {
+ print STDERR "Unable to open '$conffile' for writing.\n";
+ exit 1;
+}
+
+my $commondir = "$htdigdata/$lang";
+if ( !$lang || !-e $commondir ) {
+ $commondir = "$htdigdata/en";
+}
+if ( !-e $commondir ) { $commondir = $htdigdata; }
+
+my $locale;
+if ( $lang eq "de" ) { $locale = "de_DE"; }
+else { $locale = $lang; }
+
+print CONF << "EOT";
+# htdig configuration for doc '$identifier'
+#
+# This file has been automatically created by KHelpcenter
+
+common_dir: $commondir
+locale: $locale
+database_dir: $htdigdb
+local_urls: http://localhost=
+local_urls_only: true
+limit_urls_to: http://localhost
+ignore_noindex: true
+max_hop_count: 4
+robotstxt_name: kdedig
+compression_level: 6
+template_map: Long long $kdeprefix/share/apps/khelpcenter/searchhandlers/htdig/htdig_long.html \\
+ Short short $htdigdata/short.html
+search_algorithm: exact:1 prefix:0.8
+maximum_pages: 1
+matches_per_page: 10
+database_base: \${database_dir}/$identifier
+start_url: http://localhost/$docpath
+# for pdf-files
+max_doc_size: 5000000
+external_parsers: application/pdf /usr/share/doc/packages/htdig/contrib/parse_doc.pl application/postscript /usr/share/doc/packages/htdig/contrib/parse_doc.pl
+#external_parsers: text/docbook /build/htdig/parser
+EOT
+
+close CONF;
+
+$ENV{ PATH } = '';
+$ENV{ CDPATH } = '';
+$ENV{ ENV } = '';
+
+my $ret = system( "$htdigbin/htdig", "-s", "-i", "-c", $conffile );
+if ( $ret != 0 ) {
+ print STDERR "htdig failed\n";
+} else {
+ $ret = system( "$htdigbin/htmerge", "-c", $conffile );
+ if ( $ret != 0 ) { print STDERR "htmerge failed\n"; }
+}
+
+if ( $ret == 0 ) {
+ my $existsfile = "$indexdir/$identifier.exists";
+
+ if ( !open( EXISTS, ">$existsfile" ) ) {
+ print STDERR "Unable to open '$existsfile' for writing.\n";
+ exit 1;
+ }
+ print EXISTS "$identifier\n";
+ close EXISTS;
+
+ print "Finished successfully.\n";
+}
+
+exit $ret;
+
+sub dbg($)
+{
+ $dbg && print STDERR shift, "\n";
+}
+
+sub usage()
+{
+ print "Usage: khc_htdig.pl --indexdir <indexdir> --docpath <path> ";
+ print "--identifier <identifier>\n";
+ exit 1;
+}
diff --git a/khelpcenter/searchhandlers/khc_htsearch.pl.in b/khelpcenter/searchhandlers/khc_htsearch.pl.in
new file mode 100644
index 000000000..28113bec2
--- /dev/null
+++ b/khelpcenter/searchhandlers/khc_htsearch.pl.in
@@ -0,0 +1,117 @@
+#!/usr/bin/perl
+
+use strict;
+
+use Encode;
+use Getopt::Long;
+
+use open IO => ':utf8';
+use open ':std';
+
+my $htsearchpath="@HTDIG_SEARCH_BINARY@";
+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";
+ }
+}
diff --git a/khelpcenter/searchhandlers/khc_mansearch.pl b/khelpcenter/searchhandlers/khc_mansearch.pl
new file mode 100755
index 000000000..a68fde752
--- /dev/null
+++ b/khelpcenter/searchhandlers/khc_mansearch.pl
@@ -0,0 +1,84 @@
+#!/usr/bin/perl
+#
+# Script for searching man pages. The result is generated as HTML.
+#
+# This file is part of KHelpcenter.
+#
+# Copyright (C) 2002 SuSE Linux AG, Nuernberg
+#
+# Author: Cornelius Schumacher <cschum@suse.de>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+use strict;
+
+use Getopt::Long;
+
+my ( $words, $maxcount, $lang, $help );
+
+GetOptions (
+ 'maxcount=s' => \$maxcount,
+ 'words=s' => \$words,
+ 'lang=s' => \$lang,
+ 'help' => \$help
+);
+
+if ( $help ) {
+ print STDERR "Usage: khc_mansearch.pl --maxcount=n --words=<string> " .
+ "--lang=<languagecode>\n";
+ exit 1;
+}
+
+if ( !$words ) {
+ print STDERR "No search words given.\n";
+ exit;
+}
+
+# Perform search
+if ( !open( MAN, "-|", "apropos", $words ) ) {
+ print "Can't open apropos.\n";
+ exit 1;
+}
+my @results;
+while( <MAN> ) {
+# print "RAW:$_";
+ chop;
+ /^([^\s]+)\s+\((.*)\)\s+-\s+(.*)$/;
+ my $page = $1;
+ my $section = $2;
+ my $description = $3;
+
+ if ( $page ) { push @results, [ $page, $section, $description ]; }
+}
+close MAN;
+
+my $nummatches = @results;
+
+if ( $nummatches > 0 ) {
+ print "<ul>\n";
+
+ my $count = 0;
+ for my $result ( @results ) {
+ my ( $page, $section, $description ) = @$result;
+ my $url = "man:" . $page;
+ print "<li><a href=\"$url\">";
+ print "$page - $description</a></li>\n";
+ if ( ++$count == $maxcount ) { last; }
+ }
+
+ print "</ul>\n";
+}
+
+1;
diff --git a/khelpcenter/searchhandlers/man.desktop b/khelpcenter/searchhandlers/man.desktop
new file mode 100644
index 000000000..f9274384e
--- /dev/null
+++ b/khelpcenter/searchhandlers/man.desktop
@@ -0,0 +1,5 @@
+[Desktop Entry]
+
+DocumentTypes=text/man
+
+SearchCommand=khc_mansearch.pl --words=%w --maxcount=%m