[greenstone-devel] Patch for UnknownPlug.pm to handle filenames with spaces - and begging for video plugins.

From Stephen De Gabrielle
DateFri, 15 Oct 2004 16:50:29 +0900
Subject [greenstone-devel] Patch for UnknownPlug.pm to handle filenames with spaces - and begging for video plugins.
Hi,

Was working on a small test collection in greenstone and noticed that the receptionist was clipping the filename if I used '[ex.srclink]>[ex.Source][ex./srclink]' in my format statements.

Eg;
I got
http://somestuff/beds
in my address bar (leading to a 404)
Instead of
http://somestuff/beds are burning.mpeg
---

The quick fix was to change the '[ex.srclink]>[ex.Source][ex./srclink]' in my format statements to:
<a href='/gsdl/collect/gsarch/index/assoc/[assocfilepath]/[ex.Source]'>[ex.Source]</a>

While this works I am not really happy. I went looking at my extracted metadata and found that [ex.srclink] was being defined without quotes around the contents of the href attribute.

Adding single quotes the the href in line 149 of unknownplug.pm seemed to do the trick:

line 149
"<a href='/gsdl/collect/gsarch/index/assoc/[assocfilepath]/[$assoc_field]'>");

I have tested this on WinXP and it seems to work.
(I will test it under osx this weekend)

PS Does anyone have plugins for video formats? I found mention on MTVPlug and MovPlug in the music video demo collect.cfg file but they are not included in the distro.
(Or should I sniff around cvs?)

Regards,

Stephen De Gabrielle
NT Library

--snippet of unknownplug.pm with the changed line--
# Associate the unknown file with the new document

sub associate_unknown_file {
my $self = shift (@_);
my $filename = shift (@_); # filename with full path
my $file = shift (@_); # filename without path
my $doc_obj = shift (@_);

my $verbosity = $self->{'verbosity'};
my $outhandle = $self->{'outhandle'};

# check the filename is okay
return 0 if ($file eq "" || $filename eq "");

# Add the image metadata
my $url = $file;
$url =~ s/ /%20/g;

# Add the file as an associated file ...
my $section = $doc_obj->get_top_section();
my $file_format = $self->{'file_format'} || "unknown";
my $mime_type = $self->{'mime_type'} || "unknown/unknown";
my $assoc_field = $self->{'assoc_field'} || "unknown_file";

$doc_obj->associate_file($filename, $file, $mime_type, $section);
$doc_obj->add_metadata ($section, "FileFormat", $file_format);
$doc_obj->add_metadata ($section, $assoc_field, $file);
$doc_obj->add_metadata ($section, "Source", $file);

$self->title_fallback($doc_obj,$section,$file);

$doc_obj->add_metadata ($section, "srclink",
"<a href='/gsdl/collect/gsarch/index/assoc/[assocfilepath]/[$assoc_field]'>");
## SD added single quotes to allow files with spaces.
$doc_obj->add_metadata ($section, "srcicon", "_texticonunknown_");
$doc_obj->add_metadata ($section, "/srclink", "</a>");

return 1;
}