[537] | 1 | ###########################################################################
|
---|
| 2 | #
|
---|
| 3 | # HTML.pm --
|
---|
| 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 |
|
---|
[449] | 26 | # html classifier plugin - creates an empty classification
|
---|
| 27 | # that's simply a link to a web page
|
---|
| 28 | # options are:
|
---|
[2022] | 29 | # buttonname=Title -- (optional) the title field for this classification.
|
---|
[449] | 30 | # if not included title field 'Browse'
|
---|
| 31 | # url=url -- the url of the web page to link to
|
---|
| 32 |
|
---|
[3540] | 33 | # 12/05/02 Added usage datastructure - John Thompson
|
---|
| 34 |
|
---|
[449] | 35 | package HTML;
|
---|
| 36 |
|
---|
[1483] | 37 | use BasClas;
|
---|
| 38 |
|
---|
| 39 | sub BEGIN {
|
---|
| 40 | @ISA = ('BasClas');
|
---|
| 41 | }
|
---|
| 42 |
|
---|
[3540] | 43 | my $arguments =
|
---|
[4759] | 44 | [ { 'name' => "url",
|
---|
[4873] | 45 | 'desc' => "{HTML.url}",
|
---|
[3540] | 46 | 'type' => "string",
|
---|
| 47 | 'reqd' => "yes" } ,
|
---|
[4759] | 48 | { 'name' => "buttonname",
|
---|
[4873] | 49 | 'desc' => "{HTML.buttonname}",
|
---|
[3540] | 50 | 'type' => "string",
|
---|
[4759] | 51 | 'deft' => "Browse",
|
---|
| 52 | 'reqd' => "no" } ];
|
---|
[3540] | 53 |
|
---|
[4759] | 54 | my $options = { 'name' => "HTML",
|
---|
[5645] | 55 | 'desc' => "{HTML.desc}",
|
---|
[6408] | 56 | 'abstract' => "no",
|
---|
| 57 | 'inherits' => "yes",
|
---|
[4759] | 58 | 'args' => $arguments };
|
---|
[3540] | 59 |
|
---|
[4786] | 60 | # sub print_usage {
|
---|
| 61 | # print STDERR "
|
---|
| 62 | # usage: classify AZList [options]
|
---|
| 63 | # options:
|
---|
| 64 | # -url X The url of the web page to link to.
|
---|
| 65 | # -buttonname X (optional) the title field for this classification.
|
---|
| 66 | # The default is 'Browse'
|
---|
[1839] | 67 |
|
---|
[4786] | 68 | # HTML classifier plugin - creates classifier that is a link to a web page
|
---|
[1839] | 69 |
|
---|
[4786] | 70 | # ";
|
---|
| 71 | # }
|
---|
[1839] | 72 |
|
---|
[449] | 73 | sub new {
|
---|
[1839] | 74 | my $class = shift (@_);
|
---|
| 75 | my $self = new BasClas($class, @_);
|
---|
[3540] | 76 |
|
---|
[4759] | 77 | # 14-05-02 To allow for proper inheritance of arguments - John Thompson
|
---|
| 78 | my $option_list = $self->{'option_list'};
|
---|
| 79 | push( @{$option_list}, $options );
|
---|
| 80 |
|
---|
[449] | 81 | my ($title, $url);
|
---|
[1839] | 82 |
|
---|
| 83 | if (!parsargv::parse(\@_,
|
---|
| 84 | q^url/.*/^, \$url,
|
---|
[2022] | 85 | q^buttonname/.*/Browse^, \$title,
|
---|
[1839] | 86 | "allow_extra_options")) {
|
---|
| 87 |
|
---|
| 88 | print STDERR "\nIncorrect options passed to $class, check your collect.cfg file\n";
|
---|
[4873] | 89 | $self->print_txt_usage(""); # Use default resource bundle
|
---|
[1839] | 90 | die "\n";
|
---|
[449] | 91 | }
|
---|
| 92 |
|
---|
[1483] | 93 | if (!defined $url) {
|
---|
| 94 | my $outhandle = $self->{'outhandle'};
|
---|
| 95 | print $outhandle "Error: HTML classifier contains no 'url' option\n";
|
---|
| 96 | die "\n";
|
---|
| 97 | }
|
---|
[449] | 98 |
|
---|
[1483] | 99 | $self->{'url'} = $url;
|
---|
| 100 | $self->{'title'} = $title;
|
---|
| 101 |
|
---|
| 102 | return bless $self, $class;
|
---|
[449] | 103 | }
|
---|
| 104 |
|
---|
| 105 | sub init {
|
---|
| 106 | my $self = shift (@_);
|
---|
| 107 | }
|
---|
| 108 |
|
---|
| 109 | sub classify {
|
---|
| 110 | my $self = shift (@_);
|
---|
| 111 | my ($doc_obj) = @_;
|
---|
| 112 |
|
---|
| 113 | # we don't do anything for individual documents
|
---|
| 114 | }
|
---|
| 115 |
|
---|
| 116 | sub get_classify_info {
|
---|
| 117 | my $self = shift (@_);
|
---|
| 118 |
|
---|
[717] | 119 | my %classifyinfo = ('thistype'=>'Invisible',
|
---|
| 120 | 'childtype'=>'HTML',
|
---|
[449] | 121 | 'Title'=>$self->{'title'},
|
---|
| 122 | 'contains'=>[]);
|
---|
| 123 |
|
---|
| 124 | push (@{$classifyinfo{'contains'}}, {'OID'=>$self->{'url'}});
|
---|
| 125 |
|
---|
| 126 | return \%classifyinfo;
|
---|
| 127 | }
|
---|
| 128 |
|
---|
| 129 |
|
---|
| 130 | 1;
|
---|