4 package RT::Pod::HTMLBatch;
5 use base 'Pod::Simple::HTMLBatch';
7 use List::MoreUtils qw/all/;
13 my $self = shift->SUPER::new(@_);
16 # Per-page output options
17 $self->css_flurry(0); # No CSS
18 $self->javascript_flurry(0); # No JS
19 $self->no_contents_links(1); # No header/footer "Back to contents" links
22 $self->index(1); # Write a per-page TOC
23 $self->contents_file("index.html"); # Write a global TOC
25 $self->html_render_class('RT::Pod::HTML');
26 $self->search_class('RT::Pod::Search');
35 my $is_install_doc = sub {
37 local $_ = $page{name};
38 return 1 if /^(README|UPGRADING)/;
39 return 1 if $_ eq "RT_Config";
40 return 1 if $_ eq "web_deployment";
41 return 1 if $page{infile} =~ m{^configure(\.ac)?$};
45 my $section = $info{infile} =~ m{/plugins/([^/]+)} ? "05 Extension: $1" :
46 $info{infile} =~ m{/local/} ? '04 Local Documenation' :
47 $is_install_doc->(%info) ? '00 Install and Upgrade '.
49 $info{infile} =~ m{/(docs|etc)/} ? '01 User Documentation' :
50 $info{infile} =~ m{/bin/} ? '02 Utilities (bin)' :
51 $info{infile} =~ m{/sbin/} ? '03 Utilities (sbin)' :
52 $info{name} =~ /^RT::Action/ ? '08 Actions' :
53 $info{name} =~ /^RT::Condition/ ? '09 Conditions' :
54 $info{name} =~ /^RT(::|$)/ ? '07 Developer Documentation' :
55 $info{infile} =~ m{/devel/tools/} ? '20 Utilities (devel/tools)' :
58 if ($info{infile} =~ m{/(docs|etc)/}) {
59 $info{name} =~ s/_/ /g;
60 $info{name} = join "/", map { ucfirst } split /::/, $info{name};
63 return ($info{name}, $section);
66 sub write_contents_file {
68 return unless $self->contents_file;
70 my $file = join "/", $to, $self->contents_file;
71 open my $index, ">", $file
72 or warn "Unable to open index file '$file': $!\n", return;
74 my $pages = $self->_contents;
75 return unless @$pages;
79 for my $page (@$pages) {
80 my ($name, $infile, $outfile, $pieces) = @$page;
82 my ($title, $section) = $self->classify(
87 (my $path = $outfile) =~ s{^\Q$to\E/?}{};
89 push @{ $toc{$section} }, {
96 print $index "<dl class='superindex'>\n";
98 for my $key (sort keys %toc) {
99 next unless @{ $toc{$key} };
101 (my $section = $key) =~ s/^\d+ //;
102 print $index "<dt>", esc($section), "</dt>\n";
103 print $index "<dd>\n";
106 my @names = map { $_->{name} } $a, $b;
108 # Sort just the upgrading docs descending within everything else
109 @names = reverse @names
110 if all { /^UPGRADING-/ } @names;
112 $names[0] cmp $names[1]
115 for my $page (@sorted) {
116 print $index " <a href='", esc($page->{path}), "'>",
120 print $index "</dd>\n";
122 print $index '</dl>';
128 Pod::Simple::HTMLBatch::esc(@_);