Work on the web site
[mono.git] / web / web / process.pl
1 #!/usr/bin/perl
2 #
3 # Author:
4 #   Sean MacIsaac
5 #
6
7 use strict;
8
9 my $full_expand = 1;
10 my @template;
11 my $n;
12
13 if ($#ARGV != 2) {
14   print "process.pl command_file template_file directory_prefix\n";
15   exit ();
16 }
17
18 my $menu = "";
19
20 open COMMANDS, $ARGV[0] || die "Can not open $ARGV[0]";
21 while (<COMMANDS>) {
22   chop;
23   my @command = split /,/;
24   if ($command[0] != -1) {
25       $menu .= "\t\t";
26       if ($command[0] == 0){
27           $menu .= "<tr><td class=\"navi\"><a class=\"navi\"";
28       } else {
29           $menu .= "&nbsp; &nbsp; &nbsp; <tr><td class=\"subnavi\"><a class=\"navi\"";
30       }
31       $menu .= "HREF=\"$command[2]\">$command[1]</A></td></tr>\n\n";
32   } 
33 }
34 close COMMANDS;
35
36 open TEMPLATE, $ARGV[1] || die "Can not open $ARGV[1]";
37 while (<TEMPLATE>) {
38   push @template, $_;
39 }
40 close TEMPLATE;
41
42 open COMMANDS, $ARGV[0] || die "Can not open $ARGV[0]";
43 while (<COMMANDS>) {
44   chop;
45   my @command = split /,/;
46
47   $n = $ARGV[2] . "/" . $command[2];
48   open OUTPUT, ">" . $n || die "Can not create $n";
49
50   my $content = "";
51   open INPUT, $command[3] || die "Can not open $command[3]";
52   while (<INPUT>) {
53     $content .= $_;
54   }
55   close INPUT;
56
57   my $line;
58   my $temp;
59
60   foreach $line (@template) {
61     $temp = $line;
62     $temp =~ s/#CONTENT#/$content/;
63     $temp =~ s/#MENU#/$menu/;
64     print OUTPUT $temp;
65   }
66
67   close OUTPUT;
68 }