Skip to content

Commit

Permalink
Item458: coonverted to Foswiki namespace and tested
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk/NativeSearchContrib@1326 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
CrawfordCurrie authored and CrawfordCurrie committed Dec 13, 2008
1 parent 235030b commit 3a1c6cd
Show file tree
Hide file tree
Showing 14 changed files with 52 additions and 69 deletions.
Expand Up @@ -14,8 +14,6 @@ By default Foswiki searches its database by [[http://en.wikipedia.org/wiki/Fork_

---++ Installation Instructions

If you are installing on a TWiki version before 4.1.2, please refer to TWiki:Codev.NativeSearch for instructions. Note that an old version of the package was pre-installed with 4.1.2; that pre-installation will be overwritten by this package.

Before you start, there are some prerequisites.
1 you must have =ExtUtils::MakeMaker= installed (available from CPAN)
1 you must have a C compiler (=gcc= has been tested). Most Unix/Linux systems will have this already. On Win32 !MinGW is recommended.
Expand All @@ -31,18 +29,18 @@ Before you start, there are some prerequisites.
$ cd tools/native_search
$ perl Makefile.PL
$ make install
$ perl test.pl -i -l NativeTWikiSearch test.pl Makefile.PL NativeTWikiSearch.xs
$ perl test.pl -i -l FoswikiNativeSearch test.pl Makefile.PL FoswikiNativeSearch.xs
</verbatim>
(on Win32 you should use =nmake=)

Make sure that =perl test.pl= returns something sane, and _NOT_ a
=Segmentation fault=.
(=test.pl= is simply a stub interface to the native search, so it behaves like =grep=. The test above simply greps for the string "NativeSearch" in the files Makefile.PL and !NativeTWikiSearch.xs)
(=test.pl= is simply a stub interface to the native search, so it behaves like =grep=. The test above simply greps for the string "NativeSearch" in the files Makefile.PL and !FoswikiNativeSearch.xs)

*If you do not have administrator (root) access to the server*, you can still
install. Follow the steps above, but use =perl Makefile.PL INSTALLBASE=/your/dir= to install to a different directory. Exactly where you install depends on your system configuration.

Now, in [[%SCRIPTURL{configure}%][configure]], under "Store Settings", you should be able to select the search algorithm =Foswiki::Store::SearchAlgorithms::Native= (click the <input type="button" style="background-color:#eef" value="Yes, I've read all the documentation"/> button first if you have TWiki 4.2 or later or Foswiki).
Now, in [[%SCRIPTURL{configure}%][configure]], under "Store Settings", you should be able to select the search algorithm =Foswiki::Store::SearchAlgorithms::Native= (click the <input type="button" style="background-color:#eef" value="Yes, I've read all the documentation"/> button first).

Run a Foswiki search, and watch the web server error log for any problems.

Expand All @@ -56,18 +54,14 @@ Many thanks to the following sponsors for supporting this work:
* Wind River Systems http://windriver.com

| Contrib Author(s): | Crawford Currie http://c-dot.co.uk |
| Copyright: | &copy; !WikiRing 2007 |
| Copyright: | &copy; Crawford Currie 2007-2008 |
| License: | [[http://www.gnu.org/licenses/gpl.html][GPL (Gnu General Public License)]] |
| Contrib Version: | %$VERSION% |
| Change History: | <!-- versions below in reverse order -->&nbsp; |
| Dependencies: | %$DEPENDENCIES% |
| Contrib Home: | http://twiki.org/cgi-bin/view/Plugins/NativeSearchContrib |
| Feedback: | http://twiki.org/cgi-bin/view/Plugins/NativeSearchContribDev |
| Appraisal: | http://twiki.org/cgi-bin/view/Plugins/NativeSearchContribAppraisal |

__Related Topics:__ [[%SYSTEMWEB%.Contribs][Contribs]], %SYSTEMWEB%.DeveloperDocumentationCategory, %SYSTEMWEB%.AdminDocumentationCategory, %SYSTEMWEB%.DefaultPreferences, %USERSWEB%.SitePreferences
| Contrib Home: | http://foswiki.org/Extensions/NativeSearchContrib |

<!-- Do _not_ attempt to edit this topic; it is auto-generated. Please add comments/questions/remarks to the feedback topic on twiki.org instead. -->
<!-- Do _not_ attempt to edit this topic; it is auto-generated. Please add comments/questions/remarks to the feedback topic on foswiki.org instead. -->

%META:FILEATTACHMENT{name="wikiringlogo20x20.png" attr="h" comment="" version="1"}%
%META:FILEATTACHMENT{name="logo.gif" attr="h" comment="" version="1"}%
Expand Up @@ -11,7 +11,7 @@
# GNU General Public License for more details, published at
# http://www.gnu.org/copyleft/gpl.html

package TWiki::Contrib::NativeSearchContrib;
package Foswiki::Contrib::NativeSearchContrib;

use strict;

Expand Down
@@ -1,5 +1,4 @@
# Dependencies for NativeSearchContrib
# Example:
# Time::ParseDate,>=2003.0211,cpan,Required.
# TWiki::Plugins,>=1.15,perl,TWiki 4.1 release.
ExtUtils::MakeMaker,>=0,cpan,Required for building makefiles
11 changes: 11 additions & 0 deletions lib/Foswiki/Contrib/NativeSearchContrib/MANIFEST
@@ -0,0 +1,11 @@
# Release manifest for NativeSearchContrib
data/System/NativeSearchContrib.txt 0644 Documentation
lib/Foswiki/Contrib/NativeSearchContrib.pm 0444
lib/Foswiki/Store/SearchAlgorithms/Native.pm 0444
tools/native_search/FoswikiNativeSearch.pm 0555
tools/native_search/cgrep.c 0555
tools/native_search/Makefile.PL 0555
tools/native_search/test.pl 0555
tools/native_search/FoswikiNativeSearch.xs 0555
pub/System/NativeSearchContrib/wikiringlogo20x20.png 0660
pub/System/NativeSearchContrib/logo.gif 0660
12 changes: 12 additions & 0 deletions lib/Foswiki/Contrib/NativeSearchContrib/build.pl
@@ -0,0 +1,12 @@
#!/usr/bin/perl -w
BEGIN {
unshift @INC, split( /:/, $ENV{FOSWIKI_LIBS} );
}
use Foswiki::Contrib::Build;

# Create the build object
$build = new Foswiki::Contrib::Build('NativeSearchContrib');

# Build the target on the command line, or the default target
$build->build($build->{target});

@@ -1,8 +1,12 @@
#
# Copyright (C) 2007 TWiki Contributors. All Rights Reserved.
# TWiki Contributors are listed in the AUTHORS file in the root
# Copyright (C) 2008 Foswiki Contributors. All Rights Reserved.
# Foswiki Contributors are listed in the AUTHORS file in the root
# of this distribution. NOTE: Please extend that file, not this notice.
#
# Additional copyrights apply to some or all of the code in this
# module, as follows:
# Copyright (C) 2007 TWiki Contributors. All Rights Reserved.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
Expand All @@ -15,14 +19,14 @@
#
# As per the GPL, removal of this notice is prohibited.
#
package TWiki::Store::SearchAlgorithms::Native;
package Foswiki::Store::SearchAlgorithms::Native;

use Assert;
use NativeTWikiSearch;
use FoswikiNativeSearch;

=pod
---+ package TWiki::Store::SearchAlgorithms::Native
---+ package Foswiki::Store::SearchAlgorithms::Native
Native implementation of the RCS cache search. Requires tools/native_search
to be built and installed.
Expand All @@ -49,7 +53,7 @@ sub search {
push(@fs, '-l') if $options->{files_without_match};
push(@fs, $searchString);
push(@fs, map { "$sDir/$_.txt" } @$topics);
my $matches = NativeTWikiSearch::cgrep(\@fs);
my $matches = FoswikiNativeSearch::cgrep(\@fs);
my %seen;
if (defined($matches)) {
for (@$matches) {
Expand Down
11 changes: 0 additions & 11 deletions lib/TWiki/Contrib/NativeSearchContrib/MANIFEST

This file was deleted.

26 changes: 0 additions & 26 deletions lib/TWiki/Contrib/NativeSearchContrib/build.pl

This file was deleted.

File renamed without changes
@@ -1,13 +1,13 @@
# Copyright (C) 2007 WikiRing http://wikiring.com All Rights Reserved
# Author: Crawford Currie
# Perl interface to NativeTWikiSearch xs module
package NativeTWikiSearch;
# Perl interface to FoswikiNativeSearch xs module
package FoswikiNativeSearch;

require Exporter;
require DynaLoader;
@ISA = qw(Exporter DynaLoader);
@EXPORT = qw( cgrep );

bootstrap NativeTWikiSearch;
bootstrap FoswikiNativeSearch;

1;
Expand Up @@ -81,7 +81,7 @@ void XS_pack_charPtrPtr(SV* st, char **s, int n) {
free(s);
}

MODULE = NativeTWikiSearch PACKAGE = NativeTWikiSearch
MODULE = FoswikiNativeSearch PACKAGE = FoswikiNativeSearch

char**
cgrep(argv)
Expand Down
6 changes: 3 additions & 3 deletions tools/native_search/Makefile.PL
@@ -1,8 +1,8 @@
# Makefile for NativeTWikiSearch module
# Makefile for FoswikiNativeSearch module
use ExtUtils::MakeMaker;
WriteMakefile(
NAME => 'NativeTWikiSearch',
OBJECT => 'NativeTWikiSearch.o cgrep.o',
NAME => 'FoswikiNativeSearch',
OBJECT => 'FoswikiNativeSearch.o cgrep.o',
LIBS => [ '-lpcre' ],
CCFLAGS => "-g",
LD => "gcc",
Expand Down
10 changes: 5 additions & 5 deletions tools/native_search/test.pl
@@ -1,15 +1,15 @@
#!/usr/bin/perl
# Test program for NativeTWikiSearch
# Test program for FoswikiNativeSearch
# If it is correctly installed, this program will accept parameters like grep
# e.g.
# perl test.pl -i -l NativeTWikiSearch test.pl Makefile.PL NativeTWikiSearch.xs
# perl test.pl -i -l FoswikiNativeSearch test.pl Makefile.PL FoswikiNativeSearch.xs
#
use NativeTWikiSearch;
use FoswikiNativeSearch;
die <<MOAN unless scalar(@ARGV);
I need parameters, like grep!
Try:
perl test.pl -i -l NativeTWikiSearch test.pl Makefile.PL NativeTWikiSearch.xs
perl test.pl -i -l FoswikiNativeSearch test.pl Makefile.PL FoswikiNativeSearch.xs
If it returns at least 3 filenames and doesn't crash, it worked.
MOAN
my $result = NativeTWikiSearch::cgrep(\@ARGV);
my $result = FoswikiNativeSearch::cgrep(\@ARGV);
print "RESULT\n".join("\n", @$result)."\n";

0 comments on commit 3a1c6cd

Please sign in to comment.