Fixed DNS issues with ubuntu-9.10
[people/pravin/BKO.git] / Troubleshooting / makefaq.pl
1 #!/usr/bin/perl
2
3 # makefaq.pl
4 # Author: John "warthog9" Hawley
5 # License: GPL
6 # Date Created: 09/30/2005
7 # Description:
8 #       Basically this is just a quick slap together script I wrote
9 #       to deal with the generation of the FAQ file.  This was due
10 #       to the fact I wanted the questions seperate from the surrounding 
11 #       page structure.  If it changes it should be a LOT easier to adjust
12 #       to them.
13 #
14 # Changelog:
15 #--------------------------------------------
16 #   Date:    | Who           | Description
17 #------------+---------------+---------------
18 # 09/30/2005 | JH "warthog9" |  Initial Creation 
19 #            |               |
20 #            |               |
21 #            |               |
22
23
24 $questionsfile = "troubleshooting.txt";
25 $headerfile = "header.txt";
26 $footerfile = "footer.txt";
27
28 $question_pre = "<div class=\"qbox\" >\n<table class=\"qtable\" width=\"100%\" border=\"0\" cellpadding=\"5\" cellspacing=\"0\">\n<tr>\n<td class=\"qmrk\" width=\"1px\"><span class=\"question\">Q.</span></td>\n<td class=\"qtd\">\n<div class=\"query\">";
29 $question_post = "\n</div>\n</td>\n</tr>\n</table>\n</div>";
30 $answer_pre = "<div class=\"abox\">\n<table class=\"atable\" width=\"100%\" border=\"0\" cellpadding=\"5\" cellspacing=\"0\">\n<tr>\n<td class=\"amrk\" width=\"1px\"><span class=\"answer\">A.</span></td>\n<td class=\"atd\">\n<div class=\"reply\">";
31 $answer_post = "\n</div>\n</td>\n</tr>\n</table>\n</div>";
32
33 open( FH, $headerfile ) || die "No Header file found\n";
34
35 while ( <FH> ){
36         print $_;
37 }
38
39 close(FH);
40
41 $questionindex = "";
42 $qasection = "";
43 undef $tagname;
44
45 open( FH, $questionsfile) || die "No Question file found\n";
46 $answertail = '';
47
48
49 while ( <FH> ){
50         if (/^\#(\S+)/) {
51             $qasection .= $answertail;
52             $answertail = '';
53             $tagname = $1;
54             next;
55         } elsif(/^Q\.(.*)/) {
56             $q = $1;
57             $foo = $1;
58             $foo =~ s/[^a-zA-Z0-9_]/_/g;
59             $tagname = $foo unless ( defined($tagname) );
60             $questionindex .= "<li><a href=\"#$tagname\">$q</a><br/><br/></li>\n";
61             $qasection .= "<a id=\"$tagname\"></a>". $question_pre . $q . $question_post ."\n";
62             undef $tagname;
63         } elsif(/^A\.(.*)/) {
64             $qasection .= $answer_pre . $1 . "\n";
65             $answertail = $answer_post;
66         } else {
67             $qasection .= $_ . "\n";
68         }
69 }
70 close( FH );
71 $qasection .= $answertail;
72
73 print "<ul>\n". $questionindex ."</ul>\n\n". $qasection;
74
75 open( FH, $footerfile ) || die "No Footer file found\n";
76 while ( <FH> ){
77         print $_;
78 }
79 close( FH );