Changeset 810 for trunk


Ignore:
Timestamp:
1999-12-07T10:45:27+13:00 (24 years ago)
Author:
sjboddie
Message:

plugins now take options, files are associated at build time as
well as import time

Location:
trunk/gsdl/perllib
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/perllib/colcfg.pm

    r780 r810  
    3434#
    3535# {'creator'}->string
    36 # {'maintainer'}->array of strings
    3736# {'public'}->string
    3837# {'beta'}->string
    39 # {'key'}->string
     38# {'defaultindex'}->string
     39# {'importdir'}->string
     40# {'archivedir'}->string
     41# {'cachedir'}->string
     42# {'builddir'}->string
     43# {'removeold'}->string
     44
     45# {'maintainer'}->array of strings
    4046# {'languages'}->array of strings
    41 # {'subcollection'}->hash of key-value pairs
    4247# {'indexsubcollections'}->array of strings
    4348# {'indexes'}->array of strings
    44 # {'defaultindex'}->string
    45 # {'plugins'}->array of strings
     49# {'dontbuild'}->array of strings
     50# {'dontgdbm'}->array of strings
     51
     52# {'subcollection'}->hash of key-value pairs
     53# {'collectionmeta'}->hash of key-value pairs
     54
     55# {'plugin'}->array of arrays of strings
     56# {'classify'}->array of arrays of strings
    4657
    4758sub read_collect_cfg {
     
    4960
    5061    return &cfgread::read_cfg_file ($filename,
    51             '^(creator|public|beta|key|defaultindex|importdir|' .
    52                     'archivedir|cachedir|builddir|textindex|removeold)$',
    53             '^(maintainer|languages|indexsubcollections|indexes|plugins|dontbuild|dontgdbm)$',
    54             '^(subcollection|collectionmeta)$');
     62                    q/^(creator|public|beta|defaultindex|importdir|/ .
     63                    q/archivedir|cachedir|builddir|removeold)$/,
     64                    q/(maintainer|languages|indexsubcollections|/ .
     65                       q/indexes|dontbuild|dontgdbm)$/,
     66                    q/^(subcollection|collectionmeta)$/,
     67                    q/^(plugin|classify)$/);
    5568}
    5669
     
    5972
    6073    &cfgread::write_cfg_file($filename, $data,
    61             '^(creator|public|beta|key|defaultindex|importdir|' .
    62                     'archivedir|cachedir|builddir|textindex|removeold)$',
    63             '^(maintainer|languages|indexsubcollections|indexes|plugins|dontbuild|dontgdbm)$',
    64             '^(subcollection|collectionmeta)$');
     74                 q/^(creator|public|beta|defaultindex|importdir|/ .
     75                 q/archivedir|cachedir|builddir|removeold)$/,
     76                 q/^(maintainer|languages|indexsubcollections|/ .
     77                 q/indexes|dontbuild|dontgdbm)$/,
     78                 q/^(subcollection|collectionmeta)$/,
     79                 q/^(plugin|classify)$/);
    6580}
    6681
     
    7994
    8095    return &cfgread::read_cfg_file ($filename,
    81             '^(builddate|numdocs|numwords|numbytes)$',
    82             '^(metadata|languages)$');
     96                    q/^(builddate|numdocs|numwords|numbytes)$/,
     97                    q/^(metadata|languages)$/);
    8398}
    8499
     
    87102
    88103    &cfgread::write_cfg_file($filename, $data,
    89             '^(builddate|numdocs|numwords|numbytes)$',
    90             '^(metadata|languages)$');
     104                 q/^(builddate|numdocs|numwords|numbytes)$/,
     105                 q/^(metadata|languages)$/);
    91106}
    92107
  • trunk/gsdl/perllib/docsave.pm

    r537 r810  
    100100    my @assoc_files = ();
    101101    foreach $assoc_file (@{$doc_obj->get_assoc_files()}) {
     102    my ($dir, $afile) = $assoc_file->[1] =~ /^(.*?)([^\/\\]+)$/;
     103    $dir = "" unless defined $dir;
    102104    if (-e $assoc_file->[0]) {
    103         my $afile = &util::filename_cat($archive_dir, $doc_dir, $assoc_file->[1]);
    104         &util::cp ($assoc_file->[0], $afile);
     105        my $filepath = &util::filename_cat($archive_dir, $doc_dir, $afile);
     106        &util::hard_link ($assoc_file->[0], $filepath);
    105107        $doc_obj->add_metadata ($doc_obj->get_top_section(),
    106108                    "gsdlassocfile",
    107                     "$assoc_file->[1]:$assoc_file->[2]");
     109                    "$afile:$assoc_file->[2]:$dir");
    108110    } else {
    109111        print STDERR "docsave::process couldn't copy the associated file " .
  • trunk/gsdl/perllib/mgbuilder.pm

    r784 r810  
    9393
    9494    # get the list of plugins for this collection
    95     my @plugins = (); # some good choice of plugins .... ????
    96     if (defined $self->{'collect_cfg'}->{'plugins'}) {
    97     @plugins = @{$self->{'collect_cfg'}->{'plugins'}};
     95    my $plugins = [];
     96    if (defined $self->{'collect_cfg'}->{'plugin'}) {
     97    $plugins = $self->{'collect_cfg'}->{'plugin'};
    9898    }
    9999   
    100 
    101100    # load all the plugins
    102     $self->{'pluginfo'} = &plugin::load_plugins ($collection, \@plugins);
     101    $self->{'pluginfo'} = &plugin::load_plugins ($plugins);
    103102    if (scalar(@{$self->{'pluginfo'}}) == 0) {
    104103    print STDERR "No plugins were loaded.\n";
     
    106105    }
    107106
     107    # get the list of classifiers for this collection
     108    my $classifiers = [];
     109    if (defined $self->{'collect_cfg'}->{'classify'}) {
     110    $classifiers = $self->{'collect_cfg'}->{'classify'};
     111    }
     112   
    108113    # load all the classifiers
    109     $self->{'classifiers'} = [];
    110     if (open (COLCFG, $colcfgname)) {
    111     while (defined ($line = &cfgread::read_cfg_line('mgbuilder::COLCFG'))) {
    112         if (scalar(@$line) >= 2) {
    113         my $key = shift (@$line);
    114         if ($key eq "classify") {
    115             my $classinfo = &classify::load_classifier($line);
    116             push (@{$self->{'classifiers'}}, $classinfo)
    117             if defined $classinfo;
    118         }
    119         }
    120     }
    121     close (COLCFG);
    122     } else {
    123     print STDERR "mgbuilder::new couldn't read the cfg file $colcfgname\n";
    124     print STDERR "               no classifiers were loaded\n";
    125     }
     114    $self->{'classifiers'} = &classify::load_classifiers ($classifiers);
    126115
    127116    # load up any dontgdbm fields
     
    560549    my $self = shift (@_);
    561550    my $textdir = &util::filename_cat($self->{'build_dir'}, "text");
     551    my $assocdir = &util::filename_cat($self->{'build_dir'}, "assoc");
    562552    &util::mk_all_dir ($textdir);
     553    &util::mk_all_dir ($assocdir);
    563554
    564555    # get db name
     
    572563    my $txt2db_exe = &util::filename_cat($exedir, "txt2db$exe");
    573564
    574     print STDERR "\n*** creating the info database\n" if ($self->{'verbosity'} >= 1);
     565    print STDERR "\n*** creating the info database and processing associated files\n"
     566    if ($self->{'verbosity'} >= 1);
    575567
    576568    # init all the classifiers
     
    590582    $self->{'buildproc'}->set_output_handle ($handle);
    591583    $self->{'buildproc'}->set_mode ('infodb');
     584    $self->{'buildproc'}->set_assocdir ($assocdir);
    592585    $self->{'buildproc'}->set_dontgdbm ($self->{'dontgdbm'});
    593586    $self->{'buildproc'}->set_classifiers ($self->{'classifiers'});
  • trunk/gsdl/perllib/mgbuildproc.pm

    r780 r810  
    5151    $self->{'classifiers'} = [];
    5252    $self->{'mode'} = "text";
     53    $self->{'assocdir'} = $build_dir;
    5354    $self->{'dontgdbm'} = {};
    5455    $self->{'index'} = "section:text";
     
    102103
    103104    $self->{'mode'} = $mode;
     105}
     106
     107sub set_assocdir {
     108    my $self = shift (@_);
     109    my ($assocdir) = @_;
     110
     111    $self->{'assocdir'} = $assocdir;
    104112}
    105113
     
    177185}
    178186
     187sub assoc_files {
     188    my $self = shift (@_);
     189    my ($doc_obj) = @_;
     190   
     191    foreach $assoc_file (@{$doc_obj->get_assoc_files()}) {
     192    $afile = &util::filename_cat($self->{'assocdir'}, $assoc_file->[1]);
     193    &util::hard_link ($assoc_file->[0], $afile);
     194    }
     195}
     196
    179197sub infodb {
    180198    my $self = shift (@_);
     
    183201#    $handle = "main::STDOUT";
    184202
     203    $self->assoc_files ($doc_obj);
     204
    185205    my $doctype = $doc_obj->get_doc_type();
    186206
     
    197217    my $doc_OID = $doc_obj->get_OID();
    198218    my $first = 1;
     219    my $url = "";
    199220    while (defined $section) {
    200221    # update a few statistics
     
    222243
    223244        if ($field ne "Identifier" && $field !~ /^gsdl/ &&
    224         defined $value && $value ne "" &&
    225         !defined $self->{'dontgdbm'}->{$field}) {
     245        defined $value && $value ne "") {
     246
    226247        # escape problematic stuff
    227248        $value =~ s/\\/\\\\/g;
    228249        $value =~ s/\n/\\n/g;
    229250        $value =~ s/\r/\\r/g;
    230        
    231         print $handle "<$field>$value\n";
    232         }
    233     }
    234 
     251
     252        # special case for URL metadata
     253        if ($field =~ /^URL$/i) {
     254                    $url .= "[$value]\n";
     255                    if ($section eq "") {$url .= "<section>$doc_OID\n";}
     256                    else {$url .= "<section>$doc_OID.$section\n";}
     257                    $url .= '-' x 70 . "\n";
     258        }
     259
     260        if (!defined $self->{'dontgdbm'}->{$field}) {
     261            print $handle "<$field>$value\n";
     262        }
     263        }
     264    }
     265   
    235266    # output archivedir if at top level
    236267    if ($section eq $doc_obj->get_top_section()) {
     
    242273        print $handle "<archivedir>$archivedir\n";
    243274    }
    244 
     275   
    245276    # output document display type
    246277    if ($first) {
     
    280311    else { print $handle "<section>$doc_OID.$section\n"; }
    281312    print $handle '-' x 70, "\n";
     313   
     314        # output entry for url
     315        if ($url ne "") {
     316            print $handle $url;
     317        }
    282318
    283319    $first = 0;
Note: See TracChangeset for help on using the changeset viewer.