0
|
1 #!/usr/bin/perl -w
|
|
2 #
|
|
3 # $RCSfile: TextFilesToHTML.pl,v $
|
|
4 # $Date: 2015/02/28 20:46:21 $
|
|
5 # $Revision: 1.41 $
|
|
6 #
|
|
7 # Author: Manish Sud <msud@san.rr.com>
|
|
8 #
|
|
9 # Copyright (C) 2015 Manish Sud. All rights reserved.
|
|
10 #
|
|
11 # This file is part of MayaChemTools.
|
|
12 #
|
|
13 # MayaChemTools is free software; you can redistribute it and/or modify it under
|
|
14 # the terms of the GNU Lesser General Public License as published by the Free
|
|
15 # Software Foundation; either version 3 of the License, or (at your option) any
|
|
16 # later version.
|
|
17 #
|
|
18 # MayaChemTools is distributed in the hope that it will be useful, but without
|
|
19 # any warranty; without even the implied warranty of merchantability of fitness
|
|
20 # for a particular purpose. See the GNU Lesser General Public License for more
|
|
21 # details.
|
|
22 #
|
|
23 # You should have received a copy of the GNU Lesser General Public License
|
|
24 # along with MayaChemTools; if not, see <http://www.gnu.org/licenses/> or
|
|
25 # write to the Free Software Foundation Inc., 59 Temple Place, Suite 330,
|
|
26 # Boston, MA, 02111-1307, USA.
|
|
27 #
|
|
28
|
|
29 use strict;
|
|
30 use FindBin; use lib "$FindBin::Bin/../lib";
|
|
31 use Getopt::Long;
|
|
32 use File::Basename;
|
|
33 use Text::ParseWords;
|
|
34 use Benchmark;
|
|
35 use FileUtil;
|
|
36 use TextUtil;
|
|
37 use HTMLUtil;
|
|
38
|
|
39 my($ScriptName, %Options, $StartTime, $EndTime, $TotalTime);
|
|
40
|
|
41 # Autoflush STDOUT
|
|
42 $| = 1;
|
|
43
|
|
44 # Starting message...
|
|
45 $ScriptName = basename($0);
|
|
46 print "\n$ScriptName: Starting...\n\n";
|
|
47 $StartTime = new Benchmark;
|
|
48
|
|
49 # Get the options and setup script...
|
|
50 SetupScriptUsage();
|
|
51 if ($Options{help} || @ARGV < 1) {
|
|
52 die GetUsageFromPod("$FindBin::Bin/$ScriptName");
|
|
53 }
|
|
54
|
|
55 my(@TextFilesList);
|
|
56 @TextFilesList = ExpandFileNames(\@ARGV, "csv tsv");
|
|
57
|
|
58 print "Processing options...\n";
|
|
59 my(%OptionsInfo);
|
|
60 ProcessOptions();
|
|
61
|
|
62 print "Checking input text file(s)...\n";
|
|
63 my(%TextFilesInfo);
|
|
64 RetrieveTextFilesInfo();
|
|
65 SetupCoulmnsTablesAndMiscInfo();
|
|
66
|
|
67 # Generate output files...
|
|
68 my($FileIndex);
|
|
69 if (@TextFilesList > 1) {
|
|
70 print "\nProcessing text files...\n";
|
|
71 }
|
|
72 for $FileIndex (0 .. $#TextFilesList) {
|
|
73 if ($TextFilesInfo{FileOkay}[$FileIndex]) {
|
|
74 print "\nProcessing file $TextFilesList[$FileIndex]...\n";
|
|
75 GenerateHTMLTable($FileIndex);
|
|
76 }
|
|
77 }
|
|
78 print "\n$ScriptName:Done...\n\n";
|
|
79
|
|
80 $EndTime = new Benchmark;
|
|
81 $TotalTime = timediff ($EndTime, $StartTime);
|
|
82 print "Total time: ", timestr($TotalTime), "\n";
|
|
83
|
|
84 ###############################################################################
|
|
85
|
|
86 # Generate HTML table(s)...
|
|
87 sub GenerateHTMLTable {
|
|
88 my($Index) = @_;
|
|
89
|
|
90 if ($TextFilesInfo{MultipleHTMLTables}[$Index]) {
|
|
91 GenerateMultipleHTMLTable($Index);
|
|
92 }
|
|
93 else {
|
|
94 GenerateOneHTMLTable($Index);
|
|
95 }
|
|
96 }
|
|
97
|
|
98 # Generate one table...
|
|
99 sub GenerateOneHTMLTable {
|
|
100 my($Index) = @_;
|
|
101 my($TextFile, $TopHTMLDir, $HTMLFile, $Line, $StartRowNum, $EndRowNum, $CSSFile, $CSSFilePath, $CSSRef);
|
|
102
|
|
103 $HTMLFile = $TextFilesInfo{HTMLRoot}[$Index] . ".html";
|
|
104 $TextFile = $TextFilesList[$Index];
|
|
105
|
|
106 # Setup data directories...
|
|
107 ($TopHTMLDir) = SetupDataDirs($Index);
|
|
108
|
|
109 # Setup stylesheet file...
|
|
110 $CSSRef = "";
|
|
111 if ($Options{stylesheet} =~ /^new$/i) {
|
|
112 $CSSFile = $TextFilesInfo{HTMLRoot}[$Index] . ".css"; $CSSRef = ".\/" . "$CSSFile";
|
|
113 $CSSFilePath = "$TopHTMLDir" . "\/" . $CSSFile;
|
|
114 GenerateStyleSheetFile($CSSFilePath);
|
|
115 }
|
|
116 elsif ($Options{stylesheet} =~ /^old$/i) {
|
|
117 $CSSRef = $Options{stylesheetname};
|
|
118 }
|
|
119 # Set HTML file location...
|
|
120 $HTMLFile = "$TopHTMLDir" . "\/" . $HTMLFile;
|
|
121
|
|
122 print "Generating HTML file $HTMLFile...\n";
|
|
123 open HTMLFILE, ">$HTMLFile" or die "Error: Can't open $HTMLFile: $! \n";
|
|
124 open TEXTFILE, "$TextFile" or die "Error: Can't open $TextFile: $! \n";
|
|
125
|
|
126 # Write out HTML page header...
|
|
127 print HTMLFILE SetupHTMLPageHeader($TextFilesInfo{HTMLTitle}[$Index], $CSSRef);
|
|
128 if ($OptionsInfo{TitleDisplay}) {
|
|
129 print HTMLFILE SetupHTMLPageTitle($TextFilesInfo{HTMLTitle}[$Index]);
|
|
130 }
|
|
131 else {
|
|
132 print HTMLFILE SetupHTMLEmptyLines(1);
|
|
133 }
|
|
134
|
|
135 # Start the table...
|
|
136 print HTMLFILE SetupHTMLAlignmentBegin("center");
|
|
137 print HTMLFILE SetupHTMLTableHeader($OptionsInfo{TableBorder}, $OptionsInfo{TableCellPadding}, $OptionsInfo{TableCellSpacing});
|
|
138
|
|
139 WriteColLabels($Index, \*TEXTFILE, \*HTMLFILE);
|
|
140
|
|
141 # Skip the labels and write out all the other rows...
|
|
142 $Line = <TEXTFILE>;
|
|
143 $StartRowNum = 1;
|
|
144 $EndRowNum = $TextFilesInfo{LineCount}[$Index];
|
|
145 WriteRowValues($Index, $StartRowNum, $EndRowNum, \*TEXTFILE, \*HTMLFILE);
|
|
146
|
|
147 # Finish up the table...
|
|
148 print HTMLFILE SetupHTMLTableEnd();
|
|
149 print HTMLFILE SetupHTMLAlignmentEnd("center");
|
|
150
|
|
151 # Write out HTML page end...
|
|
152 print HTMLFILE SetupHTMLPageEnd($OptionsInfo{Footer});
|
|
153
|
|
154 close HTMLFILE;
|
|
155 close TEXTFILE;
|
|
156 }
|
|
157
|
|
158 # Generate multiple tables...
|
|
159 sub GenerateMultipleHTMLTable {
|
|
160 my($Index) = @_;
|
|
161 my($TopHTMLDir, $SubHTMLDir, $TextFile, $HTMLFile, $TableNum, $TableCount, $TableIndex, $TableStartLineNum, $TableEndLineNum, $Line, $InSubHTMLDir, $PrintMsg, $CSSFile, $CSSFilePath, $CSSRef, $NewStyleSheet);
|
|
162
|
|
163 # Open text file and skip over label line...
|
|
164 $TextFile = $TextFilesList[$Index];
|
|
165 open TEXTFILE, "$TextFile" or die "Error: Can't open $TextFile: $! \n";
|
|
166 $Line = <TEXTFILE>;
|
|
167
|
|
168 # Set up data directories to hold various html files...
|
|
169 ($TopHTMLDir, $SubHTMLDir) = SetupDataDirs($Index);
|
|
170
|
|
171 # Create stylesheet file...
|
|
172 $CSSRef = "";
|
|
173 $NewStyleSheet = 0;
|
|
174 if ($Options{stylesheet} =~ /^new$/i) {
|
|
175 $NewStyleSheet = 1;
|
|
176 $CSSFile = $TextFilesInfo{HTMLRoot}[$Index] . ".css";
|
|
177 $CSSFilePath = "$TopHTMLDir" . "\/" . $CSSFile;
|
|
178 GenerateStyleSheetFile($CSSFilePath);
|
|
179 }
|
|
180 elsif ($Options{stylesheet} =~ /^old$/i) {
|
|
181 $CSSRef = $Options{stylesheetname};
|
|
182 }
|
|
183
|
|
184 $PrintMsg = 1;
|
|
185 # Generate HTML files for all the tables...
|
|
186 $TableCount = $TextFilesInfo{TableCount}[$Index];
|
|
187 for $TableNum (1 .. $TableCount) {
|
|
188 $TableIndex = $TableNum - 1;
|
|
189 $HTMLFile = ${$TextFilesInfo{TableHTMLFiles}[$Index]}[$TableIndex];
|
|
190 $TableStartLineNum = ${$TextFilesInfo{TableStartLineNum}[$Index]}[$TableIndex];
|
|
191 $TableEndLineNum = ${$TextFilesInfo{TableEndLineNum}[$Index]}[$TableIndex];
|
|
192
|
|
193 # Setup file name...
|
|
194 if ($TableNum == 1) {
|
|
195 $HTMLFile = "$TopHTMLDir" . "\/" . $HTMLFile;
|
|
196 print "Generating HTML file $HTMLFile...\n";
|
|
197 }
|
|
198 else {
|
|
199 $HTMLFile = "$SubHTMLDir" . "\/" . $HTMLFile;
|
|
200 if ($PrintMsg) {
|
|
201 $PrintMsg = 0;
|
|
202 if ($TableCount == 2) {
|
|
203 print "Generating HTML file $HTMLFile...\n";
|
|
204 }
|
|
205 else {
|
|
206 print "Generating ", ($TableCount - 1), " other HTML files: $SubHTMLDir\/$TextFilesInfo{HTMLRoot}[$Index]\*.html...\n";
|
|
207 }
|
|
208 }
|
|
209 }
|
|
210 # Setup stylesheet reference...
|
|
211 if ($NewStyleSheet) {
|
|
212 $CSSRef = ($TableNum == 1) ? ".\/" : "..\/";
|
|
213 $CSSRef .= $CSSFile;
|
|
214 }
|
|
215
|
|
216 open HTMLFILE, ">$HTMLFile" or die "Error: Can't open $HTMLFile: $! \n";
|
|
217 # Write out HTML page header...
|
|
218 print HTMLFILE SetupHTMLPageHeader($TextFilesInfo{HTMLTitle}[$Index], $CSSRef);
|
|
219
|
|
220 # Set up the navigation links for this table...
|
|
221 if ($OptionsInfo{NavLinksAtTop}) {
|
|
222 WriteNavigationLinks($Index, $TableNum, \*HTMLFILE);
|
|
223 }
|
|
224 # Setup page title...
|
|
225 if ($OptionsInfo{TitleDisplay}) {
|
|
226 print HTMLFILE SetupHTMLPageTitle($TextFilesInfo{HTMLTitle}[$Index]);
|
|
227 }
|
|
228 else {
|
|
229 print HTMLFILE SetupHTMLEmptyLines(1);
|
|
230 }
|
|
231
|
|
232 # Start the table...
|
|
233 print HTMLFILE SetupHTMLAlignmentBegin("center");
|
|
234 print HTMLFILE SetupHTMLTableHeader($OptionsInfo{TableBorder}, $OptionsInfo{TableCellPadding}, $OptionsInfo{TableCellSpacing});
|
|
235
|
|
236 WriteColLabels($Index, \*TEXTFILE, \*HTMLFILE);
|
|
237
|
|
238 # Write out appropriate row data for this table...
|
|
239 WriteRowValues($Index, $TableStartLineNum, $TableEndLineNum, \*TEXTFILE, \*HTMLFILE);
|
|
240
|
|
241 # Finish up the table...
|
|
242 print HTMLFILE SetupHTMLTableEnd();
|
|
243 print HTMLFILE SetupHTMLAlignmentEnd("center");
|
|
244
|
|
245 # Set up the navigation links for this table...
|
|
246 if ($OptionsInfo{NavLinksAtBottom}) {
|
|
247 print HTMLFILE SetupHTMLEmptyLines(1);
|
|
248 WriteNavigationLinks($Index, $TableNum, \*HTMLFILE);
|
|
249 }
|
|
250
|
|
251 # Write out HTML page end...
|
|
252 print HTMLFILE SetupHTMLPageEnd($OptionsInfo{Footer});
|
|
253 close HTMLFILE;
|
|
254 }
|
|
255 close TEXTFILE;
|
|
256
|
|
257 }
|
|
258
|
|
259 # Create stylesheet file...
|
|
260 sub GenerateStyleSheetFile {
|
|
261 my($CSSFile) = @_;
|
|
262 print "Generating stylesheet file $CSSFile...\n";
|
|
263 open CSSFILE, ">$CSSFile" or die "Error: Can't open $CSSFile: $! \n";
|
|
264 print CSSFILE SetupHTMLStyleSheetTags();
|
|
265 close CSSFILE;
|
|
266 }
|
|
267
|
|
268 # Write out table header using column labels...
|
|
269 sub WriteColLabels {
|
|
270 my($Index, $TextFileRef, $HTMLFileRef) = @_;
|
|
271 my(@ColLabels, $Label);
|
|
272
|
|
273 print $HTMLFileRef $TextFilesInfo{TableRowHeaderTags};
|
|
274
|
|
275 @ColLabels = @{$TextFilesInfo{ColLabels}[$Index]};
|
|
276 for $Label (@ColLabels) {
|
|
277 print $HTMLFileRef SetupHTMLTableRowHeaderValue($Label);
|
|
278 }
|
|
279 print $HTMLFileRef $TextFilesInfo{RowEndTags};
|
|
280 }
|
|
281
|
|
282 #Write out the rows value...
|
|
283 sub WriteRowValues {
|
|
284 my($Index, $StartRowNum, $EndRowNum, $TextFileRef, $HTMLFileRef) = @_;
|
|
285 my($ColNum, $BackgroundColor, $FontColor, $LineCount, $Line, @RowValues, $Value, $InDelim, $LastColNum);
|
|
286
|
|
287 $InDelim = $TextFilesInfo{InDelim}[$Index];
|
|
288 $LastColNum = @{$TextFilesInfo{ColLabels}[$Index]} - 1;
|
|
289
|
|
290 for $LineCount ($StartRowNum .. $EndRowNum) {
|
|
291 $Line = GetTextLine($TextFileRef);
|
|
292
|
|
293 if ($OptionsInfo{ShadeRowsStatus}) {
|
|
294 print $HTMLFileRef ($LineCount % 2) ? $TextFilesInfo{BgFilledOddRowHeaderTags} : $TextFilesInfo{BgFilledEvenRowHeaderTags};
|
|
295 }
|
|
296 else {
|
|
297 print $HTMLFileRef $TextFilesInfo{RowHeaderTags};
|
|
298 }
|
|
299 @RowValues = quotewords($InDelim, 0, $Line);
|
|
300 for $ColNum (0 .. $LastColNum) {
|
|
301 $Value = ($ColNum <= $#RowValues) ? $RowValues[$ColNum] : "";
|
|
302 $BackgroundColor = ""; $FontColor = "";
|
|
303 if ($OptionsInfo{HighlightStatus}) {
|
|
304 if (exists($TextFilesInfo{HightlightColNumMap}[$Index]{$ColNum})) {
|
|
305 ($BackgroundColor, $FontColor) = GetValueHighlightColors($Index, $ColNum, $Value);
|
|
306 }
|
|
307 }
|
|
308 print $HTMLFileRef SetupHTMLTableRowDataValue($Value, $BackgroundColor, $FontColor);
|
|
309 }
|
|
310 print $HTMLFileRef $TextFilesInfo{RowEndTags};
|
|
311 }
|
|
312 }
|
|
313
|
|
314 # Setup navigation link information for each table.
|
|
315 #
|
|
316 # All table sets besides first and last have these links: FirstTable, Previous, Current-1,Current,Current+1, Next, and LastTable
|
|
317 # First set: Current, Next, and LastTable
|
|
318 # Last set: FirstTable, Previous and Current.
|
|
319 #
|
|
320 sub WriteNavigationLinks {
|
|
321 my($Index, $CurTableNum, $HTMLFileRef) = @_;
|
|
322 my($TableNum, $StartTableNum, $EndTableNum, $TableIndex, $BorderWidth, $CellPadding, $CellSpacing,$HTMLFile, $HTMLRefFile, $RelativeFileDir, $HTMLRefValue, $FirstTableNum, $FirstTableIndex, $LastTableNum, $LastTableIndex, $TableStartLineNum, $TableEndLineNum, $LastLineNum, $BGColor, $LinksOffSet);
|
|
323
|
|
324 $LinksOffSet = 10;
|
|
325
|
|
326 $FirstTableNum = 1; $FirstTableIndex = $FirstTableNum - 1;
|
|
327 $LastTableNum = $TextFilesInfo{TableCount}[$Index]; $LastTableIndex = $LastTableNum - 1;
|
|
328 $LastLineNum = ${$TextFilesInfo{TableEndLineNum}[$Index]}[$LastTableIndex];
|
|
329
|
|
330 # Figure out which links to display for a particular table...
|
|
331 $StartTableNum = $CurTableNum - $LinksOffSet + 1;
|
|
332 $StartTableNum = ($StartTableNum < $FirstTableNum) ? $FirstTableNum : $StartTableNum;
|
|
333 if ($CurTableNum < $LinksOffSet) {
|
|
334 $EndTableNum = $LinksOffSet;
|
|
335 }
|
|
336 else {
|
|
337 $EndTableNum = $CurTableNum + $LinksOffSet - 1;
|
|
338 }
|
|
339 $EndTableNum = ($EndTableNum > $LastTableNum) ? $LastTableNum : $EndTableNum;
|
|
340
|
|
341 my($InactiveLinkNumColor, $InactiveLinkFontBold) = ("#8e2323", "1");
|
|
342 my($LinkTextColor, $LinkBGColor, $LinkFontBold) = ("", "", "1");
|
|
343
|
|
344 # Start link table...
|
|
345 $BorderWidth = 0; $CellPadding = 2; $CellSpacing = 2;
|
|
346 print $HTMLFileRef SetupHTMLAlignmentBegin("center");
|
|
347 print $HTMLFileRef SetupHTMLDivBegin("tablenav");
|
|
348 print $HTMLFileRef SetupHTMLTableHeader($BorderWidth, $CellPadding, $CellSpacing);
|
|
349 print $HTMLFileRef $TextFilesInfo{RowHeaderTags};
|
|
350
|
|
351 if ($OptionsInfo{NavLinksTableInfo} && $OptionsInfo{NavLinksLineInfo}) {
|
|
352 print $HTMLFileRef SetupHTMLTableRowDataValue("Showing table $CurTableNum of $LastTableNum");
|
|
353 print $HTMLFileRef SetupHTMLTableRowDataValue(" ");
|
|
354 print $HTMLFileRef SetupHTMLTableRowDataValue(" ");
|
|
355 }
|
|
356
|
|
357 print $HTMLFileRef SetupHTMLTableRowDataValue("Tables: ");
|
|
358 # Setup a link to first table...
|
|
359 if ($StartTableNum != $FirstTableNum) {
|
|
360 $HTMLFile = ${$TextFilesInfo{TableHTMLFiles}[$Index]}[$FirstTableIndex];
|
|
361 $HTMLRefFile = GetRelativeFileDir($CurTableNum, $FirstTableNum, $FirstTableNum) . $HTMLFile;
|
|
362 $TableStartLineNum = ${$TextFilesInfo{TableStartLineNum}[$Index]}[$FirstTableIndex];
|
|
363 $TableEndLineNum = ${$TextFilesInfo{TableEndLineNum}[$Index]}[$FirstTableIndex];
|
|
364 $HTMLRefValue = SetupHTMLHRef("First", $HTMLRefFile, "First Table Containing Lines $TableStartLineNum To $TableEndLineNum");
|
|
365 print $HTMLFileRef SetupHTMLTableRowDataValue($HTMLRefValue, $LinkBGColor, $LinkTextColor, $LinkFontBold);
|
|
366 }
|
|
367
|
|
368 # Setup link to previous table...
|
|
369 if ($CurTableNum != $FirstTableNum) {
|
|
370 my($PreviousTableNum, $PreviousTableIndex);
|
|
371 $PreviousTableNum = $CurTableNum - 1; $PreviousTableIndex = $PreviousTableNum - 1;
|
|
372 $HTMLFile = ${$TextFilesInfo{TableHTMLFiles}[$Index]}[$PreviousTableIndex];
|
|
373 $HTMLRefFile = GetRelativeFileDir($CurTableNum, $PreviousTableNum, $FirstTableNum) . $HTMLFile;
|
|
374 $TableStartLineNum = ${$TextFilesInfo{TableStartLineNum}[$Index]}[$PreviousTableIndex];
|
|
375 $TableEndLineNum = ${$TextFilesInfo{TableEndLineNum}[$Index]}[$PreviousTableIndex];
|
|
376 $HTMLRefValue = SetupHTMLHRef("Previous", $HTMLRefFile, "Previous Table Containing Lines $TableStartLineNum To $TableEndLineNum");
|
|
377 print $HTMLFileRef SetupHTMLTableRowDataValue($HTMLRefValue, $LinkBGColor, $LinkTextColor, $LinkFontBold);
|
|
378 }
|
|
379
|
|
380 for $TableNum ($StartTableNum .. $EndTableNum) {
|
|
381 $TableIndex = $TableNum - 1;
|
|
382 $HTMLFile = ${$TextFilesInfo{TableHTMLFiles}[$Index]}[$TableIndex];
|
|
383 if ($TableNum == $CurTableNum) {
|
|
384 print $HTMLFileRef SetupHTMLTableRowDataValue($TableNum, $LinkBGColor, $InactiveLinkNumColor, $InactiveLinkFontBold);
|
|
385 }
|
|
386 else {
|
|
387 # Setup the link...
|
|
388 my($RefTitle);
|
|
389 $TableStartLineNum = ${$TextFilesInfo{TableStartLineNum}[$Index]}[$TableIndex];
|
|
390 $TableEndLineNum = ${$TextFilesInfo{TableEndLineNum}[$Index]}[$TableIndex];
|
|
391 $RefTitle = AddNumberSuffix($TableNum) . " Table Containing Lines $TableStartLineNum To $TableEndLineNum";
|
|
392 $HTMLRefFile = GetRelativeFileDir($CurTableNum, $TableNum, $FirstTableNum) . $HTMLFile;
|
|
393 $HTMLRefValue = SetupHTMLHRef($TableNum, $HTMLRefFile, $RefTitle);
|
|
394 print $HTMLFileRef SetupHTMLTableRowDataValue($HTMLRefValue);
|
|
395 }
|
|
396 }
|
|
397
|
|
398 # Setup link to next table...
|
|
399 if ($CurTableNum != $LastTableNum) {
|
|
400 my($NextTableNum, $NextTableIndex);
|
|
401 $NextTableNum = $CurTableNum + 1; $NextTableIndex = $NextTableNum - 1;
|
|
402 $HTMLFile = ${$TextFilesInfo{TableHTMLFiles}[$Index]}[$NextTableIndex];
|
|
403 $HTMLRefFile = GetRelativeFileDir($CurTableNum, $NextTableNum, $FirstTableNum) . $HTMLFile;
|
|
404 $TableStartLineNum = ${$TextFilesInfo{TableStartLineNum}[$Index]}[$NextTableIndex];
|
|
405 $TableEndLineNum = ${$TextFilesInfo{TableEndLineNum}[$Index]}[$NextTableIndex];
|
|
406 $HTMLRefValue = SetupHTMLHRef("Next", $HTMLRefFile, "Next Table Containing Lines $TableStartLineNum To $TableEndLineNum");
|
|
407 print $HTMLFileRef SetupHTMLTableRowDataValue($HTMLRefValue, $LinkBGColor, $LinkTextColor, $LinkFontBold);
|
|
408 }
|
|
409
|
|
410 # Setup link to last table...
|
|
411 if ($EndTableNum != $LastTableNum) {
|
|
412 $HTMLFile = ${$TextFilesInfo{TableHTMLFiles}[$Index]}[$LastTableIndex];
|
|
413 $HTMLRefFile = GetRelativeFileDir($CurTableNum, $LastTableNum, $FirstTableNum) . $HTMLFile;
|
|
414 $TableStartLineNum = ${$TextFilesInfo{TableStartLineNum}[$Index]}[$LastTableIndex];
|
|
415 $TableEndLineNum = ${$TextFilesInfo{TableEndLineNum}[$Index]}[$LastTableIndex];
|
|
416 $HTMLRefValue = SetupHTMLHRef("Last", $HTMLRefFile, "Last Table Containing Lines $TableStartLineNum To $TableEndLineNum");
|
|
417 print $HTMLFileRef SetupHTMLTableRowDataValue($HTMLRefValue, $LinkBGColor, $LinkTextColor, $LinkFontBold);
|
|
418 }
|
|
419 # Setup current table info text....
|
|
420 print $HTMLFileRef SetupHTMLTableRowDataValue(" ");
|
|
421 print $HTMLFileRef SetupHTMLTableRowDataValue(" ");
|
|
422 $TableStartLineNum = ${$TextFilesInfo{TableStartLineNum}[$Index]}[$CurTableNum - 1];
|
|
423 $TableEndLineNum = ${$TextFilesInfo{TableEndLineNum}[$Index]}[$CurTableNum - 1];
|
|
424 if ($OptionsInfo{NavLinksLineInfo}) {
|
|
425 print $HTMLFileRef SetupHTMLTableRowDataValue("Showing lines $TableStartLineNum to $TableEndLineNum of $LastLineNum");
|
|
426 }
|
|
427 else {
|
|
428 print $HTMLFileRef SetupHTMLTableRowDataValue("Showing table $CurTableNum of $LastTableNum");
|
|
429 }
|
|
430
|
|
431 print $HTMLFileRef $TextFilesInfo{RowEndTags};
|
|
432 # End link table...
|
|
433 print $HTMLFileRef SetupHTMLTableEnd();
|
|
434 print $HTMLFileRef SetupHTMLDivEnd();
|
|
435 print $HTMLFileRef SetupHTMLAlignmentEnd("center");
|
|
436 }
|
|
437
|
|
438 # Generate relative directory path...
|
|
439 sub GetRelativeFileDir {
|
|
440 my($FromTableNum, $ToTableNum, $FirstTableNum) = @_;
|
|
441 my($RelativeFileDir) = "";
|
|
442
|
|
443 if ($FromTableNum == $FirstTableNum) {
|
|
444 $RelativeFileDir = ($ToTableNum == $FirstTableNum) ? ".\/" : ".\/html\/";
|
|
445 }
|
|
446 else {
|
|
447 $RelativeFileDir = ($ToTableNum == $FirstTableNum) ? "..\/" : ".\/";
|
|
448 }
|
|
449 return $RelativeFileDir;
|
|
450 }
|
|
451
|
|
452 # Based on hightlight stype, return appropriate colors for background or text...
|
|
453 sub GetValueHighlightColors {
|
|
454 my($FileIndex, $ColNum, $Value) = @_;
|
|
455 my($DataType, $Criterion, $CriterionValue, $BgColor, $FontColor, $ValueOk, $Nothing);
|
|
456
|
|
457 $BgColor = ""; $FontColor = "";
|
|
458 $DataType = ${$TextFilesInfo{HightlightDataMap}[$FileIndex]{$ColNum}}[0];
|
|
459 $Criterion = ${$TextFilesInfo{HightlightDataMap}[$FileIndex]{$ColNum}}[1];
|
|
460 $CriterionValue = ${$TextFilesInfo{HightlightDataMap}[$FileIndex]{$ColNum}}[2];
|
|
461
|
|
462 $ValueOk = 0;
|
|
463 if ($DataType =~ /^numeric$/i) {
|
|
464 NUMSWITCH: {
|
|
465 if ($Criterion =~ /^ge$/i) { $ValueOk = ($Value >= $CriterionValue) ? 1 : 0; last NUMSWITCH; }
|
|
466 if ($Criterion =~ /^le$/i) { $ValueOk = ($Value <= $CriterionValue) ? 1 : 0; last NUMSWITCH; }
|
|
467 if ($Criterion =~ /^eq$/i) { $ValueOk = ($Value == $CriterionValue) ? 1 : 0; last NUMSWITCH; }
|
|
468 $Nothing = 1;
|
|
469 }
|
|
470 }
|
|
471 else {
|
|
472 TEXTSWITCH: {
|
|
473 if ($Criterion =~ /^ge$/i) { $ValueOk = ($Value ge $CriterionValue) ? 1 : 0; last TEXTSWITCH; }
|
|
474 if ($Criterion =~ /^le$/i) { $ValueOk = ($Value le $CriterionValue) ? 1 : 0; last TEXTSWITCH; }
|
|
475 if ($Criterion =~ /^eq$/i) { $ValueOk = ($Value eq $CriterionValue) ? 1 : 0; last TEXTSWITCH; }
|
|
476 $Nothing = 1;
|
|
477 }
|
|
478 }
|
|
479 $BgColor = $ValueOk ? $OptionsInfo{ValueOkColor} : $OptionsInfo{ValueNotOkColor};
|
|
480 if ($Options{highlightstyle} =~ /^text$/i) {
|
|
481 $BgColor = "";
|
|
482 $FontColor = $ValueOk ? $OptionsInfo{ValueOkColor} : $OptionsInfo{ValueNotOkColor};
|
|
483 }
|
|
484 return ($BgColor, $FontColor);
|
|
485 }
|
|
486
|
|
487 # Setup columns, tables and other information...
|
|
488 sub SetupCoulmnsTablesAndMiscInfo {
|
|
489 SetupColumnsToHighlightInfo();
|
|
490 SetupMultipleTablesInfo();
|
|
491 SetupHTMLTagsInfo();
|
|
492 }
|
|
493
|
|
494 # Setup columns to highlight information...
|
|
495 sub SetupColumnsToHighlightInfo {
|
|
496 my($ColID, $DataType, $Criterion, $Value, $Index, $ColNum, $ColLabel, $ColIndex);
|
|
497
|
|
498 @{$TextFilesInfo{HightlightColNumMap}} = ();
|
|
499 @{$TextFilesInfo{HightlightDataMap}} = ();
|
|
500
|
|
501 for $Index (0 .. $#TextFilesList) {
|
|
502 %{$TextFilesInfo{HightlightColNumMap}[$Index]} = ();
|
|
503 %{$TextFilesInfo{HightlightDataMap}[$Index]} = ();
|
|
504 if ($TextFilesInfo{FileOkay}[$Index]) {
|
|
505 SPECIFIEDCOLS: for $ColIndex (0 .. $#{$OptionsInfo{SpecifiedColIds}}) {
|
|
506 $ColID = $OptionsInfo{SpecifiedColIds}[$ColIndex];
|
|
507 $DataType = $OptionsInfo{SpecifiedColDataTypes}[$ColIndex];
|
|
508 $Criterion = $OptionsInfo{SpecifiedColCriteria}[$ColIndex];
|
|
509 $Value = $OptionsInfo{SpecifiedColValues}[$ColIndex];
|
|
510 if (!$OptionsInfo{HighlightStatus}) {
|
|
511 next SPECIFIEDCOLS;
|
|
512 }
|
|
513 if ($Options{highlightby} =~ /^colnum$/i) {
|
|
514 $ColNum = $ColID;
|
|
515 if ($ColNum > 0 && $ColNum <= $TextFilesInfo{ColCount}[$Index]) {
|
|
516 $ColNum -= 1;
|
|
517 }
|
|
518 else {
|
|
519 warn "Warning: Ignoring column number, $ColID, specifed in quartet, \"$ColID,$DataType,$Criterion,$Value\", using \"--highlight\" option for $TextFilesList[$Index]: it doesn't exists \n";
|
|
520 next SPECIFIEDCOLS;
|
|
521 }
|
|
522 }
|
|
523 else {
|
|
524 $ColLabel = $ColID;
|
|
525 if (exists($TextFilesInfo{ColLabelToNumMap}[$Index]{$ColLabel})) {
|
|
526 $ColNum = $TextFilesInfo{ColLabelToNumMap}[$Index]{$ColLabel};
|
|
527 } else {
|
|
528 warn "Warning: Ignoring column label, $ColID, specifed in quartet, \"$ColID,$DataType,$Criterion,$Value\", using \"--highlight\" option for $TextFilesList[$Index]: it doesn't exists \n";
|
|
529 next SPECIFIEDCOLS;
|
|
530 }
|
|
531 }
|
|
532 $TextFilesInfo{HightlightColNumMap}[$Index]{$ColNum} = $ColNum;
|
|
533 @{$TextFilesInfo{HightlightDataMap}[$Index]{$ColNum}} =();
|
|
534 push @{$TextFilesInfo{HightlightDataMap}[$Index]{$ColNum}}, ($DataType, $Criterion, $Value);
|
|
535 }
|
|
536 }
|
|
537 }
|
|
538 }
|
|
539
|
|
540 # Setup navigation link information for multiple tables...
|
|
541 sub SetupMultipleTablesInfo {
|
|
542 my($Index, $LinesPerTable);
|
|
543
|
|
544 $LinesPerTable = $Options{numrows};
|
|
545 @{$TextFilesInfo{TableCount}} = ();
|
|
546 @{$TextFilesInfo{TableHTMLFiles}} = ();
|
|
547 @{$TextFilesInfo{TableStartLineNum}} = ();
|
|
548 @{$TextFilesInfo{TableEndLineNum}} = ();
|
|
549
|
|
550 for $Index (0 .. $#TextFilesList) {
|
|
551 $TextFilesInfo{TableCount}[$Index] = 1;
|
|
552 @{$TextFilesInfo{TableHTMLFiles}[$Index]} = ();
|
|
553 @{$TextFilesInfo{TableStartLineNum}[$Index]} = ();
|
|
554 @{$TextFilesInfo{TableEndLineNum}[$Index]} = ();
|
|
555
|
|
556 if ($TextFilesInfo{FileOkay}[$Index]) {
|
|
557 if ($TextFilesInfo{MultipleHTMLTables}[$Index]) {
|
|
558 my($TableIndex, $TotalLines, $TableCount, $TableStartLineNum, $TableEndLineNum, $Name);
|
|
559
|
|
560 $TotalLines = $TextFilesInfo{LineCount}[$Index];
|
|
561 $TableCount = ($TotalLines % $LinesPerTable) ? (int($TotalLines/$LinesPerTable) + 1) : ($TotalLines/$LinesPerTable);
|
|
562 $TextFilesInfo{TableCount}[$Index] = $TableCount;
|
|
563 for $TableIndex (1 .. $TableCount) {
|
|
564 $TableStartLineNum = ($TableIndex - 1) * $LinesPerTable + 1;
|
|
565 $TableEndLineNum = ($TableIndex == $TableCount) ? $TotalLines : ($TableIndex * $LinesPerTable);
|
|
566 push @{$TextFilesInfo{TableStartLineNum}[$Index]}, $TableStartLineNum;
|
|
567 push @{$TextFilesInfo{TableEndLineNum}[$Index]}, $TableEndLineNum;
|
|
568
|
|
569 # Setup HTML file names for all the tables...
|
|
570 $Name = "Lines" . "$TableStartLineNum" . "To" . "$TableEndLineNum";
|
|
571 if ($TableIndex == 1) {
|
|
572 $Name = "";
|
|
573 }
|
|
574 $Name = $TextFilesInfo{HTMLRoot}[$Index] . $Name . ".html";
|
|
575 push @{$TextFilesInfo{TableHTMLFiles}[$Index]}, $Name;
|
|
576 }
|
|
577 #print "$TextFilesList[$Index]: $TableCount - @{$TextFilesInfo{TableStartLineNum}[$Index]} - @{$TextFilesInfo{TableEndLineNum}[$Index]} - @{$TextFilesInfo{TableHTMLFiles}[$Index]}\n";
|
|
578 }
|
|
579 }
|
|
580 }
|
|
581 }
|
|
582
|
|
583 # Setup HTML tags information...
|
|
584 sub SetupHTMLTagsInfo {
|
|
585 # Setup row tags...
|
|
586 $TextFilesInfo{RowHeaderTags} = "";
|
|
587 $TextFilesInfo{RowEndTags} = "";
|
|
588 $TextFilesInfo{BgFilledOddRowHeaderTags} = "";
|
|
589 $TextFilesInfo{BgFilledEvenRowHeaderTags} = "";
|
|
590 $TextFilesInfo{TableRowHeaderTags} = "";
|
|
591
|
|
592 $TextFilesInfo{RowHeaderTags} = SetupHTMLTableRowHeader($OptionsInfo{RowHAlignment}, "", $OptionsInfo{RowVAlignment});
|
|
593 $TextFilesInfo{RowEndTags} = SetupHTMLTableRowEnd();
|
|
594
|
|
595 if ($OptionsInfo{ShadeRowsStatus}) {
|
|
596 $TextFilesInfo{BgFilledOddRowHeaderTags} = SetupHTMLTableRowHeader($OptionsInfo{RowHAlignment}, $OptionsInfo{OddRowsShadeColor}, $OptionsInfo{RowVAlignment});
|
|
597 $TextFilesInfo{BgFilledEvenRowHeaderTags} = SetupHTMLTableRowHeader($OptionsInfo{RowHAlignment}, $OptionsInfo{EvenRowsShadeColor}, $OptionsInfo{RowVAlignment});
|
|
598 }
|
|
599
|
|
600 $TextFilesInfo{TableRowHeaderTags} = SetupHTMLTableRowHeader($OptionsInfo{TableHeaderRowHAlignment}, $OptionsInfo{TableHeaderRowColor}, $OptionsInfo{TableHeaderRowVAlignment});
|
|
601
|
|
602 }
|
|
603
|
|
604 #Make sure appropriate mode specific option values are specified...
|
|
605 sub ProcessOptions {
|
|
606
|
|
607 %OptionsInfo = ();
|
|
608
|
|
609 $OptionsInfo{RowHAlignment} = "left"; $OptionsInfo{RowVAlignment} = "middle";
|
|
610 if (exists($Options{align})) {
|
|
611 my (@AlignValues) = split ",", $Options{align};
|
|
612 if (@AlignValues == 2) {
|
|
613 $OptionsInfo{RowHAlignment} = $AlignValues[0];
|
|
614 $OptionsInfo{RowVAlignment} = $AlignValues[1];
|
|
615 }
|
|
616 elsif (@AlignValues == 1) {
|
|
617 $OptionsInfo{RowHAlignment} = $AlignValues[0];
|
|
618 }
|
|
619 else {
|
|
620 die "Error: Invalid number of values, ", scalar(@AlignValues) , ", specified by \"-a --align\" option.\nIt must contain only one or two value.\n";
|
|
621 }
|
|
622 if ($OptionsInfo{RowHAlignment} !~ /^(left|center|right)$/i) {
|
|
623 die "Error: The horizontal alignment value specified, $Options{align}, for option \"-a --align\" is not valid. Allowed values: left, center, or right\n";
|
|
624 }
|
|
625 if ($OptionsInfo{RowVAlignment} !~ /^(top|middle|bottom)$/i) {
|
|
626 die "Error: The horizontal alignment value specified, $Options{align}, for option \"-a --align\" is not valid. Allowed values: top, middle, or bottom\n";
|
|
627 }
|
|
628 }
|
|
629
|
|
630 $OptionsInfo{TableHeaderRowHAlignment} = "center"; $OptionsInfo{TableHeaderRowVAlignment} = "middle";
|
|
631 if (exists($Options{headeralign})) {
|
|
632 my (@AlignValues) = split ",", $Options{headeralign};
|
|
633 if (@AlignValues == 2) {
|
|
634 $OptionsInfo{TableHeaderRowHAlignment} = $AlignValues[0];
|
|
635 $OptionsInfo{TableHeaderRowVAlignment} = $AlignValues[1];
|
|
636 }
|
|
637 elsif (@AlignValues == 1) {
|
|
638 $OptionsInfo{TableHeaderRowHAlignment} = $AlignValues[0];
|
|
639 }
|
|
640 else {
|
|
641 die "Error: Invalid number of values, ", scalar(@AlignValues) , ", specified by \"--headeralign\" option.\nIt must contain only one or two value.\n";
|
|
642 }
|
|
643 if ($OptionsInfo{TableHeaderRowHAlignment} !~ /^(left|center|right)$/i) {
|
|
644 die "Error: The horizontal alignment value specified, $Options{headeralign}, for option \"--headeralign\" is not valid. Allowed values: left, center, or right\n";
|
|
645 }
|
|
646 if ($OptionsInfo{TableHeaderRowVAlignment} !~ /^(top|middle|bottom)$/i) {
|
|
647 die "Error: The horizontal alignment value specified, $Options{headeralign}, for option \"-a --headeralign\" is not valid. Allowed values: top, middle, or bottom\n";
|
|
648 }
|
|
649 }
|
|
650
|
|
651 $OptionsInfo{TitleDisplay} = ($Options{titledisplay} =~ /^yes$/i) ? 1 : 0;
|
|
652
|
|
653 if (exists($Options{border})) {
|
|
654 $OptionsInfo{TableBorder} = $Options{border};
|
|
655 }
|
|
656 else {
|
|
657 $OptionsInfo{TableBorder} = ($Options{mode} =~ /^(plain|highlight)$/i) ? 1 : 0;
|
|
658 }
|
|
659 $OptionsInfo{TableCellPadding} = $Options{cellpadding};
|
|
660 $OptionsInfo{TableCellSpacing} = $Options{cellspacing};
|
|
661 $OptionsInfo{Footer} = $Options{footer} ? $Options{footer} : "";
|
|
662
|
|
663 if ($Options{headercolor}) {
|
|
664 $OptionsInfo{TableHeaderRowColor} = $Options{headercolor};
|
|
665 }
|
|
666 else {
|
|
667 $OptionsInfo{TableHeaderRowColor} = ($Options{mode} =~ /^plain$/i) ? "" : "#ccccff";
|
|
668 }
|
|
669
|
|
670 $OptionsInfo{NavLinksAtBottom} = 1; $OptionsInfo{NavLinksAtTop} = 0;
|
|
671 if ($Options{displaylinks} =~ /^(both|top)$/i) {
|
|
672 $OptionsInfo{NavLinksAtTop} = 1;
|
|
673 }
|
|
674 $OptionsInfo{NavLinksTableInfo} = 1; $OptionsInfo{NavLinksLineInfo} = 0;
|
|
675 if ($Options{displaylinksinfo} =~ /^both$/i) {
|
|
676 $OptionsInfo{NavLinksLineInfo} = 1;
|
|
677 $OptionsInfo{NavLinksTableInfo} = 1;
|
|
678 }
|
|
679 elsif ($Options{displaylinksinfo} =~ /^line$/i) {
|
|
680 $OptionsInfo{NavLinksLineInfo} = 1;
|
|
681 $OptionsInfo{NavLinksTableInfo} = 0;
|
|
682 }
|
|
683
|
|
684 if ($Options{stylesheet} =~ /^old$/i ) {
|
|
685 if (!$Options{stylesheetname}) {
|
|
686 die "Error: No stylesheet name specified using \"--stylesheetname\" option: It is required for \"old\" value of \"-s --stylesheet\" option. \n";
|
|
687 }
|
|
688 }
|
|
689
|
|
690 my(@ColorValues);
|
|
691 $OptionsInfo{OddRowsShadeColor} = ""; $OptionsInfo{EvenRowsShadeColor} = ""; $OptionsInfo{ShadeRowsStatus} = 0;
|
|
692 if ($Options{mode} =~ /^(shade|shadedhighlight)$/i) {
|
|
693 $OptionsInfo{OddRowsShadeColor} = "#ffffff";
|
|
694 $OptionsInfo{EvenRowsShadeColor} = "#e0e0eb";
|
|
695 $OptionsInfo{ShadeRowsStatus} = 1;
|
|
696 if ($Options{shadecolor}) {
|
|
697 # Make sure only two value are specified...
|
|
698 @ColorValues = split ",", $Options{shadecolor};
|
|
699 if (@ColorValues == 2) {
|
|
700 $OptionsInfo{OddRowsShadeColor} = $ColorValues[0];
|
|
701 $OptionsInfo{EvenRowsShadeColor} = $ColorValues[1];
|
|
702 }
|
|
703 else {
|
|
704 die "Error: Invalid number of values, ", scalar(@ColorValues) , ", specified by \"--shadecolor\" option.\nIt must contain only two values.\n";
|
|
705 }
|
|
706 }
|
|
707 }
|
|
708 $OptionsInfo{ValueOkColor} = ""; $OptionsInfo{ValueNotOkColor} = ""; $OptionsInfo{HighlightStatus} = 0;
|
|
709 if ($Options{mode} =~ /^(highlight|shadedhighlight)$/i) {
|
|
710 my($HighlightMode, $HighlightBy);
|
|
711 $HighlightMode = $Options{mode}; $HighlightBy = $Options{highlightby};
|
|
712
|
|
713 $OptionsInfo{HighlightStatus} = 1;
|
|
714 $OptionsInfo{ValueOkColor} = "#0fff0f";
|
|
715 $OptionsInfo{ValueNotOkColor} = "#ff0f0f";
|
|
716 if ($Options{highlightstyle} =~ /^text$/i) {
|
|
717 $OptionsInfo{ValueOkColor} = "#0fbb0f";
|
|
718 $OptionsInfo{ValueNotOkColor} = "#ff0f0f";
|
|
719 }
|
|
720 if ($Options{highlightcolor}) {
|
|
721 # Make sure two values are specified...
|
|
722 @ColorValues = split ",", $Options{highlightcolor};
|
|
723 if (@ColorValues == 2) {
|
|
724 $OptionsInfo{ValueOkColor} = $ColorValues[0];
|
|
725 $OptionsInfo{ValueNotOkColor} = $ColorValues[1];
|
|
726 }
|
|
727 else {
|
|
728 die "Error: Invalid number of values, ", scalar(@ColorValues), ", specified by \"--highlightcolor\" option.\nIt must contain only two value for $HighlightMode value specified using \"-m --mode\" option.\n";
|
|
729 }
|
|
730 }
|
|
731 if (!$Options{highlight}) {
|
|
732 die "Error: Specify columns to be highlighted using \"--hightlight\" option\n";
|
|
733 }
|
|
734 # Retrieve quartet values from "hightlight" option...
|
|
735 my(@HighlightValueQuartets);
|
|
736
|
|
737 @HighlightValueQuartets = ();
|
|
738 @HighlightValueQuartets = split ",", $Options{highlight};
|
|
739 if ((@HighlightValueQuartets % 4)) {
|
|
740 die "Error: Quartets not found in values specified using \"--highlight\" option for $HighlightMode \"-m --mode\"\n";
|
|
741 }
|
|
742 # Process quartets...
|
|
743 my($Index, $Col, $DataType, $Criterion, $Value);
|
|
744
|
|
745 @{$OptionsInfo{SpecifiedColIds}} = ();
|
|
746 @{$OptionsInfo{SpecifiedColDataTypes}} = ();
|
|
747 @{$OptionsInfo{SpecifiedColCriteria}} = ();
|
|
748 @{$OptionsInfo{SpecifiedColValues}} = ();
|
|
749 for ($Index = 0; $Index < @HighlightValueQuartets; $Index = $Index + 4) {
|
|
750 $Col = $HighlightValueQuartets[$Index];
|
|
751 $DataType = $HighlightValueQuartets[$Index + 1];
|
|
752 $Criterion = $HighlightValueQuartets[$Index + 2];
|
|
753 $Value = $HighlightValueQuartets[$Index + 3];
|
|
754 if ($Options{highlightby} =~ /^colnum$/i ) {
|
|
755 if (!IsPositiveInteger($Col)) {
|
|
756 die "Error: Invalid column id, $Col, specified in quartet, \"$Col,$DataType,$Criterion,$Value\", using \"--hightlight\" option: It must be an integer value > 0 for $HighlightMode \"-m --mode\" and $HighlightBy \"--highlightby\" option values.\n";
|
|
757 }
|
|
758 }
|
|
759 if ($DataType !~ /^(numeric|text)$/i) {
|
|
760 die "Error: Invalid column data type, $DataType, specified in quartet, \"$Col,$DataType,$Criterion,$Value\", using \"--hightlight\" option: Valid values: numeric or text\n";
|
|
761 }
|
|
762 if ($Criterion !~ /^(eq|le|ge)$/i) {
|
|
763 die "Error: Invalid criterion value, $Criterion, specified in quartet, \"$Col,$DataType,$Criterion,$Value\", using \"--hightlight\" option: Valid values: le, ge, or eq\n";
|
|
764 }
|
|
765 if ($DataType =~ /^numeric$/i) {
|
|
766 if (!IsFloat($Value)) {
|
|
767 die "Error: Invalid criterion value, $Value, specified in quartet, \"$Col,$DataType,$Criterion,$Value\", using \"--hightlight\" option: numeric value required for numeric data type\n";
|
|
768 }
|
|
769 }
|
|
770 push @{$OptionsInfo{SpecifiedColIds}}, $Col;
|
|
771 push @{$OptionsInfo{SpecifiedColDataTypes}}, $DataType;
|
|
772 push @{$OptionsInfo{SpecifiedColCriteria}}, $Criterion;
|
|
773 push @{$OptionsInfo{SpecifiedColValues}}, $Value;
|
|
774 }
|
|
775 }
|
|
776 }
|
|
777
|
|
778 # Retrieve information about input text files...
|
|
779 sub RetrieveTextFilesInfo {
|
|
780 my($LineCount, $TextFile, $FileDir, $FileName, $HTMLFile, $CSSFile, $HTMLRoot, $HTMLTitle, $FileExt, $Index, $ColIndex, $ColNum, $ColLabel, $LinesCount, $InDelim, $Line, @LineWords, @ColLabels, $TopHTMLDir);
|
|
781
|
|
782 %TextFilesInfo = ();
|
|
783
|
|
784 @{$TextFilesInfo{FileOkay}} = ();
|
|
785 @{$TextFilesInfo{ColCount}} = ();
|
|
786 @{$TextFilesInfo{ColLabels}} = ();
|
|
787 @{$TextFilesInfo{ColLabelToNumMap}} = ();
|
|
788 @{$TextFilesInfo{LineCount}} = ();
|
|
789 @{$TextFilesInfo{InDelim}} = ();
|
|
790
|
|
791 @{$TextFilesInfo{HTMLRoot}} = ();
|
|
792 @{$TextFilesInfo{HTMLTitle}} = ();
|
|
793 @{$TextFilesInfo{MultipleHTMLTables}} = ();
|
|
794
|
|
795 @{$TextFilesInfo{TopHTMLDir}} = ();
|
|
796 @{$TextFilesInfo{SubHTMLDir}} = ();
|
|
797
|
|
798 FILELIST: for $Index (0 .. $#TextFilesList) {
|
|
799 $TextFile = $TextFilesList[$Index];
|
|
800
|
|
801 $TextFilesInfo{FileOkay}[$Index] = 0;
|
|
802 $TextFilesInfo{ColCount}[$Index] = 0;
|
|
803 $TextFilesInfo{LineCount}[$Index] = 0;
|
|
804 $TextFilesInfo{InDelim}[$Index] = "";
|
|
805 $TextFilesInfo{HTMLRoot}[$Index] = "";
|
|
806 $TextFilesInfo{HTMLTitle}[$Index] = "";
|
|
807 $TextFilesInfo{MultipleHTMLTables}[$Index] = 0;
|
|
808
|
|
809 @{$TextFilesInfo{ColLabels}[$Index]} = ();
|
|
810 %{$TextFilesInfo{ColLabelToNumMap}[$Index]} = ();
|
|
811
|
|
812 if (!(-e $TextFile)) {
|
|
813 warn "Warning: Ignoring file $TextFile: It doesn't exist\n";
|
|
814 next FILELIST;
|
|
815 }
|
|
816 if (!CheckFileType($TextFile, "csv tsv")) {
|
|
817 warn "Warning: Ignoring file $TextFile: It's not a csv or tsv file\n";
|
|
818 next FILELIST;
|
|
819 }
|
|
820 ($FileDir, $FileName, $FileExt) = ParseFileName($TextFile);
|
|
821 if ($FileExt =~ /^tsv$/i) {
|
|
822 $InDelim = "\t";
|
|
823 }
|
|
824 else {
|
|
825 $InDelim = "\,";
|
|
826 if ($Options{indelim} !~ /^(comma|semicolon)$/i) {
|
|
827 warn "Warning: Ignoring file $TextFile: The value specified, $Options{indelim}, for option \"--indelim\" is not valid for csv files\n";
|
|
828 next FILELIST;
|
|
829 }
|
|
830 if ($Options{indelim} =~ /^semicolon$/i) {
|
|
831 $InDelim = "\;";
|
|
832 }
|
|
833 }
|
|
834
|
|
835 if (!open TEXTFILE, "$TextFile") {
|
|
836 warn "Warning: Ignoring file $TextFile: Couldn't open it: $! \n";
|
|
837 next FILELIST;
|
|
838 }
|
|
839
|
|
840 $Line = GetTextLine(\*TEXTFILE);
|
|
841 @ColLabels = quotewords($InDelim, 0, $Line);
|
|
842 $LineCount = 0;
|
|
843 while (<TEXTFILE>) {
|
|
844 $LineCount++;
|
|
845 }
|
|
846 close TEXTFILE;
|
|
847
|
|
848 $FileDir = ""; $FileName = ""; $FileExt = "";
|
|
849 ($FileDir, $FileName, $FileExt) = ParseFileName($TextFile);
|
|
850 $HTMLRoot = $FileName;
|
|
851 if ($Options{root} && (@TextFilesList == 1)) {
|
|
852 my ($RootFileDir, $RootFileName, $RootFileExt) = ParseFileName($Options{root});
|
|
853 if ($RootFileName && $RootFileExt) {
|
|
854 $HTMLRoot = $RootFileName;
|
|
855 }
|
|
856 else {
|
|
857 $HTMLRoot = $Options{root};
|
|
858 }
|
|
859 }
|
|
860 $HTMLTitle = $HTMLRoot;
|
|
861 if ($Options{title} && (@TextFilesList == 1)) {
|
|
862 $HTMLTitle = $Options{title};
|
|
863 }
|
|
864 $HTMLFile = lc($HTMLRoot) . "-html";
|
|
865 if (!$Options{overwrite}) {
|
|
866 if (-d $HTMLFile) {
|
|
867 warn "Warning: Ignoring file $TextFile: The directory $HTMLFile already exists\n";
|
|
868 next FILELIST;
|
|
869 }
|
|
870 }
|
|
871
|
|
872 $TextFilesInfo{FileOkay}[$Index] = 1;
|
|
873 $TextFilesInfo{InDelim}[$Index] = $InDelim;
|
|
874 $TextFilesInfo{HTMLRoot}[$Index] = "$HTMLRoot";
|
|
875 $TextFilesInfo{HTMLTitle}[$Index] = "$HTMLTitle";
|
|
876
|
|
877 $TextFilesInfo{ColCount}[$Index] = @ColLabels;
|
|
878 push @{$TextFilesInfo{ColLabels}[$Index]}, @ColLabels;
|
|
879 for $ColNum (0 .. $#ColLabels) {
|
|
880 $ColLabel = $ColLabels[$ColNum];
|
|
881 $TextFilesInfo{ColLabelToNumMap}[$Index]{$ColLabel} = $ColNum;
|
|
882 }
|
|
883 $TextFilesInfo{LineCount}[$Index] = $LineCount;
|
|
884
|
|
885 if ($Options{numrows} == 0 || $LineCount <= $Options{numrows}) {
|
|
886 $TextFilesInfo{MultipleHTMLTables}[$Index] = 0;
|
|
887 }
|
|
888 else {
|
|
889 $TextFilesInfo{MultipleHTMLTables}[$Index] = 1;
|
|
890 }
|
|
891 # Setup HTML data directories paths...
|
|
892 $TopHTMLDir = lc($TextFilesInfo{HTMLRoot}[$Index]) . "-html";
|
|
893 $TextFilesInfo{TopHTMLDir}[$Index] = "$TopHTMLDir";
|
|
894 $TextFilesInfo{SubHTMLDir}[$Index] = "$TopHTMLDir\/html";
|
|
895 }
|
|
896 }
|
|
897
|
|
898 # Setup various data directories to hold HTML and other related files...
|
|
899 sub SetupDataDirs {
|
|
900 my($Index) = @_;
|
|
901 my($TopHTMLDir, $SubHTMLDir, $CreateTopHTMLDir, $CreateSubHTMLDir);
|
|
902
|
|
903 $TopHTMLDir = $TextFilesInfo{TopHTMLDir}[$Index];
|
|
904 $SubHTMLDir = $TextFilesInfo{SubHTMLDir}[$Index];
|
|
905
|
|
906 # Clean up existing directories...
|
|
907 if (-d $TopHTMLDir) {
|
|
908 unlink "<$TopHTMLDir/*.html>";
|
|
909 unlink "<$TopHTMLDir/*.css>";
|
|
910 }
|
|
911 if (-d $SubHTMLDir) {
|
|
912 unlink "<$SubHTMLDir/*.html>";
|
|
913 }
|
|
914 # What directories need to be created...
|
|
915 $CreateTopHTMLDir = (-d $TopHTMLDir) ? 0 : 1;
|
|
916
|
|
917 $CreateSubHTMLDir = 0;
|
|
918 if ($TextFilesInfo{MultipleHTMLTables}[$Index]) {
|
|
919 $CreateSubHTMLDir = (-d $SubHTMLDir) ? 0 : 1;
|
|
920 }
|
|
921
|
|
922 # Create appropriate directories...
|
|
923 if ($CreateTopHTMLDir) {
|
|
924 mkdir $TopHTMLDir or die "Couldn't mkdir $TopHTMLDir: $! \n";
|
|
925 }
|
|
926 if ($CreateSubHTMLDir) {
|
|
927 mkdir $SubHTMLDir or die "Error: Couldn't mkdir $SubHTMLDir: $! \n";
|
|
928 }
|
|
929 else {
|
|
930 unlink <$SubHTMLDir/*.html>;
|
|
931 }
|
|
932 return ($TopHTMLDir, $SubHTMLDir);
|
|
933 }
|
|
934
|
|
935 # Setup script usage and retrieve command line arguments specified using various options...
|
|
936 sub SetupScriptUsage {
|
|
937
|
|
938 # Retrieve all the options...
|
|
939 %Options = ();
|
|
940 $Options{indelim} = "comma";
|
|
941 $Options{numrows} = 50;
|
|
942
|
|
943 $Options{mode} = "shade";
|
|
944 $Options{highlightby} = "colnum";
|
|
945 $Options{highlightstyle} = "background";
|
|
946
|
|
947 $Options{cellpadding} = 2;
|
|
948 $Options{cellspacing} = 1;
|
|
949
|
|
950 $Options{displaylinks} = "both";
|
|
951 $Options{displaylinksinfo} = "both";
|
|
952 $Options{stylesheet} = "new";
|
|
953
|
|
954 $Options{titledisplay} = "yes";
|
|
955
|
|
956 if (!GetOptions(\%Options, "align|a=s", "border|b=i", "cellpadding=i", "cellspacing=i", "color|c=s", "footer=s", "displaylinks|d=s", "displaylinksinfo=s", "help|h", "headeralign=s", "headercolor=s", "highlight=s", "highlightby=s", "highlightcolor=s", "highlightstyle=s", "indelim=s", "mode|m=s", "numrows|n=i", "overwrite|o", "root|r=s", "shadecolor=s", "stylesheet=s", "stylesheetname=s", "title|t=s", "titledisplay=s", "workingdir|w=s")) {
|
|
957 die "\nTo get a list of valid options and their values, use \"$ScriptName -h\" or\n\"perl -S $ScriptName -h\" command and try again...\n";
|
|
958 }
|
|
959
|
|
960 if ($Options{workingdir}) {
|
|
961 if (! -d $Options{workingdir}) {
|
|
962 die "Error: The value specified, $Options{workingdir}, for option \"-w --workingdir\" is not a directory name.\n";
|
|
963 }
|
|
964 chdir $Options{workingdir} or die "Error: Couldn't chdir $Options{workingdir}: $! \n";
|
|
965 }
|
|
966 if ($Options{displaylinks} !~ /^(top|bottom|both)$/i) {
|
|
967 die "Error: The value specified, $Options{displaylinks}, for option \"-d --displaylinks\" is not valid. Allowed values: top, bottom, or both\n";
|
|
968 }
|
|
969 if ($Options{displaylinksinfo} !~ /^(line|table|both)$/i) {
|
|
970 die "Error: The value specified, $Options{displaylinksinfo}, for option \"--displaylinksinfo\" is not valid. Allowed values: line, table, or both\n";
|
|
971 }
|
|
972 if ($Options{indelim} !~ /^(comma|semicolon)$/i) {
|
|
973 die "Error: The value specified, $Options{indelim}, for option \"--indelim\" is not valid. Allowed values: comma or semicolon\n";
|
|
974 }
|
|
975 if ($Options{highlightby} !~ /^(colnum|collabel)$/i) {
|
|
976 die "Error: The value specified, $Options{highlightby}, for option \"--highlightby\" is not valid. Allowed values: colnum or collabel\n";
|
|
977 }
|
|
978 if ($Options{highlightstyle} !~ /^(background|text)$/i) {
|
|
979 die "Error: The value specified, $Options{highlightstyle}, for option \"--highlightstyle\" is not valid. Allowed values: background or text\n";
|
|
980 }
|
|
981 if ($Options{mode} !~ /^(plain|shade|highlight|shadedhighlight)$/i) {
|
|
982 die "Error: The value specified, $Options{mode}, for option \"-m --mode\" is not valid. Allowed values: plain, shade, hightlight, or shadedhighlight\n";
|
|
983 }
|
|
984 if ($Options{stylesheet} !~ /^(old|new|none)$/i) {
|
|
985 die "Error: The value specified, $Options{stylesheet}, for option \"-s --stylesheet\" is not valid. Allowed values: old, new, or none\n";
|
|
986 }
|
|
987 if ($Options{numrows} < 0) {
|
|
988 die "Error: The value specified, $Options{numrows}, for option \"-n --numrows\" is not valid. Allowed values: >= 0 \n";
|
|
989 }
|
|
990 if ($Options{titledisplay} !~ /^(yes|no)$/i) {
|
|
991 die "Error: The value specified, $Options{titledisplay}, for option \"--titledisplay\" is not valid. Allowed values: yes or no\n";
|
|
992 }
|
|
993 if (exists($Options{border})) {
|
|
994 if ($Options{border} < 0) {
|
|
995 die "Error: The value specified, $Options{border}, for option \"--border\" is not valid. Allowed values: >= 0 \n";
|
|
996 }
|
|
997 }
|
|
998 if ($Options{cellpadding} < 0) {
|
|
999 die "Error: The value specified, $Options{cellpadding}, for option \"--cellpadding\" is not valid. Allowed values: >= 0 \n";
|
|
1000 }
|
|
1001 if ($Options{cellspacing} < 0) {
|
|
1002 die "Error: The value specified, $Options{cellspacing}, for option \"--cellspacing\" is not valid. Allowed values: >= 0 \n";
|
|
1003 }
|
|
1004 }
|
|
1005
|
|
1006 __END__
|
|
1007
|
|
1008 =head1 NAME
|
|
1009
|
|
1010 TextFilesToHTML.pl - Generate HTML table file(s) from TextFile(s)
|
|
1011
|
|
1012 =head1 SYNOPSIS
|
|
1013
|
|
1014 TextFilesToHTML.pl ... TextFile(s)...
|
|
1015
|
|
1016 TextFilesToHTML.pl [B<-a, --align> left | center | right,[top | middle | bottom]] [B<-b, --border> borderwidth] [B<--cellpadding> padding]
|
|
1017 [B<--cellspacing> spacing] [B<--footer> string] [B<-d, --displaylinks> top | bottom | both]
|
|
1018 [B<--displaylinksinfo> line | table | both] [B<-h, --help>]
|
|
1019 [B<--headeralign> left | center | right,[top | middle | bottom]] [B<--headercolor> "#RRGGBB"]
|
|
1020 [B<--highlight> "fieldlabel,datatype,criterion,value,[fieldlabel,datatype,criterion,value,]..."]
|
|
1021 [B<--highlightby> colnum | collabel] [B<--highlightcolor> "#RRGGBB,#RRGGBB"]
|
|
1022 [B<--highlightstyle> text | background] [B<--indelim> comma | semicolon] [B<-m, --mode> plain | shade | highlight | shadedhighlight]
|
|
1023 [B<-n, --numrows> number] [B<-o, --overwrite>] [B<-r, --root> rootname]
|
|
1024 [B<--stylesheet> old | new | none] [B<--stylesheetname> filename] [B< --shadecolor> "#RRGGBB,#RRGGBB"]
|
|
1025 [B<-t, --title> string] [B<--titledisplay> yes | no] [B<-w, --workingdir> dirname] TextFile(s)...
|
|
1026
|
|
1027 =head1 DESCRIPTION
|
|
1028
|
|
1029 Generate HTML file(s) from I<TextFile(s)>. The HTML file(s) contain data tables and appropriate
|
|
1030 navigational links to view other tables. These files can be generated for local viewing or
|
|
1031 deployment on a web server. A variety of options are provided to control style and
|
|
1032 appearence of tables.
|
|
1033
|
|
1034 Multiple I<TextFile(s)> names are separated by spaces. The valid file extensions are I<.csv> and
|
|
1035 I<.tsv> for comma/semicolon and tab delimited text files respectively. All other file names
|
|
1036 are ignored. All the text files in a current directory can be specified by I<*.csv>,
|
|
1037 I<*.tsv>, or the current directory name. The B<--indelim> option determines the
|
|
1038 format of I<TextFile(s)>. Any file which doesn't correspond to the format indicated
|
|
1039 by B<--indelim> option is ignored.
|
|
1040
|
|
1041 =head1 OPTIONS
|
|
1042
|
|
1043 =over 4
|
|
1044
|
|
1045 =item B<-a, --align> I<left | center | right,[top | middle | bottom]>
|
|
1046
|
|
1047 Horizontal and vertical alignment for table rows except for header row which is specified
|
|
1048 using B<--headeralign> option. Possible horizontal alignment values: I<left, center, or right>.
|
|
1049 Possible vertical alignment values: I<top, middle, or bottom>.
|
|
1050
|
|
1051 Default values: I<left,middle>
|
|
1052
|
|
1053 =item B<-b, --border> I<borderwidth>
|
|
1054
|
|
1055 Table border width. Default value: 1 for I<plain> and I<highlight> mode; 0 for I<shade>
|
|
1056 and I<shadedhightlight> mode. Zero indicates no border.
|
|
1057
|
|
1058 =item B<--cellpadding> I<padding>
|
|
1059
|
|
1060 Table cell padding. Default value: I<2>.
|
|
1061
|
|
1062 =item B<--cellspacing> I<spacing>
|
|
1063
|
|
1064 Table cell spacing. Default value: I<1>.
|
|
1065
|
|
1066 =item B<--footer> I<string>
|
|
1067
|
|
1068 Text string to be included at bottom of each HTML file. Default: none.
|
|
1069
|
|
1070 =item B<-d, --displaylinks> I<top | bottom | both>
|
|
1071
|
|
1072 Specify where to display navigation links in each HTML file for accessing all other HTML
|
|
1073 files. Possible values: I<top, bottom, or both>. Default value: I<both>. This option is
|
|
1074 only valid during multiple HTML files generation for an input file.
|
|
1075
|
|
1076 =item B<--displaylinksinfo> I<line | table | both>
|
|
1077
|
|
1078 Control display of additional information along with navigational links: Showing line
|
|
1079 n of m is displyed for line and showing table n of m for table. Possible values: I<line
|
|
1080 | table | both>. Default: I<both>. This option is only valid during multiple HTML files generation.
|
|
1081
|
|
1082 =item B<-h, --help>
|
|
1083
|
|
1084 Print this help message
|
|
1085
|
|
1086 =item B<--headeralign> I<left | center | right,[top | middle | bottom]>
|
|
1087
|
|
1088 Horizontal and vertical alignment for table header rows. Possible horizontal alignment
|
|
1089 values: I<left, center, or right>. Possible vertical alignment values: I<top, middle, or bottom>.
|
|
1090
|
|
1091 Default values: I<center,middle>
|
|
1092
|
|
1093 =item B<--headercolor> I<"#RRGGBB">
|
|
1094
|
|
1095 Color used to fill background of table header row containing column labels
|
|
1096 represented as a hexadecimal string. None for B<-m, --mode> option value
|
|
1097 of I<plain> and I<#ccccff>, light blue, for others.
|
|
1098
|
|
1099 =item B<--highlight> I<"fieldlabel,datatype,criterion,value,[fieldlabel,datatype,criterion,value,]...">
|
|
1100
|
|
1101 This value is mode specific. It specifies how to highlight various column values
|
|
1102 for each text file. Same set of quartets values are applied to all I<TextFile(s)>.
|
|
1103
|
|
1104 For I<highlightbycolnum> mode, input text format contains these quartets:
|
|
1105 I<colnum,datatype,criterion,value,...>. Possible datatype values: I<numeric or text>.
|
|
1106 Possible criterion values: I<le, ge, or eq>. Examples: "1,numeric,le,450>" or
|
|
1107 "2,numeric,ge,150,6,numeric,le,10".
|
|
1108
|
|
1109 For I<highlightbycollabel> mode, input text format contains these quartets:
|
|
1110 I<collabel,datatype,criterion,value,...>.
|
|
1111
|
|
1112 =item B<--highlightby> I<colnum | collabel>
|
|
1113
|
|
1114 This value is mode specific. It indicates how columns to be highlighted are specified
|
|
1115 using B<--hightlight> option. Possible values: I<colnum or collabel>. Default value: I<colnum>.
|
|
1116
|
|
1117 =item B<--highlightcolor> I<"#RRGGBB,#RRGGBB">
|
|
1118
|
|
1119 Colors used to highlight column values during I<highlight> and I<shadedhightlight>
|
|
1120 mode represented as hexadecimal strings.
|
|
1121
|
|
1122 For B<--highlighstyle> option values of I<text> and I<background>, these colors represent
|
|
1123 text or background colors respectively. For a specific column, first color string is used for
|
|
1124 values which meet criterion indicated by B<--highlight> option; the second color is used
|
|
1125 for rest of the values.
|
|
1126
|
|
1127 Default values for I<background> B<--highlightstyle>: I<#0fff0f,#ff0f0f>. And default values for
|
|
1128 I<text> B<--highlightstyle>: I<#0fbb0f,#ff0f0f>. Hexadecimal strings for both B<--highlightstyle>
|
|
1129 colors correspond to I<reddish> and I<greenish>.
|
|
1130
|
|
1131 =item B<--highlightstyle> I<text | background>
|
|
1132
|
|
1133 This value is mode specific. It indicates highlight style used to differentiate column
|
|
1134 values which pass a specified criterion from others. Possible values: I<text or
|
|
1135 background>. Default: I<background>.
|
|
1136
|
|
1137 =item B<--indelim> I<comma | semicolon>
|
|
1138
|
|
1139 Input delimiter for CSV I<TextFile(s)>. Possible values: I<comma or semicolon>.
|
|
1140 Default value: I<comma>. For TSV files, this option is ignored and I<tab> is used as a
|
|
1141 delimiter.
|
|
1142
|
|
1143 =item B<-m, --mode> I<plain | shade | highlight | shadedhighlight>
|
|
1144
|
|
1145 Specify how to generate HTML table(s): plain tables with line borders, background of
|
|
1146 alternate rows filled with a specified color, column values hightlighted using a specified
|
|
1147 criteria, or combination of previous two styles.
|
|
1148
|
|
1149 Possible values: I<plain, shade, highlight, or shadedhighlight>. Default: I<shade>.
|
|
1150
|
|
1151 =item B<-n, --numrows> I<number>
|
|
1152
|
|
1153 Maximum number of rows per table. Default value: I<100>. Use 0 to put all rows into
|
|
1154 one table. For I<TextFile(s)> with more than maximum number of specified rows,
|
|
1155 multiple HTML tables, with appropriate navigation links, are created.
|
|
1156
|
|
1157 =item B<-o, --overwrite>
|
|
1158
|
|
1159 Overwrite existing files.
|
|
1160
|
|
1161 =item B<-r, --root> I<rootname>
|
|
1162
|
|
1163 New file or directory name is generated using the root: <root>.html or <root>-html.
|
|
1164 Default new file name: <InitialTextFileName>.html. Default directory name:
|
|
1165 <InitialTextFileName>-html.
|
|
1166
|
|
1167 For I<TextFile(s)> with more than maximum number of rows specified per table,
|
|
1168 this directory tree is generated using <Name> where <Name> corresponds to <root>
|
|
1169 or <InitialTextFileName>:Top dir - <Name>-html; Sub dirs - html and mols. <Top dir> contains
|
|
1170 <Name>.html and <Name>.css files and <sub dir> html conatins various
|
|
1171 <Name>Lines<Start>To<End>.html files; <sub dir> mols is created as needed and contains
|
|
1172
|
|
1173 This option is ignored for multiple input files.
|
|
1174
|
|
1175 =item B<--stylesheet> I<old | new | none>
|
|
1176
|
|
1177 Controls usage of stylesheet for newly generated HTML file(s). Possible values: I<old,
|
|
1178 new, or none>. Default value: I<new>.
|
|
1179
|
|
1180 Stylesheet file contains various properties which control apperance of HTML pages:
|
|
1181 type, size, and color of fonts; background color; and so on.
|
|
1182
|
|
1183 For I<old> value, an existing stylesheet file specified by B<--stylesheetname> option is
|
|
1184 used for each HTML file; no new stylesheet file is created. This option is quite handy
|
|
1185 for deploying HTML file(s) on a web server: assuming you specify a valid stylesheet
|
|
1186 file location relative to your WWWRoot, a reference to this stylesheet is added to each
|
|
1187 HTML file. For local deployment of HTML file(s), a complete path to a local stylesheet
|
|
1188 is fine as well.
|
|
1189
|
|
1190 For I<create> value, a new stylesheet is created and reference to this local stylesheet
|
|
1191 is added to each HTML file. Use option B<--stylesheetname> to specify name.
|
|
1192
|
|
1193 For I<none> value, stylesheet usage is completely ignored.
|
|
1194
|
|
1195 =item B<--stylesheetname> I<filename>
|
|
1196
|
|
1197 Stylesheet file name to be used in conjunction with B<-s --stylesheet> option. It is only
|
|
1198 valid for I<old> value of B<-s --stylesheet> option. Specify a valid stylesheet file location
|
|
1199 relative to your WWWRoot and a reference to this stylesheet is added to each HTML
|
|
1200 file. Example: "/stylesheets/MyStyleSheet.css". Or a complete path name to a local
|
|
1201 stylesheet file.
|
|
1202
|
|
1203 For I<create> value of B<-s --stylesheet> option, a new stylesheet file is created using
|
|
1204 B<-r --root> option. And value of B<--stylesheetname> is simply ignored.
|
|
1205
|
|
1206 =item B< --shadecolor> I<"#RRGGBB,#RRGGBB">
|
|
1207
|
|
1208 Colors used to fill background of rows during I<shade> and I<shadedhightlight> mode
|
|
1209 represented as a pair of hexadecimal string; the first and second color values
|
|
1210 are used for odd and even number rows respectively.
|
|
1211
|
|
1212 Default value: I<"#ffffff,#e0e9eb"> - it's white and very light blue for odd and even number rows.
|
|
1213
|
|
1214 =item B<-t, --title> I<string>
|
|
1215
|
|
1216 Title for HTML table(s). Default value: <TextFileName>. For multiple input files,
|
|
1217 B<-r --root> option is used to generate appropriate titles.
|
|
1218
|
|
1219 =item B<--titledisplay> I<yes | no>
|
|
1220
|
|
1221 Display title for HTML table(s). Possible values: I<yes or no>. Default value: I<yes>.
|
|
1222
|
|
1223 =item B<-w, --workingdir> I<dirname>
|
|
1224
|
|
1225 Location of working directory. Default: current directory.
|
|
1226
|
|
1227 =back
|
|
1228
|
|
1229 =head1 EXAMPLES
|
|
1230
|
|
1231 To generate HTML tables with rows background filled with white and greyish colors and
|
|
1232 navigation links on top and botton of each page, type:
|
|
1233
|
|
1234 % TextFilesToHTML.pl -o Sample1.csv
|
|
1235
|
|
1236 To generate HTML tables with rows background filled with golden and greyish colors,
|
|
1237 navigation links on top and botton of each page, 10 rows in each table, greyish header
|
|
1238 row color, and cell spacing of 1, type:
|
|
1239
|
|
1240 % TextFilesToHTML.pl -o -n 10 --headeralign "center" --headercolor
|
|
1241 "#a1a1a1" --shadecolor "#ddd700,#d1d1d1" --cellspacing 1
|
|
1242 Sample1.csv
|
|
1243
|
|
1244 To generate plain HTML tables with 10 rows in each table and navigation links only at
|
|
1245 the bottom, type:
|
|
1246
|
|
1247 % TextFilesToHTML.pl -o -n 10 --displaylinks bottom -m plain
|
|
1248 Sample1.csv
|
|
1249
|
|
1250 To highlight values in column 3 using specified highlight criteria and fill in default background
|
|
1251 colors, type:
|
|
1252
|
|
1253 % TextFilesToHTML.pl -n 10 --highlight "3,numeric,le,450"
|
|
1254 --highlightby colnum --highlightstyle background -m
|
|
1255 shadedhighlight -o Sample1.csv
|
|
1256
|
|
1257 To highlight values in column MolWeight using specified highlight criteria, color the text using
|
|
1258 default colors, and add a footer message in every page, type:
|
|
1259
|
|
1260 % TextFilesToHTML.pl -n 4 --highlight "MolWeight,numeric,le,500"
|
|
1261 --highlightby collabel --highlightstyle text -m shadedhighlight -o
|
|
1262 --footer "Copyright (C) MayaChemTools" --cellspacing 1 Sample1.csv
|
|
1263
|
|
1264 =head1 AUTHOR
|
|
1265
|
|
1266 Manish Sud <msud@san.rr.com>
|
|
1267
|
|
1268 =head1 SEE ALSO
|
|
1269
|
|
1270 JoinTextFiles.pl, MergeTextFilesWithSD.pl, ModifyTextFilesFormat.pl, SplitTextFiles.pl, SortTextFiles.pl
|
|
1271
|
|
1272 =head1 COPYRIGHT
|
|
1273
|
|
1274 Copyright (C) 2015 Manish Sud. All rights reserved.
|
|
1275
|
|
1276 This file is part of MayaChemTools.
|
|
1277
|
|
1278 MayaChemTools is free software; you can redistribute it and/or modify it under
|
|
1279 the terms of the GNU Lesser General Public License as published by the Free
|
|
1280 Software Foundation; either version 3 of the License, or (at your option)
|
|
1281 any later version.
|
|
1282
|
|
1283 =cut
|