1 | #!/usr/local/bin/perl5 -w
|
---|
2 |
|
---|
3 | ###########################################################################
|
---|
4 | #
|
---|
5 | # gettext.pl --
|
---|
6 | # A component of the Greenstone digital library software
|
---|
7 | # from the New Zealand Digital Library Project at the
|
---|
8 | # University of Waikato, New Zealand.
|
---|
9 | #
|
---|
10 | # Copyright (C) 1999 New Zealand Digital Library Project
|
---|
11 | #
|
---|
12 | # This program is free software; you can redistribute it and/or modify
|
---|
13 | # it under the terms of the GNU General Public License as published by
|
---|
14 | # the Free Software Foundation; either version 2 of the License, or
|
---|
15 | # (at your option) any later version.
|
---|
16 | #
|
---|
17 | # This program is distributed in the hope that it will be useful,
|
---|
18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
20 | # GNU General Public License for more details.
|
---|
21 | #
|
---|
22 | # You should have received a copy of the GNU General Public License
|
---|
23 | # along with this program; if not, write to the Free Software
|
---|
24 | # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
25 | #
|
---|
26 | ###########################################################################
|
---|
27 |
|
---|
28 |
|
---|
29 | # This program will output the text for a particular index
|
---|
30 |
|
---|
31 | BEGIN {
|
---|
32 | die "GSDLHOME not set\n" unless defined $ENV{'GSDLHOME'};
|
---|
33 | die "GSDLOS not set\n" unless defined $ENV{'GSDLOS'};
|
---|
34 | unshift (@INC, "$ENV{'GSDLHOME'}/perllib");
|
---|
35 | unshift (@INC, "$ENV{'GSDLHOME'}/perllib/plugins");
|
---|
36 | }
|
---|
37 |
|
---|
38 | use parsargv;
|
---|
39 | use plugin;
|
---|
40 | use colcfg;
|
---|
41 | use util;
|
---|
42 |
|
---|
43 | sub print_usage {
|
---|
44 | print STDERR "\n usage: $0 collection-name\n";
|
---|
45 | print STDERR " options:\n";
|
---|
46 | print STDERR " -archivedir directory Where the archives live\n";
|
---|
47 | print STDERR " -mode infodb for gdbm database, defaults to text\n";
|
---|
48 | print STDERR " -index index The index to output\n\n";
|
---|
49 | }
|
---|
50 |
|
---|
51 |
|
---|
52 | &main ();
|
---|
53 |
|
---|
54 | sub main {
|
---|
55 |
|
---|
56 | if (!parsargv::parse(\@ARGV,
|
---|
57 | 'archivedir/.*/', \$archivedir,
|
---|
58 | 'index/.*/section:text', \$index,
|
---|
59 | 'mode/.*/text', \$mode)) {
|
---|
60 | &print_usage();
|
---|
61 | die "\n";
|
---|
62 | }
|
---|
63 |
|
---|
64 | # get and check the collection name
|
---|
65 | if (($collection = &util::use_collection(@ARGV)) eq "") {
|
---|
66 | &print_usage();
|
---|
67 | die "\n";
|
---|
68 | }
|
---|
69 |
|
---|
70 | # get the list of plugins for this collection
|
---|
71 | @plugins = ();
|
---|
72 | $configfilename = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "etc/collect.cfg");
|
---|
73 | if (-e $configfilename) {
|
---|
74 | $collectcfg = &colcfg::read_collect_cfg ($configfilename);
|
---|
75 | if (defined $collectcfg->{'plugins'}) {
|
---|
76 | @plugins = @{$collectcfg->{'plugins'}};
|
---|
77 | }
|
---|
78 | if (defined $collectcfg->{'archivedir'} && $archivedir eq "") {
|
---|
79 | $archivedir = $collectcfg->{'archivedir'};
|
---|
80 | }
|
---|
81 | } else {
|
---|
82 | die "Couldn't find the configuration file $configfilename\n";
|
---|
83 | }
|
---|
84 |
|
---|
85 | # fill in the default archives directories if none
|
---|
86 | # was supplied, turn all \ into / and remove trailing /
|
---|
87 | $archivedir = "$ENV{'GSDLCOLLECTDIR'}/archives" if $archivedir eq "";
|
---|
88 | $archivedir =~ s/[\\\/]+/\//g;
|
---|
89 | $archivedir =~ s/\/$//;
|
---|
90 |
|
---|
91 | # load all the plugins
|
---|
92 | $pluginfo = &plugin::load_plugins ($collection, \@plugins);
|
---|
93 | if (scalar(@$pluginfo) == 0) {
|
---|
94 | print STDERR "No plugins were loaded.\n";
|
---|
95 | die "\n";
|
---|
96 | }
|
---|
97 |
|
---|
98 | # load up the document processor for building
|
---|
99 | # if a buildproc class has been created for this collection, use it
|
---|
100 | # otherwise, use the mg buildproc
|
---|
101 | # if a builder class has been created for this collection, use it
|
---|
102 | # otherwise, use the mg builder
|
---|
103 | # load up the document processor for building
|
---|
104 | # if a buildproc class has been created for this collection, use it
|
---|
105 | # otherwise, use the mg buildproc
|
---|
106 | my ($buildprocdir, $buildproctype);
|
---|
107 | if (-e "$ENV{'GSDLCOLLECTDIR'}/perllib/${collection}buildproc.pm") {
|
---|
108 | $buildprocdir = "$ENV{'GSDLCOLLECTDIR'}/perllib";
|
---|
109 | $buildproctype = "${collection}buildproc";
|
---|
110 | } else {
|
---|
111 | $buildprocdir = "$ENV{'GSDLHOME'}/perllib";
|
---|
112 | $buildproctype = "mgbuildproc";
|
---|
113 | }
|
---|
114 | require "$buildprocdir/$buildproctype.pm";
|
---|
115 |
|
---|
116 | eval("\$buildproc = new $buildproctype(\$collection, " .
|
---|
117 | "\$archivedir, \"\$ENV{'GSDLCOLLECTDIR'}/building\", 1)");
|
---|
118 | die "$@" if $@;
|
---|
119 |
|
---|
120 | # set up the document processor
|
---|
121 | $buildproc->set_output_handle ('STDOUT');
|
---|
122 | $buildproc->set_mode ($mode);
|
---|
123 | $buildproc->set_index ($index);
|
---|
124 |
|
---|
125 | $buildproc->reset();
|
---|
126 |
|
---|
127 | # process the import directory
|
---|
128 | &plugin::read ($pluginfo, $archivedir,
|
---|
129 | "", {}, $buildproc);
|
---|
130 |
|
---|
131 | }
|
---|