1 | 31 | simandl | #!/usr/bin/env perl |
2 | | | use warnings; |
3 | | | use diagnostics; |
4 | | | |
5 | | | use lib "../../lib"; |
6 | | | use HotSaNICparser; |
7 | | | |
8 | | | # read global settings |
9 | | | # |
10 | | | $MODNAME=lc HotSaNICparser::get_module_name(); |
11 | | | |
12 | | | %CONFIG=HotSaNICparser::get_config("../.."); |
13 | | | $IMAGEFORMAT=$CONFIG{"IMAGEFORMAT"}; |
14 | | | $REFRESH=$CONFIG{"REFRESH"}; |
15 | | | $REFRESH=0 if !defined $REFRESH; |
16 | | | |
17 | | | # read module-specific settings |
18 | | | # |
19 | | | undef %DESCR; |
20 | | | foreach (HotSaNICparser::read_settings(".")) { |
21 | | | ($var,$value)=HotSaNICparser::parse_line($_); |
22 | | | next if $var eq ""; |
23 | | | if ($var eq "DEV") { |
24 | | | ($dev,$descr)=split(/,/,$value); |
25 | | | if ($descr ne "") { ($dev=$descr)=~ s/.*\///g; } |
26 | | | else { $dev=~ s/:/_/g; $descr=$dev; } |
27 | | | $DESCR{$dev}=$descr; |
28 | | | } |
29 | | | } |
30 | | | @DIAGRAMS=("hour","6h","day","week","month","year"); |
31 | | | @TIMES=("6h","week"); |
32 | | | |
33 | | | # build time-based .html files |
34 | | | # |
35 | | | foreach $time (@TIMES) { |
36 | | | open (FILE,">index/$time.html"); |
37 | | | print FILE "<html>\n"; |
38 | | | if ($REFRESH > 0) { |
39 | | | print FILE "<META HTTP-EQUIV=\"Content-Type\" content=\"text/html; charset=iso-8859-1\"> |
40 | | | <META HTTP-EQUIV=\"Refresh\" CONTENT=\"$REFRESH\"> |
41 | | | <META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">\n"; |
42 | | | } |
43 | | | print FILE "<body>\n<table>\n"; |
44 | | | foreach $dev (keys %DESCR) { |
45 | | | $descr=$DESCR{$dev}; |
46 | | | print FILE " <tr><td><a href=\"$dev.html\"><img src=\"$dev-$time.$IMAGEFORMAT\"></a></td> |
47 | | | <td valign=top><a href=\"$dev.html\"><h2>$descr</h2></a></td></tr>\n"; |
48 | | | } |
49 | | | print FILE "</table>\n</body>\n</html>\n"; |
50 | | | close FILE; |
51 | | | } |
52 | | | |
53 | | | # build device-based .html files and complete index |
54 | | | # |
55 | | | open (IDXFILE,">idxdata"); |
56 | | | print IDXFILE "0## <td colspan=2 align=center valign=top> <font size=\"+3\">$MODNAME</font><br> |
57 | | | 0## <a href=\"$MODNAME/6h.html\">6 hours</a> |
58 | | | 0## <a href=\"$MODNAME/week.html\">week</a><br> |
59 | | | 0## <hr width=90%> |
60 | | | 0## </td>\n"; |
61 | | | $nn=0; |
62 | | | foreach $dev (sort keys %DESCR) { |
63 | | | $nn++; |
64 | | | $descr=$DESCR{$dev}; |
65 | | | print IDXFILE $nn,"## <td><a href=\"$MODNAME/$dev.html\"><img src=\"$MODNAME/thumb-$dev.$IMAGEFORMAT\"></a></td> |
66 | | | $nn## <td valign=top><a href=\"$MODNAME/$dev.html\">$descr</a></td>\n"; |
67 | | | |
68 | | | # build device-based .html |
69 | | | # |
70 | | | open (FILE,">index/$dev.html"); |
71 | | | print FILE "<html>\n"; |
72 | | | if ($REFRESH > 0) { |
73 | | | print FILE "<META HTTP-EQUIV=\"Content-Type\" content=\"text/html; charset=iso-8859-1\"> |
74 | | | <META HTTP-EQUIV=\"Refresh\" CONTENT=\"$REFRESH\"> |
75 | | | <META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">\n"; |
76 | | | } |
77 | | | print FILE "<body>\n"; |
78 | | | foreach $diagram (@DIAGRAMS) { |
79 | | | print FILE "<img src=\"$dev-$diagram.$IMAGEFORMAT\">\n"; |
80 | | | } |
81 | | | print FILE "</body>\n</html>\n"; |
82 | | | close FILE; |
83 | | | } |
84 | | | |
85 | | | close IDXFILE; |
86 | | | |
87 | | | |