blob: 9739f9b4384aa9944d81015bde5f83bbd980df8a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
#!/usr/bin/perl
#
# Author:
# Sean MacIsaac
#
use strict;
my $full_expand = 1;
my @template;
my $n;
if ($#ARGV != 2) {
print "process.pl command_file template_file directory_prefix\n";
exit ();
}
my $menu = "";
open COMMANDS, $ARGV[0] || die "Can not open $ARGV[0]";
while (<COMMANDS>) {
chop;
my @command = split /,/;
if ($command[0] != -1) {
$menu .= "\t\t";
$menu .= "<tr><td valign=\"top\" class=\"navi" . $command[0];
$menu .= "\"><a class=\"navi" . $command[0];
$menu .= "\"";
$menu .= "HREF=\"$command[2]\">$command[1]</A></td></tr>\n\n";
}
}
close COMMANDS;
open TEMPLATE, $ARGV[1] || die "Can not open $ARGV[1]";
while (<TEMPLATE>) {
push @template, $_;
}
close TEMPLATE;
open COMMANDS, $ARGV[0] || die "Can not open $ARGV[0]";
while (<COMMANDS>) {
chop;
my @command = split /,/;
if ($command[2] =~ /^http:/){
} else {
$n = $ARGV[2] . "/" . $command[2];
open OUTPUT, ">" . $n || die "Can not create $n";
my $content = "";
open INPUT, "src/$command[3]" || die "Can not open $command[3]";
while (<INPUT>) {
$content .= $_;
}
close INPUT;
my $line;
my $temp;
my $tit;
my $title;
my $css;
my $script;
$tit = $command[1];
$css = $command[4];
$script = $command[5];
foreach $line (@template) {
$temp = $line;
$title = "$tit / Mono";
$temp =~ s/#TITLE#/$title/;
$temp =~ s/#CONTENT#/$content/;
$temp =~ s/#MENU#/$menu/;
if ($css) {
$temp =~ s/#CSS#/<LINK rel="stylesheet" type="text\/css" href="$css">/;
} else {
$temp =~ s/#CSS#//;
}
if ($script) {
$temp =~ s/#SCRIPT#/<SCRIPT src="$script"><\/SCRIPT>/;
} else {
$temp =~ s/#SCRIPT#//;
}
print OUTPUT $temp;
}
}
close OUTPUT;
}
|