Subversion Repositories DevTools

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
361 dpurdie 1
package JatsDocTools::TOC::HTML;
2
 
3
use strict;
4
use warnings;
5
 
6
use base 'JatsDocTools::TOC';
7
use Data::Dumper;
8
 
9
sub text {
10
    my $text =  join("\n", @_, "");
11
    return sub { $text };
12
}
13
 
14
my $genTail = '';
15
sub genHeader
16
{
17
    my ($title, $tip, $class, $open) = @_;
18
    my @tail;
19
    my @head;
20
 
21
    push @head, '<hr>',
22
                '<span title="' . $tip . '">',
23
                '<a id="clasp_'. $class . '" class="clasp" onclick="javascript:lunchboxToggle(\''. $class . '\');">',
24
                '<img border="1" width="9" height="9" src="images/plus.gif">',
25
                '<strong>'. $title . '</strong><br />',
26
                '</a>',
27
                '<ul>',
28
                '<div id="lunch_'. $class . '" class="lunchbox">';
29
 
30
    push @tail, '</ul></span></div>';
31
    if ( $open )
32
    {
33
        push @tail, '<script>',
34
                    'window.onload=lunchboxToggle(\''. $class .'\');',
35
                    '</script>';
36
    }
37
 
38
    $genTail = text(@tail);
39
    return text (@head);
40
 
41
}
42
 
43
 
44
# extra info is tedious to collect -- is done in a subclass or something.
45
sub extra { '' };
46
 
47
*header = text(''); # text ("<hr>","<strong>JATS Core Documentation</strong><br />",);
48
*footer = text("\n\n</div>\n</body>\n</html>");
49
 
50
*before_faq = genHeader( 'JATS FAQ',
51
                         'Selected Frequently Asked Questions on building with JATS as well as the JATS Utilities',
52
                         'faq', 0 );
53
*after_faq = $genTail;
54
 
55
sub faq_section {
56
    my($self, $file, $heading) = @_;
57
    my $ref = $self->{Faqs}->{$heading}{$file};
58
    my $tip = $file;
59
    $file =~ s~\s~&nbsp;~g;
60
    return (qq'  <li>' . _page($self->{faq}->{$ref}, $file, $self->extra($file), $tip) );
61
}
62
 
63
# Create a Hash of headings
64
sub preProcFaq
65
{
66
     my($self) = @_;
67
     my %Faqs;
68
     foreach my $faq ( keys %{$self->{faq}})
69
     {
70
        my $data = $faq;
71
        $faq =~ s~.*FAQ::~~;
72
        my @data = split ('::', $faq );
73
        if ( $data[1] ) {
74
            $Faqs{$data[0]}{$data[-1]} = $data;
75
        } else {
76
            $Faqs{''}{$data[0]} = $data;
77
        }
78
     }
79
    $self->{Faqs} = \%Faqs;
80
#print Dumper($self->{Faqs});
81
#print Dumper($self->{faq});
82
}
83
 
84
sub after_faq_section { '';}
85
sub before_faq_section
86
{
87
    my($self, $header) = @_;
88
    if ( $header )
89
    {
90
        return ('<B>' . $header . '</B>');
91
#        return (qq'  <hr>' . $header);
92
    }
93
}
94
 
95
 
96
*before_Jats = genHeader( 'Build and Make',
97
                          'Utilities to build and make JATS packages',
98
                          'Jats',1 );
99
*after_Jats = $genTail;
100
sub Jats {
101
    my($self, $file) = @_;
102
    return (qq'  <li>' . _page($self->{Jats}->{$file}, $file, $self->extra($file)));
103
}
104
 
105
*before_Deploy = genHeader( 'Deployment Utilities',
106
                            'Utilities to assist in the deployment process',
107
                            'Deploy' );
108
*after_Deploy = $genTail;
109
sub Deploy {
110
    my($self, $file) = @_;
111
    return (qq'  <li>' . _page($self->{Deploy}->{$file}, $file, $self->extra($file)));
112
}
113
 
114
*before_Core = genHeader( 'Core Documentation',
115
                          'Information about the JATS environment',
116
                          'core', 1 );
117
*after_Core = $genTail;
118
sub Core {
119
    my($self, $file) = @_;
120
    return (qq'  <li>' . _page($self->{Core}->{$file}, $file, $self->extra($file)));
121
}
122
 
123
 
124
*before_sutil = genHeader( 'System Utilities',
125
                           'Utilities used by the JATS build system. These utilities are not normally used directly by users.',
126
                           'sutil' );
