Changeset 900


Ignore:
Timestamp:
2000-02-03T10:06:40+13:00 (24 years ago)
Author:
sjboddie
Message:

tweaked the way associated files are handled at build time - some
individual plugins may still need catching up.

Location:
trunk/gsdl/perllib
Files:
4 edited

Legend:

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

    r810 r900  
    3434use docproc;
    3535use util;
    36 
    3736
    3837BEGIN {
     
    187186sub assoc_files {
    188187    my $self = shift (@_);
    189     my ($doc_obj) = @_;
     188    my ($doc_obj, $archivedir) = @_;
     189    my ($afile);
    190190   
    191     foreach $assoc_file (@{$doc_obj->get_assoc_files()}) {
    192     $afile = &util::filename_cat($self->{'assocdir'}, $assoc_file->[1]);
     191    foreach my $assoc_file (@{$doc_obj->get_assoc_files()}) {
     192    # if assoc file contains directory structure of
     193    # its own use it, otherwise use HASH... directory
     194    if ($assoc_file->[1] =~ /[\/\\]/) {
     195        $afile = &util::filename_cat($self->{'assocdir'}, $assoc_file->[1]);
     196    } else {
     197        $afile = &util::filename_cat($self->{'assocdir'}, $archivedir, $assoc_file->[1]);
     198    }
    193199    &util::hard_link ($assoc_file->[0], $afile);
    194200    }
     
    201207#    $handle = "main::STDOUT";
    202208
    203     $self->assoc_files ($doc_obj);
    204 
    205209    my $doctype = $doc_obj->get_doc_type();
    206210
    207211    # only output this document if it is one to be indexed
    208212    return if ($doctype ne "indexed_doc");
     213
     214    my ($archivedir) = $filename =~ /^(.*?)(?:\/|\\)[^\/\\]*$/;
     215    $archivedir = "" unless defined $archivedir;
     216    $archivedir =~ s/\\/\//g;
     217    $archivedir =~ s/^\/+//;
     218    $archivedir =~ s/\/+$//;
     219
     220    $self->assoc_files ($doc_obj, $archivedir);
    209221
    210222    # this is another document
     
    239251    # output all the section metadata
    240252    my $metadata = $doc_obj->get_all_metadata ($section);
    241     foreach $pair (@$metadata) {
     253    foreach my $pair (@$metadata) {
    242254        my ($field, $value) = (@$pair);
    243255
     
    266278    # output archivedir if at top level
    267279    if ($section eq $doc_obj->get_top_section()) {
    268         my ($archivedir) = $filename =~ /^(.*?)(?:\/|\\)[^\/\\]*$/;
    269         $archivedir = "" unless defined $archivedir;
    270         $archivedir =~ s/\\/\//g;
    271         $archivedir =~ s/^\/+//;
    272         $archivedir =~ s/\/+$//;
    273280        print $handle "<archivedir>$archivedir\n";
    274281    }
     
    285292        print $handle "<contains>";
    286293        my $firstchild = 1;
    287         foreach $child (@$children) {
     294        foreach my $child (@$children) {
    288295        print $handle ";" unless $firstchild;
    289296        $firstchild = 0;
     
    348355
    349356    # see if this document belongs to this subcollection
    350     foreach $indexexp (@{$self->{'indexexparr'}}) {
     357    foreach my $indexexp (@{$self->{'indexexparr'}}) {
    351358    $indexed_doc = 0;
    352359    my ($field, $exp, $options) = split /\//, $indexexp;
     
    397404    if ($indexed_doc) {
    398405        $self->{'num_bytes'} += $doc_obj->get_text_length ($section);
    399         foreach $field (split (/,/, $fields)) {
     406        foreach my $field (split (/,/, $fields)) {
    400407        # only deal with this field if it doesn't start with top or
    401408        # this is the first section
  • trunk/gsdl/perllib/plugins/GMLPlug.pm

    r863 r900  
    171171    # add the associated files
    172172    $assoc_files = $doc_obj->get_metadata($doc_obj->get_top_section(), "gsdlassocfile");
    173     my ($assoc_file_info);
     173    my ($assoc_file_info, $afile);
    174174    foreach $assoc_file_info (@$assoc_files) {
    175175        my ($assoc_file, $mime_type, $dir) = split (":", $assoc_file_info);
    176         $dir = "" unless defined $dir;
     176        if (defined $dir && $dir =~ /\w/) {
     177        $afile = &util::filename_cat($dir, $assoc_file);
     178        } else {
     179        $afile = $assoc_file;
     180        }
    177181        $doc_obj->associate_file(&util::filename_cat($parent_dir, $assoc_file),
    178                      &util::filename_cat($dir, $assoc_file), $mime_type);
     182                     $afile, $mime_type);
    179183    }
    180184    $doc_obj->delete_metadata($doc_obj->get_top_section(), "gsdlassocfile");
  • trunk/gsdl/perllib/plugins/HBPlug.pm

    r796 r900  
    141141    # fix up the image links
    142142    $section =~ s/<img[^>]*?src=\"?([^\">]+)\"?[^>]*>/
    143     <center><img src=\"_httpcollection_\/archives\/_thisOID_\/$1\"><\/center><br>/ig;
     143    <center><img src=\"_httpcollimg_\/_thisOID_\/$1\"><\/center><br>/ig;
    144144    $section =~ s/&lt;&lt;I&gt;&gt;\s*([^\.]+\.(png|jpg|gif))/
    145     <center><img src=\"_httpcollection_\/archives\/_thisOID_\/$1\"><\/center><br>/ig;
     145    <center><img src=\"_httpcollimg_\/_thisOID_\/$1\"><\/center><br>/ig;
    146146
    147147    return $section;
  • trunk/gsdl/perllib/plugins/HTMLPlug.pm

    r897 r900  
    7171    print STDERR "   -w3mir                 Set if w3mir was used to generate input file structure.\n";
    7272    print STDERR "                          w3mir \n";
     73    print STDERR "   -rename_assoc_files    Renames files associated with documents (e.g. images). Also\n";
     74    print STDERR "                          creates much shallower directory structure (useful when creating\n";
     75    print STDERR "                          collections to go on cd-rom).\n\n";
    7376}
    7477
     
    8487             q^no_metadata^, \$self->{'no_metadata'},
    8588             q^metadata_fields/.*/Title^, \$self->{'metadata_fields'},
    86              q^w3mir^, \$self->{'w3mir'})) {
     89             q^w3mir^, \$self->{'w3mir'},
     90             q^rename_assoc_files^, \$self->{'rename_assoc_files'})) {
    8791    &print_usage();
    8892    die "\n";
     
    243247    $filename = &util::filename_cat ($base_dir, $filename);
    244248    my ($ext) = $filename =~ /(\.[^\.]*)$/;
    245     if (defined $self->{'aux_files'}->{$href}) {
    246     $newname = $self->{'aux_files'}->{$href}->{'dir_num'} . "/" .
    247         $self->{'aux_files'}->{$href}->{'file_num'} . $ext;
     249    if ($self->{'rename_assoc_files'}) {
     250    if (defined $self->{'aux_files'}->{$href}) {
     251        $newname = $self->{'aux_files'}->{$href}->{'dir_num'} . "/" .
     252        $self->{'aux_files'}->{$href}->{'file_num'} . $ext;
     253    } else {
     254        $newname = $self->{'dir_num'} . "/" . $self->{'file_num'} . $ext;
     255        $self->inc_filecount ();
     256    }
     257    $doc_obj->associate_file($filename, $newname, undef, $section);
     258    return "_httpcollimg_/$newname";
     259
    248260    } else {
    249     $newname = $self->{'dir_num'} . "/" . $self->{'file_num'} . $ext;
    250     $self->inc_filecount ();
    251     }
    252     $doc_obj->associate_file($filename, $newname, undef, $section);
    253     return "_httpcollimg_/$newname";
     261    ($newname) = $filename =~ /([^\/\\]*)$/;
     262    $doc_obj->associate_file($filename, $newname, undef, $section);
     263    return "_httpcollimg_/_thisOID_/$newname";
     264    }
    254265}
    255266
Note: See TracChangeset for help on using the changeset viewer.