########################################################################### # # HTMLPlug.pm -- basic html plugin # A component of the Greenstone digital library software # from the New Zealand Digital Library Project at the # University of Waikato, New Zealand. # # Copyright (C) 1999 New Zealand Digital Library Project # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ########################################################################### # creates simple single-level document from .htm or .html files # (case-insensitive match on filenames). Adds Title metadata # taken from
add_text ($cursection, $text); foreach $field (keys(%$metadata)) { # $metadata->{$field} may be an array reference if (ref ($metadata->{$field}) eq "ARRAY") { map { $doc_obj->add_metadata ($cursection, $field, $_); } @{$metadata->{$field}}; } else { $doc_obj->add_metadata ($cursection, $field, $metadata->{$field}); } } # add OID $doc_obj->set_OID (); # process the document $processor->process($doc_obj); return 1; # processed the file } sub replace_image_links { my ($dir, $doc_obj, $front, $link, $back) = @_; my ($filename, $error); my $foundimage = 0; $link =~ s/\/\///; my ($imagetype) = $link =~ /([^\.]*)$/; $imagetype =~ tr/[A-Z]/[a-z]/; if ($imagetype eq "jpg") {$imagetype = "jpeg";} if ($imagetype !~ /^(jpg|gif|png)$/) { print STDERR "HTMLPlug: Warning - unknown image type ($imagetype)\n"; } my ($imagefile) = $link =~ /([^\/]*)$/; my ($imagepath) = $link =~ /^[^\/]*(.*)$/; if (defined $imagepath && $imagepath =~ /\w/) { # relative link $filename = &util::filename_cat ($dir, $imagepath); if (-e $filename) { $doc_obj->associate_file ($filename, $imagefile, "image/$imagetype"); $foundimage = 1; } else { $error = "HTMLPlug: Warning - couldn't find image file $imagefile in either $filename or"; } } if (!$foundimage) { $filename = &util::filename_cat ($dir, $imagefile); if (-e $filename) { $doc_obj->associate_file ($filename, $imagefile, "image/$imagetype"); $foundimage = 1; } elsif (defined $error) { print STDERR "$error $filename\n"; } else { print STDERR "HTMLPlug: Warning - couldn't find image file $imagefile in $filename\n"; } } if ($foundimage) { return "${front}_httpcollection_/archives/_thisOID_/${imagefile}${back}"; } else { return ""; } } 1;