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/
116 This plugin is now maintained by the Blosxom Sourceforge Team,
117 <blosxom-devel@lists.sourceforge.net>.
121 Blosxom Home/Docs/Licensing: http://blosxom.sourceforge.net/
123 Blosxom Plugin Docs: http://blosxom.sourceforge.net/documentation/users/plugins.html
127 None known; please send bug reports and feedback to the Blosxom
128 development mailing list <blosxom-devel@lists.sourceforge.net>.
132 Blosxom and this Blosxom Plug-in
133 Copyright 2003, Rael Dornfest
135 Permission is hereby granted, free of charge, to any person obtaining a
136 copy of this software and associated documentation files (the "Software"),
137 to deal in the Software without restriction, including without limitation
138 the rights to use, copy, modify, merge, publish, distribute, sublicense,
139 and/or sell copies of the Software, and to permit persons to whom the
140 Software is furnished to do so, subject to the following conditions:
142 The above copyright notice and this permission notice shall be included
143 in all copies or substantial portions of the Software.
145 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
146 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
147 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
148 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
149 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
150 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
151 OTHER DEALINGS IN THE SOFTWARE.