/[Grep]/bin/import.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /bin/import.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 154 - (show annotations)
Sun Jun 10 18:41:00 2007 UTC (16 years, 10 months ago) by dpavlin
File MIME type: text/plain
File size: 1224 byte(s)
starting to extend Grep so it can import data from local filesystem (for now
pages from ScrapBook fireFox plugin) and make them searchable
1 #!/usr/bin/perl
2
3 # helper script to import external data sources into local index and full text index
4
5 use strict;
6
7 use lib 'lib';
8
9 use Jifty;
10 use Grep::Search;
11 use Module::Pluggable search_path => 'Grep::Import', sub_name => 'importers', require => 1;
12 use Data::Dump qw/dump/;
13
14 $|=1;
15
16 BEGIN { Jifty->new; };
17
18 my @importers = __PACKAGE__->importers();
19
20 Jifty->log->debug("Found import plugins: ", join(", ", @importers) );
21
22 my $system_user = Grep::CurrentUser->superuser;
23 my $search = Grep::Search->new();
24
25
26 foreach my $importer ( @importers ) {
27
28 if ( $importer->can('import') ) {
29 Jifty->log->info("importing with $importer");
30 $importer->import( $search );
31 } else {
32 Jifty->log->error("importer $importer doesn't implement import");
33 }
34 }
35
36
37 __END__
38 my $coll = Grep::Model::ItemCollection->new( results_are_readable => 1, current_user => $system_user );
39 $coll->unlimit;
40
41 print "indexing ", $coll->count, " items ", $keep_duplicates ? "" : "removing duplicates ";
42
43 exit;
44
45
46 my ( $total ) = ( 0 );
47
48 while ( my $i = $coll->next ) {
49
50 print $i->id;
51
52 $search->add( $i, $i->in_feed->owner->id );
53 print ' ';
54 $total++;
55 }
56
57 print "$total records indexed", $duplicates ? "($duplicates duplicates)" : "", "\n";
58
59 $search->finish;

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26