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 %SENSOR; |
20 | | | undef %SENSORDB; |
21 | | | foreach (HotSaNICparser::read_settings(".")) { |
22 | | | ($var,$value)=HotSaNICparser::parse_line($_); |
23 | | | if ($var eq "SENSOR") { |
24 | | | ($dev,$dbname,$name)=split(/,/,$value); |
25 | | | $SENSORDB{$dbname}=$dbname; |
26 | | | $SENSOR{$dbname}=$name; |
27 | | | print "$dev\n"; |
28 | | | } |
29 | | | } |
30 | | | @DIAGRAMS=("hour","6h","day","week","month","year"); |
31 | | | |
32 | | | # build time-based .html files |
33 | | | # |
34 | | | foreach $index ("6h","week") { |
35 | | | open (FILE,">index/$index.html"); |
36 | | | print FILE "<html>\n"; |
37 | | | if ($REFRESH > 0) { |
38 | | | print FILE "<META HTTP-EQUIV=\"Content-Type\" content=\"text/html; charset=iso-8859-1\"> |
39 | | | <META HTTP-EQUIV=\"Refresh\" CONTENT=\"$REFRESH\"> |
40 | | | <META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">\n"; |
41 | | | } |
42 | | | print FILE "<body>\n<table>\n"; |
43 | | | foreach $dev (keys %SENSOR) { |
44 | | | $dbname=$SENSORDB{$dev}; |
45 | | | $name=$SENSOR{$dev}; |
46 | | | print FILE " <tr><td><a href=\"",$dbname,".html\"><img src=\"",$dbname,"-",$index,".",$IMAGEFORMAT,"\"></a></td> |
47 | | | <td valign=top><a href=\"",$dbname,".html\"><h2>",$name,"</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 %SENSOR)) { |
63 | | | $nn++; |
64 | | | $dbname=$SENSORDB{$dev}; |
65 | | | $name=$SENSOR{$dev}; |
66 | | | print IDXFILE $nn,"## <td><a href=\"",$MODNAME,"/",$dbname,".html\"><img src=\"",$MODNAME,"/thumb-",$dbname,".",$IMAGEFORMAT,"\"></a></td> |
67 | | | ",$nn,"## <td valign=top><a href=\"",$MODNAME,"/",$dbname,".html\">",$name,"</a><br></td>\n"; |
68 | | | |
69 | | | # build device-based .html |
70 | | | # |
71 | | | open (FILE,">index/$dbname.html"); |
72 | | | print FILE "<html>\n"; |
73 | | | if ($REFRESH > 0) { |
74 | | | print FILE "<META HTTP-EQUIV=\"Content-Type\" content=\"text/html; charset=iso-8859-1\"> |
75 | | | <META HTTP-EQUIV=\"Refresh\" CONTENT=\"$REFRESH\"> |
76 | | | <META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">\n"; |
77 | | | } |
78 | | | print FILE "<body>\n"; |
79 | | | foreach $diagram (@DIAGRAMS) { |
80 | | | print FILE "<img src=\"",$dbname,"-",$diagram,".",$IMAGEFORMAT,"\">\n"; |
81 | | | } |
82 | | | print FILE "</body>\n</html>\n"; |
83 | | | close FILE; |
84 | | | } |
85 | | | |
86 | | | close IDXFILE; |
87 | | | |