jablonka.czprosek.czf

hotsanic

Subversion Repositories:
[/] [branches/] [HotSaNIC-0.5.0-pre6/] [lib/] [HotSaNIChtml.pm] - Rev 14 Go to most recent revision

Compare with Previous - Blame - Download


#
# $Id: HotSaNIChtml.pm,v 1.8 2004/06/03 00:21:46 bernisys Exp $
#

package HotSaNIChtml;

($VERSION = '$Revision: 1.8 $') =~ s/.*(\d+\.\d+).*/$1/;


######################################################################
#
# insert complete HTML header
#
sub create_header {
  my $MODNAME=shift || "";
  my $REFRESH=shift || 0;
  my $WHICH=shift || "";
  my %STYLE=@_;

  $STYLE{BGCOLOR}="E0E0E0" if !defined $STYLE{BGCOLOR};
  $STYLE{TEXT}="000000" if !defined $STYLE{TEXT};
  $STYLE{LINK}="000080" if !defined $STYLE{LINK};
  $STYLE{VLINK}="800080" if !defined $STYLE{VLINK};
  $STYLE{ALINK}="008000" if !defined $STYLE{ALINK};
  $STYLE{BACKGROUND}="" if !defined $STYLE{BACKGROUND};

  if ($STYLE{BACKGROUND} ne "") {
    if ($MODNAME ne "") { $STYLE{BACKGROUND}="../$STYLE{BACKGROUND}"; }
    $STYLE{BACKGROUND}=" background=\"$STYLE{BACKGROUND}\"";
    }

  my $INFO=$MODNAME;
  if ($INFO eq "") {$INFO = "global overview page"; }
  if ($WHICH ne "") {$WHICH = " - $WHICH"; }

  my @head=(
    "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2//EN\">",
    "",
    "<html>",
    "  <head>",
    "    <meta http-equiv=\"content-type\" content=\"text/html; charset=iso-8859-1\">",
    );

  if ($REFRESH > 0) {
    push @head,(
      "    <meta http-equiv=\"refresh\" content=\"$REFRESH\">",
      "    <meta http-equiv=\"pragma\" content=\"no-cache\">"
      );
    }

  push @head,(
#   "    <meta name=\"author\" content=\"bernd pissny\">",
    "    <meta name=\"generator\" content=\"HotSaNIC\">",
    "    <meta name=\"keywords\" content=\"HotSaNIC, stats, statistics\">",
    "    <meta name=\"robots\" content=\"nofollow\">",
#   "    <meta name=\"date\" content=\"2001-12-15T08:49:37+00:00\">",
    "",
    "    <meta name=\"DC.Title\" content=\"HotSaNIC stats - $INFO$WHICH\">",
    "    <meta name=\"DC.Format\" content=\"text/html\">",
    "    <meta name=\"DC.Rights\" content=\"GPL\">",
#   "    <meta name=\"DC.Date\" content=\"2001-12-15\">",
    "",
    "    <title>HotSaNIC stats - $INFO$WHICH</title>",
    "  </head>",
    "",
    "  <body$STYLE{BACKGROUND} bgcolor=#$STYLE{BGCOLOR} text=#$STYLE{TEXT} link=#$STYLE{LINK} vlink=#$STYLE{VLINK} alink=#$STYLE{ALINK}>",
    );

  if ($MODNAME ne "") { push @head,"    <h2>$INFO$WHICH</h2>"; }

  return join("\n",@head)."\n";
  }

######################################################################
#
# insert complete HTML footer
#
sub create_footer {
  my $MODNAME=shift || "";

  my $PATH=".";
  if ($MODNAME ne "") { $PATH=".."; }

  my @foot=(
    "    <center>",
    "      <hr>",
    "      <br>",
    "      <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>",
    "      <br>",
    "      HTML overview to System and Network Information Center",
    "    </center>",
    "  </body>",
    "</html>"
    );

  return join("\n",@foot)."\n";
  }

