1 | 1 | 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 | | | if ($var eq "DEVEXT") { |
23 | | | ($dev,$descr)=split(/,/,$value); |
24 | | | $devname=$dev; |
25 | | | $dev =~ s/\//_/g; |
26 | | | $dev =~ s/! /!/g; |
27 | | | $DESCR{"ext$dev"}=$descr; |
28 | | | $DEVNAME{"ext$dev"}=$devname; |
29 | | | next; |
30 | | | } |
31 | | | if ($var eq "DEVINT") { |
32 | | | ($dev,$descr)=split(/,/,$value); |
33 | | | $devname=$dev; |
34 | | | $dev =~ s/\//_/g; |
35 | | | $dev =~ s/! /!/g; |
36 | | | $DESCR{"int$dev"}=$descr; |
37 | | | $DEVNAME{"int$dev"}=$devname; |
38 | | | next; |
39 | | | } |
40 | | | } |
41 | | | @DIAGRAMS=("hour","6h","day","week","month","year"); |
42 | | | @TIMES=("6h","week"); |
43 | | | |
44 | | | # build time-based .html files |
45 | | | # |
46 | | | foreach $time (@TIMES) { |
47 | | | open (FILE,">index/$time.html"); |
48 | | | print FILE "<html>\n"; |
49 | | | if ($REFRESH > 0) { |
50 | | | print FILE "<META HTTP-EQUIV=\"Content-Type\" content=\"text/html; charset=iso-8859-1\"> |
51 | | | <META HTTP-EQUIV=\"Refresh\" CONTENT=\"$REFRESH\"> |
52 | | | <META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">\n"; |
53 | | | } |
54 | | | print FILE "<body>\n<table>\n"; |
55 | | | foreach $dev (sort keys %DESCR) { |
56 | | | $descr=$DESCR{$dev}; |
57 | | | $devname=$DEVNAME{$dev}; |
58 | | | print FILE " <tr><td><a href=\"",$dev,".html\"><img src=\"",$dev,"-",$time,".",$IMAGEFORMAT,"\"></a></td> |
59 | | | <td valign=top><a href=\"",$dev,".html\"><h2>",$devname,"</h2></a><br>",$descr,"</td></tr>\n"; |
60 | | | } |
61 | | | print FILE "</table>\n</body>\n</html>\n"; |
62 | | | close FILE; |
63 | | | } |
64 | | | |
65 | | | # build device-based .html files and complete index |
66 | | | # |
67 | | | open (IDXFILE,">idxdata"); |
68 | | | print IDXFILE "0## <td colspan=2 align=center valign=top> <font size=\"+3\">",$MODNAME,"</font><br> |
69 | | | 0## <a href=\"",$MODNAME,"/6h.html\">6 hours</a> |
70 | | | 0## <a href=\"",$MODNAME,"/week.html\">week</a><br> |
71 | | | 0## <hr width=90%> |
72 | | | 0## </td>\n"; |
73 | | | $nn=0; |
74 | | | foreach $dev (sort keys %DESCR) { |
75 | | | $nn++; |
76 | | | $descr=$DESCR{$dev}; |
77 | | | $devname=$DEVNAME{$dev}; |
78 | | | print IDXFILE $nn,"## <td><a href=\"",$MODNAME,"/",$dev,".html\"><img src=\"",$MODNAME,"/thumb-",$dev,".",$IMAGEFORMAT,"\"></a></td> |
79 | | | ",$nn,"## <td valign=top><a href=\"",$MODNAME,"/",$dev,".html\">",$devname,"</a><br><font size=\"-2\">",$descr,"</font></td>\n"; |
80 | | | |
81 | | | # build device-based .html |
82 | | | # |
83 | | | open (FILE,">index/$dev.html"); |
84 | | | print FILE "<html>\n"; |
85 | | | if ($REFRESH > 0) { |
86 | | | print FILE "<META HTTP-EQUIV=\"Content-Type\" content=\"text/html; charset=iso-8859-1\"> |
87 | | | <META HTTP-EQUIV=\"Refresh\" CONTENT=\"$REFRESH\"> |
88 | | | <META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">\n"; |
89 | | | } |
90 | | | print FILE "<body>\n"; |
91 | | | foreach $diagram (@DIAGRAMS) { |
92 | | | print FILE "<img src=\"",$dev,"-",$diagram,".",$IMAGEFORMAT,"\">\n"; |
93 | | | } |
94 | | | print FILE "</body>\n</html>\n"; |
95 | | | close FILE; |
96 | | | } |
97 | | | |
98 | | | close IDXFILE; |
99 | | | |