127
*after_sutil = $genTail;
128
sub sutil {
129
    my($self, $file) = @_;
130
    return (qq'  <li>' . _page($self->{sutil}->{$file}, $file, $self->extra($file)));
131
}
132
 
133
*before_general = genHeader(
134
                    'User Utilities',
135
                    'Command line utilities available to users.',
136
                    'General', 1
137
                    );
138
*after_general = $genTail;
139
 
140
# Create a Hash of headings
141
sub preProcGeneral
142
{
143
     my($self) = @_;
144
     my %GenSec;
145
     foreach my $entry ( keys %{$self->{General}})
146
     {
147
        my $data = $entry;
148
 
149
        $entry =~ s~GENERAL::~~;
150
        $entry =~ s~TOOLS::(.+::)*~~;
151
        my @data = split ('::', $entry );
152
        if ( $data[1] ) {
153
            $GenSec{$data[0]}{$data[-1]} = $data;
154
        } else {
155
            $GenSec{''}{$data[0]} = $data;
156
        }
157
     }
158
    $self->{GenSec} = \%GenSec;
159
#print Dumper($self->{GenSec});
160
#print Dumper($self->{General});
161
}
162
sub after_general_section { '';}
163
sub before_general_section
164
{
165
    my($self, $header) = @_;
166
    if ( $header )
167
    {
168
#        return (qq'  <hr>' . $header);
169
        return ('<B>' . $header . '</B>');
170
    }
171
}
172
sub general_section {
173
    my($self, $file, $heading) = @_;
174
    my $ref = $self->{GenSec}->{$heading}{$file};
175
    my $tip = $file;
176
    $file =~ s~\s~&nbsp;~g;
177
    return (qq'  <li>' . _page($self->{General}->{$ref}, $file, $self->extra($file), $tip) );
178
}
179
 
180
 
181
 
182
 
183
*before_mutil = genHeader( 'Make Utilities',
184
                           'Utilities used by makefiles to assist in the build process. These are not normally used by CLI users.',
185
                           'mutil' );
186
*after_mutil = $genTail;
187
sub mutil {
188
    my($self, $file) = @_;
189
    return (qq'  <li>' . _page($self->{mutil}->{$file}, $file, $self->extra($file)));
190
}
191
 
192
 
193
sub _page {
194
    my($href, $text, $extra, $tip) = @_;
195
    die "bad arguments to _page: ($href, $text, $extra)" unless defined $href and defined $text;
196
    $extra ||= '';
197
    $extra = " $extra" if $extra;  # just to make it EXACTLY identical to the old way.
198
    $text =~ s~.*::~~;
199
 
200
    my $inner = "class=\"doc\"";
201
    if ( $tip )
202
    {
203
        $inner .= " title=\"$tip\"";
204
    }
205
    return qq'<a $inner href="$href">$text</a>$extra</li>\n';
206
}
207
 
208
 
209
sub boilerplate {
210
    return boiler_header() . boiler_links();
211
}
212
 
213
sub boiler_header {
214
    return <<'HERE';
215
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
216
<html>
217
 
218
<head>
219
<!-- Generated file. Edits will be lost -->
220
<title>JATS User Guide - Table of Contents</title>
221
<base target="JatsDoc">
222
<link rel="STYLESHEET" href="JatsToc.css" type="text/css">
223
<script type="text/javascript" src="displayToc.js"></script>
224
</head>
225
 
226
 
227
<body>
228
<h1>Table of Contents</h1>
229
HERE
230
}
231
 
232
 
233
sub boiler_links {
234
    my $retval = <<HERE;
235
<div nowrap>
236
 
237
<strong>Getting Started</strong><br />
238
<ul>
239
  <li><a class="doc" href="JatsWelcome.html">Welcome To JATS</a></li>
240
  <li><a class="doc" href="release.html">Release Notes</a></li>
241
  <li><a class="doc" href="TOOLS/jats.html">Introduction</a></li>
242
</ul>
243
HERE
244
 
245
#
246
#   ToDo
247
#  <li><a class="doc" href="install.html">Installation Guide</a></li>
248
#  <li><a class="doc" href="readme.html">Getting Started</a></li>
249
#  <li><a class="doc" href="JatsChangeLog.html">Jats Change Log</a></li>
250
#  <li><a class="doc" href="resources.html">More Resources</a></li>
251
#  <li><a class="doc" href="Copyright.html">License and Copyright</a></li>
252
 
253
#$retval .= <<HERE;
254
#<strong>JATS Components</strong><br />
255
#<ul>
256
#  <li><a class="doc" href="Components/Descriptions.html">Overview</a></li>
257
#</ul>
258
#HERE
259
#
260
    return $retval;
261
}
262
 
263
1;