3 # Wrapper script for creating search indices for htdig.
5 # This file is part of the SuSE help system.
7 # Copyright (C) 2002 SuSE Linux AG, Nuernberg
9 # Author: Cornelius Schumacher <cschum@suse.de>
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 2 of the License, or
14 # (at your option) any later version.
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write to the Free Software
23 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
29 my $htdigdata = "/srv/www/htdig/common/";
30 my $htdigbin = "/usr/bin";
31 my $kdeprefix = "@CMAKE_INSTALL_PREFIX@";
36 my ($indexdir, $docpath, $identifier, $lang, $help );
39 'indexdir=s' => \
$indexdir,
40 'docpath=s' => \
$docpath,
41 'identifier=s' => \
$identifier,
50 if ( !$indexdir || !$docpath || !$identifier ) {
51 print STDERR
"Missing arguments.\n";
55 if ( !$lang ) { $lang = "en"; }
57 &dbg
( "INDEXDIR: $indexdir" );
59 print "Creating index for <b>'$identifier'</b>\n";
61 my $htdigconf = $indexdir;
62 my $htdigdb = $indexdir;
64 my $conffile = "$htdigconf/$identifier.conf";
66 if ( !open( CONF
, ">$conffile" ) ) {
67 print STDERR
"Unable to open '$conffile' for writing.\n";
71 my $commondir = "$htdigdata/$lang";
72 if ( !$lang || !-e
$commondir ) {
73 $commondir = "$htdigdata/en";
75 if ( !-e
$commondir ) { $commondir = $htdigdata; }
78 if ( $lang eq "de" ) { $locale = "de_DE"; }
79 else { $locale = $lang; }
82 # htdig configuration for doc '$identifier'
84 # This file has been automatically created by KHelpcenter
86 common_dir
: $commondir
88 database_dir
: $htdigdb
89 local_urls
: http
://localhost
=
91 limit_urls_to
: http
://localhost
94 robotstxt_name
: kdedig
96 template_map
: Long long
$kdeprefix/share/apps/khelpcenter/searchhandlers
/htdig/htdig_long
.html
\\
97 Short short
$htdigdata/short
.html
98 search_algorithm
: exact
:1 prefix
:0.8
101 database_base
: \
${database_dir
}/$identifier
102 start_url
: http
://localhost
/$docpath
104 max_doc_size
: 5000000
105 external_parsers
: application
/pdf /usr
/share/doc/packages/htdig
/contrib/parse_doc
.pl application
/postscript /usr
/share/doc/packages/htdig
/contrib/parse_doc
.pl
106 #external_parsers: text/docbook /build/htdig/parser
115 my $ret = system( "$htdigbin/htdig", "-s", "-i", "-c", $conffile );
117 print STDERR
"htdig failed\n";
119 $ret = system( "$htdigbin/htmerge", "-c", $conffile );
120 if ( $ret != 0 ) { print STDERR
"htmerge failed\n"; }
124 my $existsfile = "$indexdir/$identifier.exists";
126 if ( !open( EXISTS
, ">$existsfile" ) ) {
127 print STDERR
"Unable to open '$existsfile' for writing.\n";
130 print EXISTS
"$identifier\n";
133 print "Finished successfully.\n";
140 $dbg && print STDERR
shift, "\n";
145 print "Usage: khc_htdig.pl --indexdir <indexdir> --docpath <path> ";
146 print "--identifier <identifier>\n";