source: trunk/gsdl/perllib/plugins/TEXTPlug.pm@ 1244

Last change on this file since 1244 was 1244, checked in by sjboddie, 24 years ago

Caught up most general plugins (that's the ones in gsdlhome/perllib/plugins)
with changes to BasPlug so that they can all now use the new general plugin
options. Those I didn't do were FoxPlug (as it's not actually used anywhere
and I don't know what it does) and WebPlug (as it's kind of a work in
progress and doesn't really work anyway). All plugins will still work
(including all the collection specific ones that are laying around), some
of them just won't have access to the general options.
I also wrote a short perl script (pluginfo.pl) that prints out all the
options available to a given plugin.

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 2.2 KB
Line 
1###########################################################################
2#
3# TEXTPlug.pm -- simple text plugin
4# A component of the Greenstone digital library software
5# from the New Zealand Digital Library Project at the
6# University of Waikato, New Zealand.
7#
8# Copyright (C) 1999 New Zealand Digital Library Project
9#
10# This program is free software; you can redistribute it and/or modify
11# it under the terms of the GNU General Public License as published by
12# the Free Software Foundation; either version 2 of the License, or
13# (at your option) any later version.
14#
15# This program is distributed in the hope that it will be useful,
16# but WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18# GNU General Public License for more details.
19#
20# You should have received a copy of the GNU General Public License
21# along with this program; if not, write to the Free Software
22# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23#
24###########################################################################
25
26# creates simple single-level document. Adds Title metadata
27# of first line of text (up to 100 characters long).
28
29package TEXTPlug;
30
31use BasPlug;
32
33sub BEGIN {
34 @ISA = ('BasPlug');
35}
36
37use strict;
38
39sub new {
40 my ($class) = @_;
41 my $self = new BasPlug ("TEXTPlug", @_);
42
43 return bless $self, $class;
44}
45
46sub get_default_process_exp {
47 my $self = shift (@_);
48
49 return q^(?i)\.te?xt$^;
50}
51
52# do plugin specific processing of doc_obj
53sub process {
54 my $self = shift (@_);
55 my ($textref, $pluginfo, $base_dir, $file, $metadata, $doc_obj) = @_;
56
57 print STDERR "TEXTPlug: processing $file\n"
58 if $self->{'verbosity'} > 1;
59
60 my $cursection = $doc_obj->get_top_section();
61
62 # get title metadata
63 # (don't need to get title if it has been passed
64 # in from another plugin)
65 if (!defined $metadata->{'Title'}) {
66 my ($title) = $$textref =~ /^([^\n]*)/;
67 if (length($title) > 100) {
68 $title = substr ($title, 0, 100);
69 }
70 $doc_obj->add_utf8_metadata ($cursection, "Title", $title);
71 }
72
73 # insert preformat tags and add text to document object
74 $doc_obj->add_utf8_text($cursection, "<pre>\n$$textref\n</pre>");
75
76 return 1;
77}
78
791;
80
81
82
83
84
85
86
87
88
89
90
Note: See TracBrowser for help on using the repository browser.