jablonka.czprosek.czf

hotsanic

Subversion Repositories:
[/] [branches/] [HotSaNIC-0.5.0-pre6/] [lib/] [HotSaNIChtml.pm] - Blame information for rev 4

 

Line No. Rev Author Line
11simandl#
2# $Id: HotSaNIChtml.pm,v 1.8 2004/06/03 00:21:46 bernisys Exp $
3#
4 
5package HotSaNIChtml;
6 
7($VERSION = '$Revision: 1.8 $') =~ s/.*(\d+\.\d+).*/$1/;
8 
9 
10######################################################################
11#
12# insert complete HTML header
13#
14sub create_header {
15 my $MODNAME=shift || "";
16 my $REFRESH=shift || 0;
17 my $WHICH=shift || "";
18 my %STYLE=@_;
19 
20 $STYLE{BGCOLOR}="E0E0E0" if !defined $STYLE{BGCOLOR};
21 $STYLE{TEXT}="000000" if !defined $STYLE{TEXT};
22 $STYLE{LINK}="000080" if !defined $STYLE{LINK};
23 $STYLE{VLINK}="800080" if !defined $STYLE{VLINK};
24 $STYLE{ALINK}="008000" if !defined $STYLE{ALINK};
25 $STYLE{BACKGROUND}="" if !defined $STYLE{BACKGROUND};
26 
27 if ($STYLE{BACKGROUND} ne "") {
28 if ($MODNAME ne "") { $STYLE{BACKGROUND}="../$STYLE{BACKGROUND}"; }
29 $STYLE{BACKGROUND}=" background=\"$STYLE{BACKGROUND}\"";
30 }
31 
32 my $INFO=$MODNAME;
33 if ($INFO eq "") {$INFO = "global overview page"; }
34 if ($WHICH ne "") {$WHICH = " - $WHICH"; }
35 
36 my @head=(
37 "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2//EN\">",
38 "",
39 "<html>",
40 " <head>",
41 " <meta http-equiv=\"content-type\" content=\"text/html; charset=iso-8859-1\">",
42 );
43 
44 if ($REFRESH > 0) {
45 push @head,(
46 " <meta http-equiv=\"refresh\" content=\"$REFRESH\">",
47 " <meta http-equiv=\"pragma\" content=\"no-cache\">"
48 );
49 }
50 
51 push @head,(
52# " <meta name=\"author\" content=\"bernd pissny\">",
53 " <meta name=\"generator\" content=\"HotSaNIC\">",
54 " <meta name=\"keywords\" content=\"HotSaNIC, stats, statistics\">",
55 " <meta name=\"robots\" content=\"nofollow\">",
56# " <meta name=\"date\" content=\"2001-12-15T08:49:37+00:00\">",
57 "",
58 " <meta name=\"DC.Title\" content=\"HotSaNIC stats - $INFO$WHICH\">",
59 " <meta name=\"DC.Format\" content=\"text/html\">",
60 " <meta name=\"DC.Rights\" content=\"GPL\">",
61# " <meta name=\"DC.Date\" content=\"2001-12-15\">",
62 "",
63 " <title>HotSaNIC stats - $INFO$WHICH</title>",
64 " </head>",
65 "",
66 " <body$STYLE{BACKGROUND} bgcolor=#$STYLE{BGCOLOR} text=#$STYLE{TEXT} link=#$STYLE{LINK} vlink=#$STYLE{VLINK} alink=#$STYLE{ALINK}>",
67 );
68 
69 if ($MODNAME ne "") { push @head," <h2>$INFO$WHICH</h2>"; }
70 
71 return join("\n",@head)."\n";
72 }
73 
74######################################################################
75#
76# insert complete HTML footer
77#
78sub create_footer {
79 my $MODNAME=shift || "";
80 
81 my $PATH=".";
82 if ($MODNAME ne "") { $PATH=".."; }
83 
84 my @foot=(
85 " <center>",
86 " <hr>",
87 " <br>",
88 " <a href=\"http://hotsanic.sourceforge.net\"><img src=\"$PATH/HotSaNIC.gif\" width=97 height=34 alt=\"HotSaNIC\" border=0></a>&nbsp;<a href=\"http://ee-staff.ethz.ch/~oetiker/webtools/rrdtool/\"><img src=\"$PATH/rrdtool.gif\" width=120 height=34 alt=\"rrdtool\" border=0></a>",
89 " <br>",
90 " HTML overview to System and Network Information Center",
91 " </center>",
92 " </body>",
93 "</html>"
94 );
95 
96 return join("\n",@foot)."\n";
97 }
98 
99######################################################################
100#
101# insert complete table entry for a module time index page
102#
103sub create_table_entry {
104 my $IMAGEFORMAT=shift || "";
105 my $PAGENAME=shift || "";
106 my $TIME=shift || "";
107 my $NAME=shift || "";
108 my $DESCRIPTION=shift || "";
109 my $COMPACT=shift || 1;
110 
111 if ($DESCRIPTION ne "") { $DESCRIPTION="<br><br>$DESCRIPTION"; }
112 
113 my $LV1=" " x 8;
114 my $LV2=" " x 10;
115 my $LV3=" " x 12;
116 
117 my @items=("$LV1<tr>");
118 my @block=(
119 "$LV2<td>",
120 "<a href=\"$PAGENAME.html\"><img src=\"$PAGENAME-$TIME.$IMAGEFORMAT\"></a>",
121 "</td>"
122 );
123 if ($COMPACT != 1) { push @items,$block[0],$LV3.$block[1],$LV2.$block[2]; }
124 else { push @items,join ("",@block); }
125 
126 @block=(
127 "$LV2<td valign=top>",
128 "<a href=\"$PAGENAME.html\"><font size=\"+2\">$NAME</font></a>$DESCRIPTION",
129 "</td>",
130 );
131 if ($COMPACT != 1) { push @items,$block[0],$LV3.$block[1],$LV2.$block[2]; }
132 else { push @items,join ("",@block); }
133 push @items,"$LV1</tr>";
134 
135 return join("\n",@items)."\n";
136 }
137 
138######################################################################
139#
140# insert complete table header for the overview page
141#
142sub create_overview_table_header {
143 my $MODNAME=shift || "";
144 my $TIMES=shift || "";
145 my $COLS=shift || 1;
146 
147 my $LV1=" " x 10;
148 my $LV2=" " x 12;
149 
150 my @items=("$COLS","0##$LV1<td colspan=".2*$COLS." align=center> <font size=\"+3\">$MODNAME</font><br>");
151 foreach $time (split /\s+/, $TIMES) {
152 push @items,"0##$LV2<a href=\"$MODNAME/$time.html\">$time</a>";
153 }
154 push @items,("0##$LV2<br>","0##$LV2<hr width=\"90%\">","0##$LV1</td>");
155 
156 return join("\n",@items)."\n";
157 }
158 
159######################################################################
160#
161# insert complete table entry for the overview page
162#
163sub create_overview_table_entry {
164 my $MODNAME=shift || "";
165 my $IMAGEFORMAT=shift || "";
166 my $NUM=shift || 1;
167 my $PAGENAME=shift || "";
168 my $NAME=shift || "";
169 my $DESCRIPTION=shift || "";
170 my $COMPACT=shift || 1;
171 
172 if ($DESCRIPTION ne "") { $DESCRIPTION="<br><font size=\"-2\">$DESCRIPTION</font>"; }
173 
174 my $LV1=" " x 10;
175 my $LV2=" " x 12;
176 
177 my @items=();
178 my @block=(
179 "$NUM##$LV1<td>",
180 "<a href=\"$MODNAME/$PAGENAME.html\"><img src=\"$MODNAME/thumb-$PAGENAME.$IMAGEFORMAT\"></a>",
181 "</td>");
182 if ($COMPACT != 1) { push @items,$block[0],"$NUM##$LV2".$block[1],"$NUM##$LV1".$block[2]; }
183 else { push @items,join ("",@block); }
184 
185 @block=(
186 "$NUM##$LV1<td valign=top>",
187 "<a href=\"$MODNAME/$PAGENAME.html\">$NAME</a>$DESCRIPTION",
188 "</td>"
189 );
190 if ($COMPACT != 1) { push @items,$block[0],"$NUM##$LV2".$block[1],"$NUM##$LV1".$block[2]; }
191 else { push @items,join ("",@block); }
192 
193 return join("\n",@items)."\n";
194 }
195 
196######################################################################
197#
198# insert a number of empty table entries for the overview page
199#
200# $num row number
201#
202# $count how many cols shall be added
203#
204sub create_overview_table_entry_empty {
205 my $NUM=shift || 1;
206 my $COUNT=shift || 0;
207 
208 my $LV1=" " x 10;
209 
210 my $value="";
211 
212 if ($COUNT > 0) {
213 if ($NUM >= 0) { $value="$NUM##$LV1<td></td><td></td>\n" x $COUNT; }
214 else { $value="$LV1<td></td><td></td>\n" x $COUNT; }
215 }
216 
217 return $value;
218 }
219 
220######################################################################
221#
222# generate a .html file containing the detailed device overview
223#
224# HotSaNIChtml::make_device_page($MODNAME,$WEBDIR,$IMAGEFORMAT,$file,description,@times);
225#
226# $MODNAME name of the module
227#
228# $WEBDIR the directory where the file shall be written
229#
230# $IMAGEFORMAT gif or png
231#
232# $file name of the file (without ".html" suffix)
233#
234# $description description tag that will be included on top of the page
235#
236# @times array containing the timespans for which diagrams shall
237# be inseerted
238#
239sub make_device_page {
240 my $MODNAME=shift;
241 my $WEBDIR=shift;
242 my $IMAGEFORMAT=shift;
243 my $file=shift;
244 my $description=shift;
245 
246 open (FILE,">$WEBDIR/$file.html");
247 print FILE HotSaNIChtml::create_header($MODNAME,$REFRESH,$description);
248 foreach my $time (@_) { print FILE "<img src=\"$file-$time.$IMAGEFORMAT\">\n"; }
249 print FILE HotSaNIChtml::create_footer($MODNAME);
250 close FILE;
251 }
252 
2531;
254 

Powered by WebSVN 2.2.1