Debian-Package-HTML-0.1/ 0000755 0001750 0001750 00000000000 10457737720 013325 5 ustar jose jose Debian-Package-HTML-0.1/t/ 0000755 0001750 0001750 00000000000 10457737720 013570 5 ustar jose jose Debian-Package-HTML-0.1/t/Debian-Package-HTML.t 0000644 0001750 0001750 00000000752 10457732372 017234 0 ustar jose jose # Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl Debian-Package-HTML.t'
#########################
# change 'tests => 1' to 'tests => last_test_to_print';
use Test::More tests => 1;
BEGIN { use_ok('Debian::Package::HTML') };
#########################
# Insert your test code below, the Test::More module is use()ed here so read
# its man page ( perldoc Test::More ) for help writing this test script.
Debian-Package-HTML-0.1/Changes 0000644 0001750 0001750 00000000654 10457737707 014632 0 ustar jose jose Revision history for Perl extension Debian::Package::HTML.
0.01 Tue Jul 18 23:36:31 2006
- original version; created by h2xs 1.23 with options
-AXc -n Debian::Package::HTML
- changed namespace, introduced new "dump" feature.
- first version shipped, first CPAN module, first OO program
added new features over the old procedural program and
wrote an example HTML::Template template in webpage.
Debian-Package-HTML-0.1/MANIFEST 0000644 0001750 0001750 00000000246 10457737720 014460 0 ustar jose jose Changes
Makefile.PL
MANIFEST
README
t/Debian-Package-HTML.t
lib/Debian/Package/HTML.pm
META.yml Module meta-data (added by MakeMaker)
Debian-Package-HTML-0.1/README 0000644 0001750 0001750 00000001433 10457732526 014205 0 ustar jose jose Debian-Package-HTML version 0.01
================================
Debian-Package-HTML provides an easy way to generate Webpages from the
results of your daily package building. The POD documentation for
the module covers most aspect of the usage of this module. Any bugs
or recommendations are greatly welcome.
INSTALLATION
To install this module type the following:
perl Makefile.PL
make
make test
make install
DEPENDENCIES
This module requires HTML::Template and a Debian system.
COPYRIGHT AND LICENCE
Copyright (C) 2006 by Jose Parrella
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.8.8 or,
at your option, any later version of Perl 5 you may have available.
Debian-Package-HTML-0.1/META.yml 0000644 0001750 0001750 00000000504 10457737720 014575 0 ustar jose jose # http://module-build.sourceforge.net/META-spec.html
#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
name: Debian-Package-HTML
version: 0.1
version_from: lib/Debian/Package/HTML.pm
installdirs: site
requires:
distribution_type: module
generated_by: ExtUtils::MakeMaker version 6.30_01
Debian-Package-HTML-0.1/Makefile.PL 0000644 0001750 0001750 00000001063 10457732372 015275 0 ustar jose jose use 5.008008;
use ExtUtils::MakeMaker;
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
WriteMakefile(
NAME => 'Debian::Package::HTML',
VERSION_FROM => 'lib/Debian/Package/HTML.pm', # finds $VERSION
PREREQ_PM => {}, # e.g., Module::Name => 1.1
($] >= 5.005 ? ## Add these new keywords supported since 5.005
(ABSTRACT_FROM => 'lib/Debian/Package/HTML.pm', # retrieve abstract from module
AUTHOR => 'Jose Parrella ') : ()),
);
Debian-Package-HTML-0.1/lib/ 0000755 0001750 0001750 00000000000 10457737720 014073 5 ustar jose jose Debian-Package-HTML-0.1/lib/Debian/ 0000755 0001750 0001750 00000000000 10457737720 015255 5 ustar jose jose Debian-Package-HTML-0.1/lib/Debian/Package/ 0000755 0001750 0001750 00000000000 10457737720 016610 5 ustar jose jose Debian-Package-HTML-0.1/lib/Debian/Package/HTML.pm 0000644 0001750 0001750 00000022377 10457737650 017727 0 ustar jose jose #!/usr/bin/perl
# debian-package-html -> generates HTML output for Debian packages and sources
# originally written by Jose Parrella
# this program is free for anyone to use it and modify it
package Debian::Package::HTML;
$VERSION = "0.1";
use strict;
use warnings;
use HTML::Template;
# Constructor
sub new {
my ($class, @args) = @_;
# Bless my anonymous hash, please
my $object = bless {}, $class;
# Default null values
%$object = (
"binary" => "",
"control" => "",
"source" => "",
"diff" => "",
"changes" => ""
);
# Get input from the constructor
while (@args) {
$object->{$args[0]} = $args[1] if defined($args[1]);
shift @args; shift @args;
}
die "At least a DSC file is needed!\n" unless defined($object->{control});
return $object;
}
# Main execution
sub output {
my ($object, @args) = @_;
# Context default values
my %context = (
"briefing" => "0",
"charset" => "ISO-8859-1",
"resultTemplate" => "result.tmpl",
"pageStyle" => "",
"doChecks" => "0",
"dump" => "index.html"
);
# Get input from the constructor
while (@args) {
$context{$args[0]} = $args[1] if defined($args[1]);
shift @args; shift @args;
}
my ($packageName, $packageVersion, $maintainerName, $maintainerMail);
my @packageVars = parseControl ($object);
if ($context{doChecks}) {
system("linda -v -i $object->{control} > $packageVars[0]-checks.txt");
system("lintian -v -i $object->{control} >> $packageVars[0]-checks.txt");
}
doTheOutput ($object, @packageVars, %context);
}
# parseControl: Parses control file
sub parseControl {
my $packageFiles = shift;
my ($packageName, $packageVersion, $maintainerName, $maintainerMail);
die "Couldn't FIND a proper DSC file\n" unless defined($packageFiles->{"control"});
open (CONTROL, $packageFiles->{"control"}) or die "Couldn't OPEN a proper DSC file\n";
while () {
chomp;
$packageName = $1 if ($_ =~ /^Source: ([\w-]+)/);
$packageVersion = $1 if ($_ =~ /^Version: (.*)/ && !defined($packageVersion));
$maintainerName = $1 if ( ($_ =~ /^Maintainer: ([\w ]+) .*/) && !defined($maintainerName) );
$maintainerMail = $1 if ( ($_ =~ /^Maintainer: [\w ]+ \<(.+)\>/) && !defined($maintainerMail) );
}
close CONTROL;
return ($packageName, $packageVersion, $maintainerName, $maintainerMail);
}
# doTheOutput: Outputs HTML
sub doTheOutput {
my($packageFiles, $packageName, $packageVersion, $maintainerName, $maintainerMail, %context) = @_;
# Call to the constructor method on $resultTemplate
my $template = HTML::Template->new(filename => $context{resultTemplate});
my $currentDate = `date +%c`;
chomp $currentDate;
my $maintainerPlus = maintainerInfo($maintainerName);
sub maintainerInfo {
my $maintainerName = @_;
my @maintainerParts = split(" ", $maintainerName);
return join("+", @maintainerParts);
}
my @packagef;
for (keys(%$packageFiles)) {
push @packagef,
{ packagefile => $packageFiles->{$_} }
if (defined($packageFiles->{$_}) && $packageFiles->{$_} ne "");
};
$template->param(
packageName => $packageName,
packageVersion => $packageVersion,
maintainerName => $maintainerName,
maintainerMail => $maintainerMail,
maintainerPlus => $maintainerPlus,
pageCharset => $context{pageCharset},
pageStyle => $context{pageStyle},
packagef => \@packagef,
date => $currentDate,
doChecks => $context{doChecks},
briefing => $context{briefing}
);
if (defined($context{dump}) && $context{dump} ne "") {
no warnings;
local *DUMPIT;
open (DUMPIT, ">", "$context{dump}") or die "Couldn't open $context{dump} for write.\n";
print $template->output(print_to => *DUMPIT);
close DUMPIT;
}
else {
die "Weird argument in context's dump option. No output will be produced\n";
}
}
1;
# Documentation
=head1 Debian::Package::HTML
Debian::Package::HTML - Generates a webpage information (and Linda/Lintian checks) about a Debian binary or source package using HTML::Template
=head1 SYNOPSIS
use strict;
use Debian::Package::HTML;
my $package = Debian::Package::HTML->new(%packageHash);
$package->output(%contextHash);
=head1 REQUIRES
HTML::Template
=head1 EXPORTS
Nothing
=head1 DESCRIPTION
This module outputs a webpage using HTML::Template templates which
resumes the information of a normal build environment for a package
in Debian (source files, binary packages and changelogs) using
Linda/Lintian for sanity checks. It is useful for making unified presentation
webpages for those packages which are being sponsorized by someone in Debian.
=head1 METHODS
=head2 Constructor
=over 4
=item * $object->new(%packageHash)
Constructs an $object with all information concerning the
package, including location for binary/source files, changelogs,
diffs, pristine sources, as well as templates, charsets and other
settings.
Possible elements for the hash are:
"binary", "control", "source", "diff", "changes", each one of
them specifying one of the five possible files generated by a
package building process in Debian.
"control" is mandatory.
=back
=head2 Output
=over 4
=item * $object->output(%contextHash)
Does the actual XHTML output. Possible elements for the hash are:
"briefing" (boolean): if TRUE, WebInfo will look for a briefing.html
in the current directory, and will include the content in the resulting
output. Useful for introducing commentaries without touching the final
HTML. Defaults to FALSE.
"charset": determines the output charset. Defaults to "ISO-8859-1".
"resultTemplate": specifies the location of an HTML::Template style
template for output. This is mandatory, and defaults to "result.tmpl"
"pageStyle": specifies the location of a CSS file which might be
included.
"doChecks" (boolean): if TRUE, WebInfo will run linda and lintian over
the control file and will generate a ${packageName}-checks.txt file which
will be included in the final output. Defaults to FALSE.
"dump": determines where to put the resulting HTML output. Defaults to
index.html
=head1 DIAGNOSTICS
=head2 No DSC could be found/open
You need to specify a DSC control file using the "control" parameter for the
new() method. If you don't, WebInfo can't do much. The package will inform if
the file could not be FOUND or could not be OPEN.
Please report the bugs, I'd love to work on them.
=head1 CUSTOMIZATION
=head2 Template customization
You can customize the final output using your own HTML::Template template
file and specifying it as a parameter for the output() method. The following
template variable names are honored by WebInfo:
packageName: the name of the package
packageVersion: the version of the package
maintainerName: the name of the maintainer
maintainerMail: the e-mail address of the maintainer
maintainerPlus: a "+" separated name/surname for the maintainer (useful for
URL searching)
pageCharset: the page charset (customizable in the output() method)
pageStyle: the CSS file (customizable in the output() method)
packagef: the available package files as an array reference, so HTML::Template
should iterate over the "packagefile" variable.
date: the date specified by the current locale
doChecks: a boolean variable specifying if Linda/Lintian checks were made
briefing: a boolean variable specifying if a briefing.html file should be included
=head2 Example template
An example template is in:
http://debian.bureado.com.ve/package-info/result.tmpl
HTML outputs with that template and no CSS look like:
http://debian.bureado.com.ve/falselogin/
=head1 EXAMPLES
=head2 Only a control file
#!/usr/bin/perl
use strict;
use warnings;
use Debian::Package::HTML;
my $package = Debian::Package::HTML->new( "control" => "falselogin.dsc" );
$package->output ( "resultTemplate" => "result.tmpl", "dump" => "index.html" );
=head2 A complete building environment
#!/usr/bin/perl
use strict;
use warnings;
use Debian::Package::HTML;
my $package = Debian::Package::HTML->new("control" => "falselogin.dsc",
"binary" => "falselogin.deb",
"diff" => "falselogin.diff.gz",
"source" => "falselogin.orig.tar.gz",
"changes" => "falselogin.changes"
;
$package -> output ( "resultTemplate" => "anotherTemplate.tmpl",
"style" => "groovy-style.css",
"charset" => "UTF-8",
"doChecks" => "1",
"dump" => "firstPackage.html"
);
=head2 Some ideas
Well, throw the files generated by your compilations (dpkg-buildpackage, i.e.)
in a /var/www/ served by your webserver of choice and run a small
program using Debian::Package::HTML and a nice CSS/Template. You will have a great webpage
for all your Debian packages, really useful if you're not yet a Developer and need
to handle several packages with your sponsors.
=head1 AUTHOR
Jose Parrella (joseparrella@cantv.net) wrote the original code, then modularized and OOed the code.
Thanks go to Christian Sánchez (csanchez@unplug.org.ve) who helped with the original HTML::Template'ing
=head1 COPYRIGHT
Copyright 2006 Jose Parrella. All rights reserved.
This library is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
=head1 SEE ALSO
perl(1), HTML::Template.
=cut