######################################################################
#
# insert complete table entry for a module time index page
#
sub create_table_entry {
  my $IMAGEFORMAT=shift || "";
  my $PAGENAME=shift || "";
  my $TIME=shift || "";
  my $NAME=shift || "";
  my $DESCRIPTION=shift || "";
  my $COMPACT=shift || 1;

  if ($DESCRIPTION ne "") { $DESCRIPTION="<br><br>$DESCRIPTION"; }

  my $LV1=" " x 8;
  my $LV2=" " x 10;
  my $LV3=" " x 12;

  my @items=("$LV1<tr>");
  my @block=(
    "$LV2<td>",
    "<a href=\"$PAGENAME.html\"><img src=\"$PAGENAME-$TIME.$IMAGEFORMAT\"></a>",
    "</td>"
    );
  if ($COMPACT != 1) { push @items,$block[0],$LV3.$block[1],$LV2.$block[2]; }
  else { push @items,join ("",@block); }

  @block=(
    "$LV2<td valign=top>",
    "<a href=\"$PAGENAME.html\"><font size=\"+2\">$NAME</font></a>$DESCRIPTION",
    "</td>",
    );
  if ($COMPACT != 1) { push @items,$block[0],$LV3.$block[1],$LV2.$block[2]; }
  else { push @items,join ("",@block); }
  push @items,"$LV1</tr>";

  return join("\n",@items)."\n";
  }

######################################################################
#
# insert complete table header for the overview page
#
sub create_overview_table_header {
  my $MODNAME=shift || "";
  my $TIMES=shift || "";
  my $COLS=shift || 1;

  my $LV1=" " x 10;
  my $LV2=" " x 12;

  my @items=("$COLS","0##$LV1<td colspan=".2*$COLS." align=center> <font size=\"+3\">$MODNAME</font><br>");
  foreach $time (split /\s+/, $TIMES) {
    push @items,"0##$LV2<a href=\"$MODNAME/$time.html\">$time</a>";
    }
  push @items,("0##$LV2<br>","0##$LV2<hr width=\"90%\">","0##$LV1</td>");

  return join("\n",@items)."\n";
  }

######################################################################
#
# insert complete table entry for the overview page
#
sub create_overview_table_entry {
  my $MODNAME=shift || "";
  my $IMAGEFORMAT=shift || "";
  my $NUM=shift || 1;
  my $PAGENAME=shift || "";
  my $NAME=shift || "";
  my $DESCRIPTION=shift || "";
  my $COMPACT=shift || 1;

  if ($DESCRIPTION ne "") { $DESCRIPTION="<br><font size=\"-2\">$DESCRIPTION</font>"; }

  my $LV1=" " x 10;
  my $LV2=" " x 12;

  my @items=();
  my @block=(
    "$NUM##$LV1<td>",
    "<a href=\"$MODNAME/$PAGENAME.html\"><img src=\"$MODNAME/thumb-$PAGENAME.$IMAGEFORMAT\"></a>",
    "</td>");
  if ($COMPACT != 1) { push @items,$block[0],"$NUM##$LV2".$block[1],"$NUM##$LV1".$block[2]; }
  else { push @items,join ("",@block); }

  @block=( 
    "$NUM##$LV1<td valign=top>",
    "<a href=\"$MODNAME/$PAGENAME.html\">$NAME</a>$DESCRIPTION",
    "</td>"
    );
  if ($COMPACT != 1) { push @items,$block[0],"$NUM##$LV2".$block[1],"$NUM##$LV1".$block[2]; }
  else { push @items,join ("",@block); }

  return join("\n",@items)."\n";
  }

######################################################################
#
# insert a number of empty table entries for the overview page
#
#  $num     row number
#
#  $count   how many cols shall be added
#
sub create_overview_table_entry_empty {
  my $NUM=shift || 1;
  my $COUNT=shift || 0;

  my $LV1=" " x 10;
  
  my $value="";

  if ($COUNT > 0) {
    if ($NUM >= 0) { $value="$NUM##$LV1<td></td><td></td>\n" x $COUNT; }
    else { $value="$LV1<td></td><td></td>\n" x $COUNT; }
    }

  return $value;
  }

######################################################################
#
# generate a .html file containing the detailed device overview
#
#   HotSaNIChtml::make_device_page($MODNAME,$WEBDIR,$IMAGEFORMAT,$file,description,@times);
#
#   $MODNAME      name of the module
#
#   $WEBDIR       the directory where the file shall be written
#
#   $IMAGEFORMAT  gif or png
#
#   $file         name of the file (without ".html" suffix)
#
#   $description  description tag that will be included on top of the page
#
#   @times        array containing the timespans for which diagrams shall
#                 be inseerted
#
sub make_device_page {
  my $MODNAME=shift;
  my $WEBDIR=shift;
  my $IMAGEFORMAT=shift;
  my $file=shift;
  my $description=shift;

  open (FILE,">$WEBDIR/$file.html");
  print FILE HotSaNIChtml::create_header($MODNAME,$REFRESH,$description);
  foreach my $time (@_) { print FILE "<img src=\"$file-$time.$IMAGEFORMAT\">\n"; }
  print FILE HotSaNIChtml::create_footer($MODNAME);
  close FILE;
  }

1;


Powered by WebSVN 2.2.1