Changeset 11122
- Timestamp:
- 2006-01-27T00:21:47+13:00 (18 years ago)
- Location:
- trunk/gsdl/perllib/plugins
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/perllib/plugins/BasPlug.pm
r11089 r11122 105 105 'type' => "string", 106 106 'reqd' => "no" }, 107 { 'name' => "associate_tail_re", 108 'desc' => "{BasPlug.associate_tail_re}", 109 'type' => "string", 110 'reqd' => "no" }, 107 111 { 'name' => "input_encoding", 108 112 'desc' => "{BasPlug.input_encoding}", … … 413 417 my $associate_ext = $self->{'associate_ext'}; 414 418 if ((defined $associate_ext) && ($associate_ext ne "")) { 415 my @exts = split(/,/,$associate_ext); 416 417 my %associate_ext_lookup = (); 418 foreach my $e (@exts) { 419 $associate_ext_lookup{$e} = 1; 420 } 421 422 $self->{'associate_ext_lookup'} = \%associate_ext_lookup; 419 420 my $associate_tail_re = $self->{'associate_tail_re'}; 421 if ((defined $associate_tail_re) && ($associate_tail_re ne "")) { 422 my $outhandle = $self->{'outhandle'}; 423 print $outhandle "Warning: can only specify 'associate_ext' or 'associate_tail_re'\n"; 424 print $outhandle " defaulting to 'associate_tail_re'\n"; 425 } 426 else { 427 my @exts = split(/,/,$associate_ext); 428 429 my @exts_bracketed = map { $_ = "(?:\\.$_)" } @exts; 430 my $associate_tail_re = join("|",@exts_bracketed); 431 $self->{'associate_tail_re'} = $associate_tail_re; 432 } 433 434 delete $self->{'associate_ext'}; 423 435 } 424 436 … … 545 557 return; 546 558 } 547 559 560 sub root_ext_split 561 { 562 my $self = shift (@_); 563 my ($filename,$tail_re) = @_; 564 565 my ($file_prefix,$file_ext) = ($filename =~ m/^(.*?)($tail_re)$/); 566 567 if ((!defined $file_prefix) || (!defined $file_ext)) { 568 ($file_prefix,$file_ext) = ($filename =~ m/^(.*)(\..*?)$/); 569 } 570 571 return ($file_prefix,$file_ext); 572 } 573 548 574 sub metadata_read { 549 575 my $self = shift (@_); 550 576 my ($pluginfo, $base_dir, $file, $metadata, $extrametakeys, $extrametadata, $processor, $maxdocs, $gli) = @_; 551 577 # Keep track of filenames with same root but different extensions 552 # Used to support -associate_ext 553 554 my $associate_ext = $self->{'associate_ext'}; 555 if ((defined $associate_ext) && ($associate_ext ne "")) { 556 557 my ($file_prefix,$file_ext) = ($file =~ m/^(.*)\.(.*?)$/); 578 # Used to support -associate_ext and the more generalised 579 # -associate_tail_re 580 581 my $associate_tail_re = $self->{'associate_tail_re'}; 582 if ((defined $associate_tail_re) && ($associate_tail_re ne "")) { 583 584 my ($file_prefix,$file_ext) 585 = $self->root_ext_split($file,$associate_tail_re); 586 558 587 if ((defined $file_prefix) && (defined $file_ext)) { 559 588 560 589 my $shared_fileroot = $self->{'shared_fileroot'}; 561 590 if (!defined $shared_fileroot->{$file_prefix}) { 562 my $file_prefix_rec = { 'tie_to' => undef, 'exts' => {} }; 591 my $file_prefix_rec = { 'tie_to' => undef, 592 'exts' => {} }; 563 593 $shared_fileroot->{$file_prefix} = $file_prefix_rec; 564 594 } … … 568 598 my $process_exp = $self->{'process_exp'}; 569 599 570 if ($file =~ m/$ self->{'process_exp'}/) {600 if ($file =~ m/$process_exp/) { 571 601 # This is the document the others should be tied to 572 602 $file_prefix_rec->{'tie_to'} = $file_ext; 573 603 } 574 604 else { 575 if ( defined $self->{'associate_ext_lookup'}->{$file_ext}) {605 if ($file_ext =~ m/$associate_tail_re$/) { 576 606 $file_prefix_rec->{'exts'}->{$file_ext} = 1; 577 607 } 578 608 } 579 } 580 } 581 609 610 } 611 } 612 582 613 # now check whether we are actually processing this 583 614 my $filename = $file; … … 630 661 631 662 my $has_file_ext = $exts->{$file_ext}; 632 663 633 664 if ($has_file_ext) { 634 665 return 1; … … 646 677 my ($file, $filename, $metadata) = @_; 647 678 648 my $associate_ext = $self->{'associate_ext'}; 649 650 651 return 0 if (!$associate_ext); 679 my $associate_tail_re = $self->{'associate_tail_re'}; 680 return 0 if (!$associate_tail_re); 652 681 653 682 # If file, see if matches with "tie_to" doc or is one of the 654 683 # associated filename extensions. 655 684 656 my ($file_prefix,$file_ext) = ($file =~ m/^(.*)\.(.*?)$/); 685 my ($file_prefix,$file_ext) = $self->root_ext_split($file,$associate_tail_re); 686 657 687 if ((defined $file_prefix) && (defined $file_ext)) { 658 688 … … 673 703 my ($full_prefix) = ($filename =~ m/^(.*)\..*?$/); 674 704 foreach my $e (keys %$exts) { 675 my $assoc_file = "$full_prefix.$e"; 705 my $assoc_file = "$full_prefix$e"; 706 print STDERR " $self->{'plugin_type'}: Associating $file_prefix$e with $file_prefix_rec->{'tie_to'} version\n"; 676 707 my $mime_type = ""; # let system auto detect this 677 708 push(@$assoc_tobe,"$assoc_file:$mime_type:"); 678 709 } 710 679 711 } 680 712 elsif ($self->tie_to_assoc_file($file_ext,$file_prefix_rec)) { 681 # a form of smart block 682 713 714 715 # a form of smart block 683 716 return 1; 684 717 } … … 724 757 } 725 758 } 759 726 760 if ($filename !~ /$self->{'process_exp'}/ || !-f $filename) { 727 761 return (undef,undef); # can't recognise … … 812 846 # include any metadata passed in from previous plugins 813 847 # note that this metadata is associated with the top level section 848 849 my $associate_tail_re = $self->{'associate_tail_re'}; 814 850 815 851 $self->extra_metadata ($doc_obj, $doc_obj->get_top_section(), $metadata); … … 1156 1192 my ($doc_obj, $cursection, $metadata) = @_; 1157 1193 1194 my $associate_tail_re = $self->{'associate_tail_re'}; 1195 1158 1196 foreach my $field (keys(%$metadata)) { 1159 1197 # $metadata->{$field} may be an array reference … … 1173 1211 1174 1212 $doc_obj->associate_file($full_filename,$tail_filename,$mimetype); 1175 1213 1214 # work out extended tail extension (i.e. matching tail re) 1215 1216 my ($file_prefix,$file_extended_ext) 1217 = $self->root_ext_split($tail_filename,$associate_tail_re); 1218 my ($pre_doc_ext) = ($file_extended_ext =~ m/^(.*)\..*$/); 1219 1176 1220 my ($doc_ext) = ($tail_filename =~ m/^.*\.(.*)$/); 1177 1221 my $start_doclink = "<a href=\"_httpcollection_/index/assoc/{Or}{[parent(Top):archivedir],[archivedir]}/$tail_filename\">"; … … 1179 1223 my $end_doclink = "</a>"; 1180 1224 1181 $equiv_form .= " $start_doclink\{If\}{$srcicon,$srcicon,$doc_ext\}$end_doclink"; 1225 my $assoc_form = "$start_doclink\{If\}{$srcicon,$srcicon,$doc_ext\}$end_doclink"; 1226 1227 if (defined $pre_doc_ext) { 1228 # for metadata such as [mp3._edited] [mp3._full] ... 1229 $doc_obj->add_utf8_metadata ($cursection, "$doc_ext.$pre_doc_ext", $assoc_form); 1230 } 1231 1232 # for multiple metadata such as [mp3.assoclink] 1233 $doc_obj->add_utf8_metadata ($cursection, "$doc_ext.assoclink", $assoc_form); 1234 1235 $equiv_form .= " $assoc_form"; 1182 1236 } 1183 1237 $doc_obj->add_utf8_metadata ($cursection, "equivlink", $equiv_form); -
trunk/gsdl/perllib/plugins/PDFPlug.pm
r10889 r11122 146 146 my $html_options = $secondary_plugin_options->{'HTMLPlug'}; 147 147 my $text_options = $secondary_plugin_options->{'TEXTPlug'}; 148 my $pagedimg_options = $secondary_plugin_options->{'PagedImgPlug'}; 148 149 149 150 if ($self->{'input_encoding'} eq "auto") { … … 179 180 push(@$html_options , "-title_sub", '^(Page\s+\d+)?(\s*1\s+)?'); 180 181 push(@$text_options , "-title_sub", '^(Page\s+\d+)?(\s*1\s+)?'); 182 183 my $associate_tail_re = $self->{'associate_tail_re'}; 184 if ((defined $associate_tail_re) && ($associate_tail_re ne "")) { 185 push(@$html_options, "-associate_tail_re", $associate_tail_re); 186 push(@$text_options, "-associate_tail_re", $associate_tail_re); 187 push(@$pagedimg_options, "-associate_tail_re", $associate_tail_re); 188 } 189 181 190 182 191 $self = bless $self, $class; -
trunk/gsdl/perllib/plugins/WordPlug.pm
r10769 r11122 152 152 my $html_options = $secondary_plugin_options->{'HTMLPlug'}; 153 153 my $text_options = $secondary_plugin_options->{'TextPlug'}; 154 154 my $structhtml_options = $secondary_plugin_options->{'StructuredHTMLPlug'}; 155 155 # wvWare will always produce html files encoded as utf-8, so make sure the secondary HTMLPlug knows this 156 156 push(@$html_options,"-input_encoding", "utf8"); 157 157 158 if ($self->{'input_encoding'} eq "auto") { 158 159 $self->{'input_encoding'} = "utf8"; … … 167 168 push(@$html_options,"-metadata_fields","Title,GENERATOR,date,author<Creator>"); 168 169 push(@$html_options , "-title_sub", '^(Page\s+\d+)?(\s*1\s+)?'); 170 171 my $associate_tail_re = $self->{'associate_tail_re'}; 172 if ((defined $associate_tail_re) && ($associate_tail_re ne "")) { 173 push(@$html_options, "-associate_tail_re", $associate_tail_re); 174 push(@$text_options, "-associate_tail_re", $associate_tail_re); 175 push(@$structhtml_options, "-associate_tail_re", $associate_tail_re); 176 } 169 177 170 178 $self = bless $self, $class;
Note:
See TracChangeset
for help on using the changeset viewer.