source: trunk/gsdl/perllib/plugins/TOCPlug.pm@ 233

Last change on this file since 233 was 233, checked in by sjboddie, 25 years ago

Altered TOCPlug to work with new gdbm building code. It now reads
a toc.txt containing only the classification type and filename
of each document.

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 1.5 KB
Line 
1# This recursive plugin processes all files in a table of contents (toc.txt)
2# file. The toc.txt file should contain a list of filenames followed by
3# one or more subject classifications to which that document belongs. The
4# subject classifications should correspond to those in the first field
5# of the collections subject file if the Hierarchy classifier plugin is
6# being used.
7
8package TOCPlug;
9
10use plugin;
11use BasPlug;
12use lang;
13use doc;
14use util;
15use cfgread;
16
17sub BEGIN {
18 @ISA = ('BasPlug');
19}
20
21sub new {
22 my ($class) = @_;
23 $self = new BasPlug ();
24
25 return bless $self, $class;
26}
27
28# return 1 if this class might recurse using $pluginfo
29sub is_recursive {
30 my $self = shift (@_);
31
32 return 1;
33}
34
35# return 1 if processed, 0 if not processed
36# Note that $base_dir might be "" and that $file might
37# include directories
38sub read {
39 my $self = shift (@_);
40 my ($pluginfo, $base_dir, $file, $metadata, $processor) = @_;
41
42 my $tocfile = &util::filename_cat($base_dir, $file, "toc.txt");
43 if (!-f $tocfile) {
44 # not a directory containing a toc file
45 return 0;
46 }
47
48 # found a toc.txt file
49 print STDERR "TOCPlug: processing $tocfile\n";
50
51 # read in the toc.txt
52 my $list = &cfgread::read_cfg_file ($tocfile, undef, '^[^#]\w');
53
54 # process each document
55 foreach $docfile (keys (%$list)) {
56 # note that $list->{$docfile} is an array reference
57 $metadata->{'Subject'} = $list->{$docfile};
58 &plugin::read ($pluginfo, $base_dir, $docfile, $metadata, $processor);
59 }
60
61 return 1; # was processed
62}
63
64
651;
Note: See TracBrowser for help on using the repository browser.