Debian Codegraph @

reports/gen_index

raw
1 #! /usr/bin/perl -w
2
3 # Parse lifeline reports programs and generate a index
4 # Written by Stephen Dum [email protected]
5 # January 2003
6
7 use strict;
8
9 my $debug = 0; #non-zero to enable debug output
10 my $viewoutput = 0; #non-zero to enable printing output information
11
12 sub usage {
13 print "usage: $0 <llprog> ...\n";
14 print(" generate index.html file from all programs listed\n");
15 exit(0);
16 }
17
18 # parse arguments
19 while (defined($_=$ARGV[0]) && /^-/) {
20 shift;
21 /-d/ && ($debug++,next);
22 /-o/ && ($viewoutput++,next);
23 /-h/ && usage();
24 }
25
26 open OUT,">temp.html" or die "Unable to open temp.html for output";
27 print_header();
28 read_files();
29 print_trailer();
30 rename("temp.html","index.html");
31
32
33
34 sub print_header {
35 print OUT <<EOF
36 <?xml version="1.0" encoding="iso-8859-1"?>
37 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
38 "http://www.w3.org/TR/html4/loose.dtd">
39 <html lang="en" >
40 <head>
41 <title>Report programs for use with Lifelines genealogy Software</title>
42 <style TYPE="text/css" TITLE="Bright Colours">
43 A:link, A:active
44 {
45 text-decoration : none;
46 color : #ff0000;
47 background : transparent;
48 }
49 A:visited
50 {
51 text-decoration : none;
52 color : #993300;
53 background : transparent;
54 }
55 A:hover {
56 text-decoration : none;
57 color : #000000;
58 background : #ffcc00;
59 }
60 </style>
61 </head>
62
63 <body text="#000080" bgcolor="#F4ECBE">
64 <table width="100%">
65 <tr>
66 <td width="33%">
67 <img src="boc.gif" alt="LifeLines stork logo">
68 <br>
69
70 <hr>
71 </td>
72 <td width="34%">
73 <center>
74 <img src="ll.png" alt="LifeLines, second generation genealogy software">
75 <br>
76 <font size="+3">Report Programs</font>
77 </center>
78 </td>
79 <td width="33%"></td>
80 </tr>
81 </table>
82 <P>
83 This is an overview of the report programs distributed with Lifelines.
84 If you want more information about a program, often there are comments
85 at the beginning of the program that talk about functionality and algorithms,
86 that have sample output and examples of post processing commands required to
87 properly view the results.
88 Some programs require customization before use, for example, they might
89 have text identifying the person who generated the report.
90 <dl>
91 EOF
92 }
93 sub print_trailer {
94 my $today = `date "+%d %b %Y"`;
95 print OUT <<EOF
96 </DL>
97 <center>
98 <small>
99 This overview was generated
100 $today
101 </small>
102 </center>
103 <!- generated automatically by gen_index, written by Stephen Dum
104 -->
105 </body>
106 EOF
107 }
108 sub read_files {
109 my $file;
110 my $prog;
111 my $progname;
112 my $version;
113 my $author;
114 my $category;
115 my $output;
116 my $description;
117 my $char_encoding;
118 while ($file = shift @ARGV ) {
119 print $file . "\n" if $debug;
120 next if $file =~ /\.li$/;
121 if ($file eq "least_related.ll") {
122 print "Skipping $file\n";
123 next;
124 }
125 $prog = $file;
126 $prog =~ s/.ll$//; #strip off .ll
127 $prog =~ s/.*\/reports\///; #strip off any path prefix on filename
128 # that includes '/reports/'
129 open(FIN,$file) or die "Unable to open $file for input";
130 $progname="";
131 $version="";
132 $author="";
133 $category="";
134 $output="";
135 $description="";
136 $char_encoding="";
137 while (<FIN>) {
138 if (/^.*\@progname\s*(.*)\s*$/) {
139 print " progname: $1\n" if $debug;
140 $progname=$1;
141 } elsif (/^.*\@version\s*(.*)\s*$/) {
142 print " version: $1\n" if $debug;
143 $version=$1;
144 } elsif (/^.*\@author\s*(.*)\s*$/) {
145 print " author: $1\n" if $debug;
146 $author=$1;
147 } elsif (/^.*\@category\s*(.*)\s*$/) {
148 print " category: $1\n" if $debug;
149 $category=$1;
150 } elsif (/^.*\@output\s*(.*)\s*$/) {
151 print " output: $1\n" if $debug || $viewoutput;
152 print "$file output: $1\n" if $viewoutput == 2;
153 $output=$1;
154 } elsif (/^.*\@description\s*(.*)\s*$/) {
155 print " description: $1\n" if $debug;
156 #$description=$1;
157 if (length($description) == 0) {
158 while(<FIN>) {
159 # skip blank lines
160 last unless /^\s*\**\s*$/;
161 }
162 s/^\s*\**\s*//;
163 $description=$_;
164 while(<FIN>) {
165 # collect descriptin until we get a blank line
166 # or end of the comment
167 last if /^\s*\**\s*$/ || /\*\//;
168 s/^\s*\**\s*//;
169 $description .= $_;
170 }
171
172 }
173 } elsif (/\*\//) {
174 print "End of program meta tags at line $. for file $file\n" if $debug;
175 last;
176 }
177 }
178 while(<FIN>) {
179 next unless /\s*char_encoding\("(.*)"\)/;
180 $char_encoding = $1;
181 last;
182 }
183 close(FIN);
184 #print OUT "<dt><b><a href=\"$file\">$prog\n</a></b><dd>";
185 print OUT "<dt><b>$prog</b>\n<dd>";
186 print OUT "Version $version; " if length($version) != 0;
187 print OUT "by $author" if length($author) != 0;
188 print OUT "; output format $output" if length($output) != 0;
189 print OUT "; char encoding $char_encoding" if length($char_encoding) != 0;
190 $description =~ s/\</&lt;/g;
191 print OUT ".\n<br>\n$description";
192 }
193 }
194