diff options
author | Michele Calgaro <[email protected]> | 2020-02-09 19:43:10 +0900 |
---|---|---|
committer | Michele Calgaro <[email protected]> | 2020-02-09 19:58:36 +0900 |
commit | 620a999812c4612a48e41d1fd81d094e0667efc6 (patch) | |
tree | d9b51448800514c0815af0f4c1272b0178960668 /khelpcenter/searchhandlers/khc_beagle_search.pl | |
parent | d008372a5ab7d7a6157315553b3b36425e837cca (diff) | |
download | tdebase-620a999812c4612a48e41d1fd81d094e0667efc6.tar.gz tdebase-620a999812c4612a48e41d1fd81d094e0667efc6.zip |
Removed beagle related code.
Signed-off-by: Michele Calgaro <[email protected]>
(cherry picked from commit f16b630348b5b14c0a3c481be606185f31b6ef12)
Diffstat (limited to 'khelpcenter/searchhandlers/khc_beagle_search.pl')
-rw-r--r-- | khelpcenter/searchhandlers/khc_beagle_search.pl | 88 |
1 files changed, 0 insertions, 88 deletions
diff --git a/khelpcenter/searchhandlers/khc_beagle_search.pl b/khelpcenter/searchhandlers/khc_beagle_search.pl deleted file mode 100644 index d7a1f44b8..000000000 --- a/khelpcenter/searchhandlers/khc_beagle_search.pl +++ /dev/null @@ -1,88 +0,0 @@ -#!/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); |