1 # Blosxom Plugin: lucene
2 # Author(s): Rael Dornfest <rael@oreilly.com>
3 # and Sam Ruby <rubys@intertwingly.net>
5 # Documentation: See the bottom of this file or type: perldoc lucene
9 # --- Configurable variables -----
11 # Turn on the Lucene engine (set to 1 only once the other bits are in place)?
15 my $JAVA_HOME = '/path/to/j2sdk1.3.1/';
18 my $lucene = '/path/to/lib/java/*.jar';
21 my $index = '/Library/WebServer/Data/lucene';
23 # --------------------------------
27 use CGI qw/:standard/;
30 use POSIX qw(strftime);
31 use Env qw(@PATH @CLASSPATH);
33 unshift @PATH, "$JAVA_HOME/bin";
34 push @CLASSPATH, "$JAVA_HOME/lib/tools.jar";
35 push @CLASSPATH, "$JAVA_HOME/jre/lib/rt.jar";
36 push @CLASSPATH, "/any/other/appropriate/java/lib";
37 push @CLASSPATH, glob($lucene);
40 $lucene_on or return 0;
41 $blosxom::static_or_dynamic eq 'dynamic' or return 0;
42 param('q') or return 0;
43 $search = "Search results for: " . param('q');
51 my $query = uri_escape(param('q'));
54 # Take a gander at what Lucene came up with based upon the search criteria
55 foreach (`$JAVA_HOME/bin/java -cp $ENV{CLASSPATH} LuceneSearch $index $query`) {
58 $_ =~ /\.txt$/ and $files{"$blosxom::datadir/$_"} = stat("$blosxom::datadir/$_")->mtime;
61 return (\%files, \%indexes);
71 Blosxom Plug-in: lucene
75 Based upon: http://radio.weblogs.com/0101679/stories/2002/08/13/luceneSearchFromBlosxom.html
77 Purpose: Lucene [http://jakarta.apache.org/lucene/] is a fabulous
78 text search engine written in Java. This plug-in hooks in the results
79 of a Lucene search, displaying only the stories matching the search query
80 (as specified by ?q=keywords).
82 Populates $lucene::search with "Search results for: keywords" for use in
85 Replaces the default $blosxom::entries subroutine. You'd best put it before
86 any other plug-ins that override the default $blosxom::entries subroutine.
87 When ?q=keywords turns on the lucene plug-in, it'll then be used instead of
88 whatever other entries overrides you have down the chain.
90 E.g. My setup is as follows:
102 This plug-in could be used as a template for hooking into just about any
103 files-based text search engine.
109 Version number coincides with the version of Blosxom with which the
110 current version was first bundled.
114 Rael Dornfest <rael@oreilly.com>, http://www.raelity.org/
118 Blosxom Home/Docs/Licensing: http://www.raelity.org/apps/blosxom/
120 Blosxom Plugin Docs: http://www.raelity.org/apps/blosxom/plugin.shtml
124 Address bug reports and comments to the Blosxom mailing list
125 [http://www.yahoogroups.com/group/blosxom].
129 Blosxom and this Blosxom Plug-in
130 Copyright 2003, Rael Dornfest
132 Permission is hereby granted, free of charge, to any person obtaining a
133 copy of this software and associated documentation files (the "Software"),
134 to deal in the Software without restriction, including without limitation
135 the rights to use, copy, modify, merge, publish, distribute, sublicense,
136 and/or sell copies of the Software, and to permit persons to whom the
137 Software is furnished to do so, subject to the following conditions:
139 The above copyright notice and this permission notice shall be included
140 in all copies or substantial portions of the Software.
142 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
143 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
144 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
145 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
146 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
147 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
148 OTHER DEALINGS IN THE SOFTWARE.