Changeset 1410

Show
Ignore:
Timestamp:
16.08.2000 17:48:49 (19 years ago)
Author:
davidb
Message:

Introduction of "ConvertTo?" family of plugins. This establishes
a new inheritance hierarchy.

BasPlug? -> ConvertToBasPlug? -> HTMLPlug/TEXTPlug -> ConvertToPlug?

-> PDFPlug/WordPlug/Future application plugins

Location:
trunk/gsdl/perllib/plugins
Files:
4 added
2 modified

Legend:

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

    r1403 r1410  
    3838package HTMLPlug; 
    3939 
    40 use BasPlug; 
     40use ConvertToBasPlug; 
    4141use ghtml; 
    4242use util; 
     
    4444 
    4545sub BEGIN { 
    46     @ISA = ('BasPlug'); 
     46    @ISA = ('ConvertToBasPlug'); 
    4747} 
    4848 
     
    6767    print STDERR "                          creates much shallower directory structure (useful when creating\n"; 
    6868    print STDERR "                          collections to go on cd-rom).\n\n"; 
     69    print STDERR "   -title_sub             Substitution expression to modify string stored as Title.\n"; 
     70    print STDERR "                          Used by, for example, PDFHtml to remove Page 1 etc from text\n"; 
     71    print STDERR "                          chosen to be used as the title.\n"; 
    6972} 
    7073 
    7174sub new { 
    7275    my $class = shift (@_); 
    73     my $self = new BasPlug ("HTMLPlug", @_); 
     76    my $self = new ConvertToBasPlug ($class, @_); 
    7477 
    7578    if (!parsargv::parse(\@_,  
     
    8184             q^assoc_files/.*/(?i)\.(jpe?g|gif|png|css|pdf)$^, \$self->{'assoc_files'}, 
    8285             q^rename_assoc_files^, \$self->{'rename_assoc_files'}, 
     86             q^title_sub/.*/^, \$self->{'title_sub'}, 
    8387             "allow_extra_options")) { 
    8488 
     
    9195    $self->{'dir_num'} = 0; 
    9296    $self->{'file_num'} = 0; 
    93      
     97 
     98    $self->{'convert_to'} = "HTML"; 
     99    $self->{'convert_to_ext'} = "html"; 
     100 
    94101    return bless $self, $class; 
    95102} 
     
    222229    my $filename = $href; 
    223230    $filename =~ s/^[^:]*:\/\///; 
    224     $filename = &util::filename_cat ($base_dir, $filename); 
     231    $filename = &util::filename_cat($base_dir, $filename); 
     232 
    225233    my ($ext) = $filename =~ /(\.[^\.]*)$/; 
    226234 
     
    296304        $before_hash =~ s/\\/\//g; # for windows 
    297305        } 
     306        else 
     307        { 
     308        # see if link shares directory with source document 
     309        # => turn into relative link if this is so! 
     310        my $before_hash_fix = &util::filename_cat("",$before_hash); 
     311        $before_hash_fix =~ s/^$base_dir(\\|\/)//; 
     312        $before_hash = $before_hash_fix; 
     313 
     314        } 
     315 
    298316 
    299317    } else { 
     
    304322    } 
    305323 
     324 
     325    my $linkfilename = &util::filename_cat ($base_dir, $before_hash);  
     326 
    306327    # make sure there's a slash on the end if it's a directory 
    307     my $linkfilename = &util::filename_cat ($base_dir, $before_hash); 
    308328    if ($before_hash !~ /\/$/) { 
    309329        $before_hash .= "/" if (-d $linkfilename); 
     
    364384        my $tmptext = $$textref; 
    365385        $tmptext =~ s/\s+/ /gs; 
     386        $tmptext =~ s/$self->{'title_sub'}// if (defined $self->{'title_sub'}); 
    366387        $tmptext =~ s/<[^>]*>//g; 
    367388        $tmptext = substr ($tmptext, 0, 100); 
     
    379400        $tmptext =~ s/\s+/ /gs; 
    380401        $tmptext =~ s/.*<body[^>]*>//i; 
     402        $tmptext =~ s/$self->{'title_sub'}// if (defined $self->{'title_sub'}); 
    381403        $tmptext =~ s/<[^>]*>//g; 
    382404        $tmptext = substr ($tmptext, 0, 200); 
  • trunk/gsdl/perllib/plugins/TEXTPlug.pm

    r1244 r1410  
    2929package TEXTPlug; 
    3030 
    31 use BasPlug; 
     31use ConvertToBasPlug; 
    3232 
    3333sub BEGIN { 
    34     @ISA = ('BasPlug'); 
     34    @ISA = ('ConvertToBasPlug'); 
    3535} 
    3636 
     
    3939sub new { 
    4040    my ($class) = @_; 
    41     my $self = new BasPlug ("TEXTPlug", @_); 
     41    my $self = new ConvertToBasPlug ($class, @_); 
     42 
     43    $self->{'convert_to'} = "TEXT"; 
     44    $self->{'convert_to_ext'} = "txt"; 
    4245 
    4346    return bless $self, $class;