Upgrade to 4.0.8 with mod of ExternalAuth + absolute paths to ticket-menu.
[usit-rt.git] / lib / RT / Pod / HTML.pm
CommitLineData
dab09ea8
MKG
1use strict;
2use warnings;
3
4package RT::Pod::HTML;
5use base 'Pod::Simple::XHTML';
6
7sub new {
8 my $self = shift->SUPER::new(@_);
9 $self->index(1);
10 $self->anchor_items(1);
11 return $self;
12}
13
14sub perldoc_url_prefix { "http://metacpan.org/module/" }
15
16sub html_header { '' }
17sub html_footer {
18 my $self = shift;
19 my $toc = "../" x ($self->batch_mode_current_level - 1);
20 return '<a href="./' . $toc . '">&larr; Back to index</a>';
21}
22
23sub start_Verbatim { $_[0]{'scratch'} = "<pre>" }
24sub end_Verbatim { $_[0]{'scratch'} .= "</pre>"; $_[0]->emit; }
25
26sub _end_head {
27 my $self = shift;
28 $self->{scratch} = '<a href="#___top">' . $self->{scratch} . '</a>';
29 return $self->SUPER::_end_head(@_);
30}
31
32sub resolve_pod_page_link {
33 my $self = shift;
34 my ($name, $section) = @_;
35
36 # Only try to resolve local links if we're in batch mode and are linking
37 # outside the current document.
38 return $self->SUPER::resolve_pod_page_link(@_)
39 unless $self->batch_mode and $name;
40
41 $section = defined $section
42 ? '#' . $self->idify($section, 1)
43 : '';
44
45 my $local;
46 if ($name =~ /^RT::/) {
47 $local = join "/",
48 map { $self->encode_entities($_) }
49 split /::/, $name;
50 }
51 elsif ($name =~ /^rt-/) {
52 $local = $self->encode_entities($name);
53 }
54
55 if ($local) {
56 # Resolve links correctly by going up
57 my $depth = $self->batch_mode_current_level - 1;
58 return join "/",
59 ($depth ? ".." x $depth : ()),
60 "$local.html$section";
61 } else {
62 return $self->SUPER::resolve_pod_page_link(@_)
63 }
64}
65
661;