Subversion Repositories DevTools

Rev

Rev 361 | Details | Compare with Previous | 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
    {
363 dpurdie 90
        return ('<div class="tocsubheading">' . $header . '</div>');
361 dpurdie 91
    }
92
}
93
 
94
 
95
*before_Jats = genHeader( 'Build and Make',
96
                          'Utilities to build and make JATS packages',
97
                          'Jats',1 );
98
*after_Jats = $genTail;
99
sub Jats {
100
    my($self, $file) = @_;
101
    return (qq'  <li>' . _page($self->{Jats}->{$file}, $file, $self->extra($file)));
102
}
103
 
104
*before_Deploy = genHeader( 'Deployment Utilities',
105
                            'Utilities to assist in the deployment process',
106
                            'Deploy' );
107
*after_Deploy = $genTail;
108
sub Deploy {
109
    my($self, $file) = @_;
110
    return (qq'  <li>' . _page($self->{Deploy}->{$file}, $file, $self->extra($file)));
111
}
112
 
113
*before_Core = genHeader( 'Core Documentation',
114
                          'Information about the JATS environment',
115
                          'core', 1 );
116
*after_Core = $genTail;
117
sub Core {
118
    my($self, $file) = @_;
119
    return (qq'  <li>' . _page($self->{Core}->{$file}, $file, $self->extra($file)));
120
}
121
 
122
 
123
*before_sutil = genHeader( 'System Utilities',
124
                           'Utilities used by the JATS build system. These utilities are not normally used directly by users.',
125
                           'sutil' );
126
*after_sutil = $genTail;
127
sub sutil {
128
    my($self, $file) = @_;
129
    return (qq'  <li>' . _page($self->{sutil}->{$file}, $file, $self->extra($file)));
130
}
131
 
132
*before_general = genHeader(
133
                    'User Utilities',
134
                    'Command line utilities available to users.',
135
                    'General', 1
136
                    );
137
*after_general = $genTail;
138
 
139
# Create a Hash of headings
140
sub preProcGeneral
141
{
142
     my($self) = @_;
143
     my %GenSec;
144
     foreach my $entry ( keys %{$self->{General}})
145
     {
146
        my $data = $entry;
147
 
148
        $entry =~ s~GENERAL::~~;
149
        $entry =~ s~TOOLS::(.+::)*~~;
150
        my @data = split ('::', $entry );
151
        if ( $data[1] ) {
152
            $GenSec{$data[0]}{$data[-1]} = $data;
153
        } else {
154
            $GenSec{''}{$data[0]} = $data;
155
        }
156
     }
157
    $self->{GenSec} = \%GenSec;
158
#print Dumper($self->{GenSec});
159
#print Dumper($self->{General});
160
}
161
sub after_general_section { '';}
162
sub before_general_section
163
{
164
    my($self, $header) = @_;
165
    if ( $header )
166
    {
363 dpurdie 167
        return ('<div class="tocsubheading">' . $header . '</div>');
361 dpurdie 168
    }
169
}
170
sub general_section {
171
    my($self, $file, $heading) = @_;
172
    my $ref = $self->{GenSec}->{$heading}{$file};
173
    my $tip = $file;
174
    $file =~ s~\s~&nbsp;~g;
175
    return (qq'  <li>' . _page($self->{General}->{$ref}, $file, $self->extra($file), $tip) );
176
}
177
 
178
 
179
 
180
 
181
*before_mutil = genHeader( 'Make Utilities',
182
                           'Utilities used by makefiles to assist in the build process. These are not normally used by CLI users.',
183
                           'mutil' );
184
*after_mutil = $genTail;
185
sub mutil {
186
    my($self, $file) = @_;
187
    return (qq'  <li>' . _page($self->{mutil}->{$file}, $file, $self->extra($file)));
188
}
189
 
190
 
191
sub _page {
192
    my($href, $text, $extra, $tip) = @_;
193
    die "bad arguments to _page: ($href, $text, $extra)" unless defined $href and defined $text;
194
    $extra ||= '';
195
    $extra = " $extra" if $extra;  # just to make it EXACTLY identical to the old way.
196
    $text =~ s~.*::~~;
197
 
198
    my $inner = "class=\"doc\"";
199
    if ( $tip )
200
    {
201
        $inner .= " title=\"$tip\"";
202
    }
203
    return qq'<a $inner href="$href">$text</a>$extra</li>\n';
204
}
205
 
206
 
207
sub boilerplate {
208
    return boiler_header() . boiler_links();
209
}
210
 
211
sub boiler_header {
212
    return <<'HERE';
213
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
214
<html>
215
 
216
<head>
217
<!-- Generated file. Edits will be lost -->
218
<title>JATS User Guide - Table of Contents</title>
219
<base target="JatsDoc">
220
<link rel="STYLESHEET" href="JatsToc.css" type="text/css">
221
<script type="text/javascript" src="displayToc.js"></script>
222
</head>
223
 
224
 
225
<body>
226
<h1>Table of Contents</h1>
227
HERE
228
}
229
 
230
 
231
sub boiler_links {
232
    my $retval = <<HERE;
233
<div nowrap>
234
 
235
<strong>Getting Started</strong><br />
236
<ul>
237
  <li><a class="doc" href="JatsWelcome.html">Welcome To JATS</a></li>
238
  <li><a class="doc" href="release.html">Release Notes</a></li>
239
  <li><a class="doc" href="TOOLS/jats.html">Introduction</a></li>
240
</ul>
241
HERE
242
 
243
#
244
#   ToDo
245
#  <li><a class="doc" href="install.html">Installation Guide</a></li>
246
#  <li><a class="doc" href="readme.html">Getting Started</a></li>
247
#  <li><a class="doc" href="JatsChangeLog.html">Jats Change Log</a></li>
248
#  <li><a class="doc" href="resources.html">More Resources</a></li>
249
#  <li><a class="doc" href="Copyright.html">License and Copyright</a></li>
250
 
251
#$retval .= <<HERE;
252
#<strong>JATS Components</strong><br />
253
#<ul>
254
#  <li><a class="doc" href="Components/Descriptions.html">Overview</a></li>
255
#</ul>
256
#HERE
257
#
258
    return $retval;
259
}
260
 
261
1;