Revision: | 1.6 |
Committed: | Tue Feb 27 11:59:42 2007 UTC (18 years, 2 months ago) by sashby |
Content type: | text/plain |
Branch: | MAIN |
CVS Tags: | V1_2_1b, V1_2_1a, V1_2_3, V1_2_2, V1_2_2_relcand2, V1_2_2_relcand1, V1_2_1, V1_2_0, V1_2_0-cand11, V1_1_7, V1_1_6, V1_2_0-cand10, V1_1_5, V1_2_0-cand9, V1_2_0-cand8, V1_2_0-cand7, V1_2_0-cand6, V1_2_0-cand5, V1_2_0-cand4, V1_2_0-cand3, V1_2_0-cand2, V1_2_0-cand1, V1_1_4, V1_1_3, V1_1_2, V1_1_0_reltag8, V1_1_0_reltag7, V1_1_0_reltag6, V1_1_1, V1_1_0_reltag5, V1_1_0_reltag4, V1_1_0_reltag3, V1_1_0_reltag2, V1_1_0_reltag1, V1_1_0_reltag, V1_1_0_cand3, V1_1_0_cand2, V1_1_0_cand1, HEAD_SM_071214, V1_1_0, v110p1, V110p6, V110p5, V110p4, V110p3 |
Branch point for: | SCRAM_V2_0, forBinLess_SCRAM, HEAD_BRANCH_SM_071214, v200branch |
Changes since 1.5: | +79 -83 lines |
Log Message: | Merged from XML branch to HEAD. Start release prep. |
# | 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 | # urlget(urlstring[,location]) : get the given url - using the cache. |
14 | # Returns (url, filename) |
15 | # urldownload(urlstring[,location]) : get the given url ignoring any cached |
16 | # version. Returns (url, filename) |
17 | # expandurl(urlstring) : return a URLclass object of the given url expanded |
18 | # according to the base settings |
19 | # cache([cache]) : get/set the current URL cache |
20 | |
21 | package ActiveDoc::SimpleURLDoc; |
22 | use ActiveDoc::SimpleDoc; |
23 | use URL::URLhandler; |
24 | require 5.001; |
25 | @ISA=qw(ActiveDoc::SimpleDoc); |
26 | |
27 | sub new() |
28 | { |
29 | my $class=shift; |
30 | my $self={}; |
31 | bless $self, $class; |
32 | my ($cache)=@_; |
33 | $self->cache($cache); |
34 | return $self; |
35 | } |
36 | |
37 | sub cache() |
38 | { |
39 | my $self=shift; |
40 | if ( @_ ) |
41 | { |
42 | $self->{cache}=shift; |
43 | $self->{urlhandler}=URL::URLhandler->new($self->{cache}); |
44 | } |
45 | return $self->{cache}; |
46 | } |
47 | |
48 | sub expandurl() |
49 | { |
50 | my $self=shift; |
51 | my $urlstring=shift; |
52 | |
53 | return $self->{urlhandler}->expandurl($urlstring); |
54 | } |
55 | |
56 | sub urldownload() |
57 | { |
58 | my $self=shift; |
59 | my $urlstring=shift; |
60 | |
61 | ($fullurl,$filename)=$self->{urlhandler}->download($urlstring, @_); |
62 | if ( ( ! defined $filename ) || ( $filename eq "" ) ) |
63 | { |
64 | $self->parseerror("Failed to get $fullurl"); |
65 | } |
66 | return ($fullurl,$filename); |
67 | } |
68 | |
69 | sub urlget() |
70 | { |
71 | my $self=shift; |
72 | my $urlstring=shift; |
73 | |
74 | ($fullurl,$filename)=$self->{urlhandler}->get($urlstring, @_); |
75 | |
76 | if ( ( ! defined $filename ) || ( $filename eq "" ) ) |
77 | { |
78 | $self->parseerror("Failed to get $fullurl"); |
79 | } |
80 | return ($fullurl,$filename); |
81 | } |
82 | |
83 | # ------------------------ Tag Routines ------------------------------- |
84 | sub base() |
85 | { |
86 | my $self=shift; |
87 | my (%attributes)=@_; |
88 | my $url=$self->{urlhandler}->setbase($attributes{'url'}); |
89 | # Add store for url of the file currently being parsed. This info can |
90 | # then be extracted in Requirements objects |
91 | $self->{configurl}=$url; |
92 | push @{$self->{basestack}}, $url->type(); |
93 | } |
94 | |
95 | sub base_() |
96 | { |
97 | my $self=shift; |
98 | if ( $#{$self->{basestack}} >= 0 ) |
99 | { |
100 | my $type=pop @{$self->{basestack}}; |
101 | $self->{urlhandler}->unsetbase($type); |
102 | } |
103 | else |
104 | { |
105 | $self->parseerror("Unmatched <$name>"); |
106 | } |
107 | } |
108 | |
109 | 1; |