Util::HTMLcatalog (version $)


package Util::HTMLcatalog;

##############################################################################
#
# DESCRIPTION: Create a catalog of files in HTML format. This Class works
# DESCRIPTION: just like the parent class except that the output is in
# DESCRIPTION: HTML format.
#
# HISTORY
# HISTORY: $Log: HTMLcatalog.pm,v $
# HISTORY: Revision 1.3  2014/02/27 07:01:07  apsop
# HISTORY: VERSION header now shows CVS Revision
# HISTORY:
# HISTORY: Revision 1.2  2006/08/01 20:35:34  apsop
# HISTORY: Add in CVS history indicator.
# HISTORY:
# HISTORY:
#
# VERSION: $Revision: 1.3 $
#
##############################################################################

use Util::Catalog;
@ISA = ("Util::Catalog");
use strict;


#########################################
# constructor
#########################################
sub new {
    my $proto=shift;
    my $self=$proto->SUPER::new(shift);

    my $filename=$self->filename();


    ####################################
    # file type of the HTML list
    ####################################
    $self->{HTML_TYPE}=shift;
    $self->{CAT_NAME}=$filename->get($self->{HTML_TYPE});

    ##############################################
    # write the HTML header
    ##############################################
    my $seq=$filename->sequence();
    my $header=$filename->get("header");

    $self->{DATA}.="<HTML>\n";
    $self->{DATA}.="<TITLE>\n";
    $self->{DATA}.="Sequence $seq File List\n";
    $self->{DATA}.="</TITLE>\n";
    $self->{DATA}.="<BODY>\n";
    $self->{DATA}.="<H1>Sequence $seq File List</H1>\n";

    $self->{DATA}.="This page lists all of the files included in the\n";
    $self->{DATA}.="distribution for this sequence.\n";
    $self->{DATA}.="The size of most files is given after the\n";
    $self->{DATA}.="file name.\n";
    $self->{DATA}.="<P>\n";

    $self->{DATA}.="The following information is also available:\n";
    $self->{DATA}.="<UL>\n";
    $self->{DATA}.="  <LI><STRONG><A HREF=\"${header}\">\n";
    $self->{DATA}.="  The processing header page</A></STRONG>\n";
    $self->{DATA}.="</UL>\n";
    $self->{DATA}.="<HR>\n";

    return $self;
}

#####################
# METHODS:
#####################

###################################################
# add all the files of a given type to the catalog
###################################################
sub add_type {
    my $self=shift;
    my $type=shift;

    my @files=$self->files_of_type($type);
    if(! @files) {return};

    my $description=$self->filename()->description($type);
    my $format=$self->format($files[0]);

    ########################################
    # HTML header for this file type
    ########################################
    
    $self->{DATA}.="<H2>$description ($format)</H2>\n";
    $self->{DATA}.="<OL>\n";
 
    my $file;
    foreach $file (@files ) {
        $self->add_file($file);
    }

    $self->{DATA}.="</OL>\n";

}


######################################
# add a file to the catalog
######################################
sub add_file {
    my $self=shift;
    my $file=shift;

    my $size=$self->size($file);

    $self->{DATA}.="<LI> $file";
    if($size) { $self->{DATA}.=" ($size kilobytes)\n" }
    else      { $self->{DATA}.=                  "\n" }

}

###########################################
# write the file
###########################################
sub close {
    my $self=shift;

    my $filename=$self->filename();

    my $file=$filename->get($self->{HTML_TYPE});

    open HTML, ">$file";
    print HTML $self->{DATA};
    close HTML;

}


1;