Ignore:
Timestamp:
2008-06-05T09:29:32+12:00 (16 years ago)
Author:
kjdon
Message:

plugin overhaul: plugins renamed to xxPlugin, and in some cases the names are made more sensible. They now use the new base plugins. Hopefully we have better code reuse. Some of the plugins still need work done as I didn't want to spend another month doing this before committing it. Alos, I haven't really tested anything yet...

File:
1 edited

Legend:

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

    r15865 r15872  
    11###########################################################################
    22#
    3 # TEXTPlug.pm -- simple text plugin
     3# TextPlugin.pm -- simple text plugin
    44# A component of the Greenstone digital library software
    55# from the New Zealand Digital Library Project at the
     
    2929# 12/05/02 Added usage datastructure - John Thompson
    3030
    31 package TEXTPlug;
    32 
    33 use BasPlug;
     31package TextPlugin;
     32
     33use ReadTextFile;
    3434
    3535use strict;
    3636no strict 'refs'; # allow filehandles to be variables and viceversa
     37no strict 'subs';
    3738
    3839sub BEGIN {
    39     @TEXTPlug::ISA = ('BasPlug');
     40    @TextPlugin::ISA = ('ReadTextFile');
    4041}
    4142
    4243my $arguments =
    4344    [ { 'name' => "process_exp",
    44     'desc' => "{BasPlug.process_exp}",
     45    'desc' => "{BasePlugin.process_exp}",
    4546    'type' => "regexp",
    4647    'deft' => &get_default_process_exp(),
    4748    'reqd' => "no" } ,
    4849      { 'name' => "title_sub",
    49     'desc' => "{TEXTPlug.title_sub}",
     50    'desc' => "{TextPlugin.title_sub}",
    5051    'type' => "regexp",
    5152    'deft' => "",
    5253    'reqd' => "no" } ];
    5354
    54 my $options = { 'name'     => "TEXTPlug",
    55         'desc'     => "{TEXTPlug.desc}",
     55my $options = { 'name'     => "TextPlugin",
     56        'desc'     => "{TextPlugin.desc}",
    5657        'abstract' => "no",
    5758        'inherits' => "yes",
     
    6566    push(@$pluginlist, $class);
    6667
    67     if(defined $arguments){ push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});}
    68     if(defined $options) { push(@{$hashArgOptLists->{"OptList"}},$options)};
    69 
    70     my $self = new BasPlug($pluginlist, $inputargs, $hashArgOptLists);
     68    push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});
     69    push(@{$hashArgOptLists->{"OptList"}},$options);
     70
     71    my $self = new ReadTextFile($pluginlist, $inputargs, $hashArgOptLists);
    7172
    7273    return bless $self, $class;
     
    8586    my $outhandle = $self->{'outhandle'};
    8687
    87     print STDERR "<Processing n='$file' p='TEXTPlug'>\n" if ($gli);
    88     print $outhandle "TEXTPlug: processing $file\n"
     88    print STDERR "<Processing n='$file' p='TextPlugin'>\n" if ($gli);
     89    print $outhandle "TextPlugin xx: processing $file\n"
    8990    if $self->{'verbosity'} > 1;
    9091   
     
    109110    }
    110111    # Add FileFormat metadata
    111     $doc_obj->add_metadata($cursection, "FileFormat", "TEXT");
     112    $doc_obj->add_metadata($cursection, "FileFormat", "Text");
    112113
    113114    # insert preformat tags and add text to document object   
     
    136137# replace_srcdoc_with_html.pl requires all subroutines that support src_replaceable
    137138# to contain a method called tmp_area_convert_file - this is indeed the case with all
    138 # Perl modules that are subclasses of ConvertToPlug.pm, but as we want TEXTPlug to also
    139 # be srcreplaceable and because TEXTPlug does not inherit from ConvertToPlug.pm, we have
     139# Perl modules that are subclasses of ConvertToPlug.pm, but as we want TextPlugin to also
     140# be srcreplaceable and because TextPlugin does not inherit from ConvertToPlug.pm, we have
    140141# a similar subroutine with the same name here.
    141142sub tmp_area_convert_file {
     
    192193    # Recreate the original file for writing the updated contents
    193194    unless(open(TEXT, "<$tmp_filename")) { # open it as a new file for writing
    194     print STDERR "TEXTPlug.pm: Unable to open and read from $tmp_filename for converting to html...ERROR: $!\n";
     195    print STDERR "TextPlugin.pm: Unable to open and read from $tmp_filename for converting to html...ERROR: $!\n";
    195196    return ""; # no file name
    196197    }
     
    212213    # try creating this new file writing and try opening it for writing, else exit with error value
    213214    unless(open(HTML, ">$output_filename")) {  # open the new html file for writing
    214     print STDERR "TEXTPlug.pm: Unable to create $output_filename for writing $tailname$suffix txt converted to html...ERROR: $!\n";
     215    print STDERR "TextPlugin.pm: Unable to create $output_filename for writing $tailname$suffix txt converted to html...ERROR: $!\n";
    215216    return ""; # no filename
    216217    }
Note: See TracChangeset for help on using the changeset viewer.