ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/ActiveDoc/SimpleURLDoc.pm
Revision: 1.1.2.4
Committed: Thu Aug 10 12:46:59 2000 UTC (24 years, 9 months ago) by williamc
Content type: text/plain
Branch: HPWbranch
Changes since 1.1.2.3: +5 -3 lines
Log Message:
Add doc tags

File Contents

# Content
1 #
2 # SimpleURLDoc.pm. - Extends SimpleDoc with URL download functionality
3 #
4 # Originally Written by Christopher Williams
5 #
6 # Description
7 # -----------
8 #
9 # Interface
10 # ---------
11 # new(URLcache[,DocVersionTag] : A new SimpleURLDoc object. You can also
12 # specify an alternative doc version tag
13 # addbasetags(parse) : Add Base Tags to the given parse
14 # urlget(urlstring[,location]) : get the given url. Returns (url, filename)
15 # expandurl(urlstring) : return a URLclass object of the given url expanded
16 # according to the base settings
17 # cache([cache]) : get/set the current URL cache
18 # doctype() : return the (type,version) of the document
19 # as specified by the DocVersionTag
20
21 package ActiveDoc::SimpleURLDoc;
22 use ActiveDoc::SimpleDoc;
23 use URL::URLhandler;
24 require 5.001;
25
26 sub new {
27 my $class=shift;
28 my $self={};
29 bless $self, $class;
30 $self->cache(shift);
31 $self->{switch}=ActiveDoc::SimpleDoc->new(@_);
32 return $self;
33 }
34
35 sub addbasetags {
36 my $self=shift;
37 my $parse=shift;
38
39 $self->{switch}->addtag($parse,"base", \&Base_start, $self,
40 "", $self,
41 \&Base_end,$self);
42 }
43
44 sub cache {
45 my $self=shift;
46 if ( @_ ) {
47 $self->{cache}=shift;
48 $self->{urlhandler}=URL::URLhandler->new($self->{cache});
49 }
50 return $self->{cache};
51 }
52
53 sub expandurl {
54 my $self=shift;
55 my $urlstring=shift;
56
57 return $self->{urlhandler}->expandurl($urlstring);
58 }
59
60 sub urlget {
61 my $self=shift;
62 my $urlstring=shift;
63
64 ($fullurl,$filename)=$self->{urlhandler}->get($urlstring, @_);
65 if ( ( ! defined $filename ) || ( $filename eq "" ) ) {
66 $self->{switch}->parseerror("Failed to get $fullurl");
67 }
68 return ($fullurl,$filename);
69 }
70
71 sub AUTOLOAD {
72 my $self=shift;
73
74 # dont propogate destroy methods
75 return if $AUTOLOAD=~/::DESTROY/;
76
77 # remove this package name
78 ($name=$AUTOLOAD)=~s/ActiveDoc::SimpleURLDoc:://;
79
80 # pass the message to SimpleDoc
81 $self->{switch}->$name(@_);
82 }
83
84 # ------------------------ Support Routines ---------------------------
85
86 # ------------------------ Tag Routines -------------------------------
87
88 sub Base_start {
89 my $self=shift;
90 my $name=shift;
91 my $hashref=shift;
92
93 $self->{switch}->checktag($name, $hashref, "url");
94 my $url=$self->{urlhandler}->setbase($$hashref{'url'});
95 push @{$self->{basestack}}, $url->type();
96 }
97
98 sub Base_end {
99 my $self=shift;
100 if ( $#{$self->{basestack}} >= 0 ) {
101 my $type=pop @{$self->{basestack}};
102 $self->{urlhandler}->unsetbase($type);
103 }
104 else {
105 $self->{switch}->parseerror("Unmatched <$name>");
106 }
107 }