Changeset 732 for trunk/gsdl


Ignore:
Timestamp:
1999-10-20T17:23:48+13:00 (25 years ago)
Author:
sjboddie
Message:

prevent from overriding Title metadata that may have been passed
in from another plugin (e.g. IndexPlug)

Location:
trunk/gsdl/perllib/plugins
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/perllib/plugins/HTMLPlug.pm

    r721 r732  
    263263    $text =~ s/\s+/ /g;
    264264
    265     # see if there's a <title> tag
    266265    my $foundtitle = 0;
    267     if ($text =~ /<title[^>]*>([^<]*)<\/title[^>]*>/i) {
    268     if (defined $1) {
    269         my $title = $1;
    270         if ($title =~ /\w/) {
    271         $doc_obj->add_metadata ($cursection, "Title", $title);
    272         $foundtitle = 1;
     266    # don't use title tag if Title has been passed
     267    # in from another plugin
     268    if (defined $metadata->{'Title'}) {
     269    $foundtitle = 1;
     270    }
     271    if (!$foundtitle) {
     272    # see if there's a <title> tag
     273    if ($text =~ /<title[^>]*>([^<]*)<\/title[^>]*>/i) {
     274        if (defined $1) {
     275        my $title = $1;
     276        if ($title =~ /\w/) {
     277            $doc_obj->add_metadata ($cursection, "Title", $title);
     278            $foundtitle = 1;
     279        }
    273280        }
    274281    }
  • trunk/gsdl/perllib/plugins/TEXTPlug.pm

    r639 r732  
    8282    my $text = "";
    8383    my $line = "";
    84     my $first = 1;
     84    my $foundtitle = 0;
     85    # don't need to get title if it has been passed
     86    # in from another plugin
     87    if (defined $metadata->{'Title'}) {
     88    $foundtitle = 1;
     89    }
    8590    while (defined ($line = <FILE>)) {
    8691    # use first line as title (or first 100 characters if it's long)
    87     if ($first && length($line) > 5) {
     92    if (!$foundtitle && length($line) > 5) {
    8893        my $title = "";
    8994        if (length($line) > 100) {
     
    9398        }
    9499        $doc_obj->add_metadata ($cursection, "Title", $title);
    95         $first = 0;
     100        $foundtitle = 1;
    96101    }
    97102    $text .= $line;
Note: See TracChangeset for help on using the changeset viewer.