delay a few things on startup, such as setting the visibility mode, which ensures...
[personal-kdebase.git] / runtime / khelpcenter / searchhandlers / khc_htdig.pl.cmake
blob511adc8359eb315146cdfe0b69cca8e345948bd1
1 #!/usr/bin/perl
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
25 use strict;
27 use Getopt::Long;
29 my $htdigdata = "/srv/www/htdig/common/";
30 my $htdigbin = "/usr/bin";
31 my $kdeprefix = "@CMAKE_INSTALL_PREFIX@";
32 chomp $kdeprefix;
34 my $dbg = 1;
36 my ($indexdir, $docpath, $identifier, $lang, $help );
38 GetOptions (
39 'indexdir=s' => \$indexdir,
40 'docpath=s' => \$docpath,
41 'identifier=s' => \$identifier,
42 'lang=s' => \$lang,
43 'help' => \$help,
46 if ( $help ) {
47 usage();
50 if ( !$indexdir || !$docpath || !$identifier ) {
51 print STDERR "Missing arguments.\n";
52 usage();
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";
68 exit 1;
71 my $commondir = "$htdigdata/$lang";
72 if ( !$lang || !-e $commondir ) {
73 $commondir = "$htdigdata/en";
75 if ( !-e $commondir ) { $commondir = $htdigdata; }
77 my $locale;
78 if ( $lang eq "de" ) { $locale = "de_DE"; }
79 else { $locale = $lang; }
81 print CONF << "EOT";
82 # htdig configuration for doc '$identifier'
84 # This file has been automatically created by KHelpcenter
86 common_dir: $commondir
87 locale: $locale
88 database_dir: $htdigdb
89 local_urls: http://localhost=
90 local_urls_only: true
91 limit_urls_to: http://localhost
92 ignore_noindex: true
93 max_hop_count: 4
94 robotstxt_name: kdedig
95 compression_level: 6
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
99 maximum_pages: 1
100 matches_per_page: 10
101 database_base: \${database_dir}/$identifier
102 start_url: http://localhost/$docpath
103 # for pdf-files
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
109 close CONF;
111 $ENV{ PATH } = '';
112 $ENV{ CDPATH } = '';
113 $ENV{ ENV } = '';
115 my $ret = system( "$htdigbin/htdig", "-s", "-i", "-c", $conffile );
116 if ( $ret != 0 ) {
117 print STDERR "htdig failed\n";
118 } else {
119 $ret = system( "$htdigbin/htmerge", "-c", $conffile );
120 if ( $ret != 0 ) { print STDERR "htmerge failed\n"; }
123 if ( $ret == 0 ) {
124 my $existsfile = "$indexdir/$identifier.exists";
126 if ( !open( EXISTS, ">$existsfile" ) ) {
127 print STDERR "Unable to open '$existsfile' for writing.\n";
128 exit 1;
130 print EXISTS "$identifier\n";
131 close EXISTS;
133 print "Finished successfully.\n";
136 exit $ret;
138 sub dbg($)
140 $dbg && print STDERR shift, "\n";
143 sub usage()
145 print "Usage: khc_htdig.pl --indexdir <indexdir> --docpath <path> ";
146 print "--identifier <identifier>\n";
147 exit 1;