HTML-Auto-0.04/0000755000175000017500000000000011763420347012744 5ustar andrefsandrefsHTML-Auto-0.04/t/0000755000175000017500000000000011763420347013207 5ustar andrefsandrefsHTML-Auto-0.04/t/pod-coverage.t0000644000175000017500000000104711754735364015761 0ustar andrefsandrefsuse strict; use warnings; use Test::More; # Ensure a recent version of Test::Pod::Coverage my $min_tpc = 1.08; eval "use Test::Pod::Coverage $min_tpc"; plan skip_all => "Test::Pod::Coverage $min_tpc required for testing POD coverage" if $@; # Test::Pod::Coverage doesn't require a minimum Pod::Coverage version, # but older versions don't recognize some common documentation styles my $min_pc = 0.18; eval "use Pod::Coverage $min_pc"; plan skip_all => "Pod::Coverage $min_pc required for testing POD coverage" if $@; all_pod_coverage_ok(); HTML-Auto-0.04/t/pod.t0000644000175000017500000000035011754735364014164 0ustar andrefsandrefs#!perl -T use strict; use warnings; use Test::More; # Ensure a recent version of Test::Pod my $min_tp = 1.22; eval "use Test::Pod $min_tp"; plan skip_all => "Test::Pod $min_tp required for testing POD" if $@; all_pod_files_ok(); HTML-Auto-0.04/t/01-basic.t0000644000175000017500000000706611756766745014725 0ustar andrefsandrefs#!perl -T use Test::More tests => 4; use HTML::Auto qw/matrix h v/; use Data::Dumper; my $tests = { 'simple h test' => { test => "h('l','r')", gold => '
l
r
' }, 'simple v test' => { test => "v('u','d')", gold => '
u
d
' }, 'simple matrix test' => { test => 'matrix([qw/c1 c2/],[qw/l1 l2/],[ [1,0], [0,1] ])', gold => '
C1 C2
L1 1 0
L2 0 1
' }, 'matrix with pop-up test' => { test => 'matrix([qw/c1 c2/],[qw/l1 l2/], [ [1,2], [3, { v=> 4, more_info => "This is a pop-up!" }]])', gold => '
C1 C2
L1 1 2
L2 3 4 This is a pop-up!
', }, }; foreach (keys %$tests) { ok(run($tests->{$_}->{test}) eq $tests->{$_}->{gold}, $_); } sub run { clean(eval $_[0]); } sub clean { my $_ = shift; $_ =~ s/^\s+|\s+$//sg; $_ =~ s/\s+/ /sg; return $_; } HTML-Auto-0.04/t/00-load.t0000644000175000017500000000024511754735364014541 0ustar andrefsandrefs#!perl -T use Test::More tests => 1; BEGIN { use_ok( 'HTML::Auto' ) || print "Bail out! "; } diag( "Testing HTML::Auto $HTML::Auto::VERSION, Perl $], $^X" ); HTML-Auto-0.04/t/manifest.t0000644000175000017500000000042011754735364015206 0ustar andrefsandrefs#!perl -T use strict; use warnings; use Test::More; unless ( $ENV{RELEASE_TESTING} ) { plan( skip_all => "Author tests not required for installation" ); } eval "use Test::CheckManifest 0.9"; plan skip_all => "Test::CheckManifest 0.9 required" if $@; ok_manifest(); HTML-Auto-0.04/META.yml0000644000175000017500000000077711763420347014230 0ustar andrefsandrefs--- abstract: 'automatic write HTML for common elements' author: - 'Nuno Carvalho ' build_requires: ExtUtils::MakeMaker: 0 configure_requires: ExtUtils::MakeMaker: 0 dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 6.6302, CPAN::Meta::Converter version 2.120921' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: HTML-Auto no_index: directory: - t - inc requires: Template: 0 Test::More: 0 version: 0.04 HTML-Auto-0.04/META.json0000644000175000017500000000162311763420347014367 0ustar andrefsandrefs{ "abstract" : "automatic write HTML for common elements", "author" : [ "Nuno Carvalho " ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 6.6302, CPAN::Meta::Converter version 2.120921", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "HTML-Auto", "no_index" : { "directory" : [ "t", "inc" ] }, "prereqs" : { "build" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "runtime" : { "requires" : { "Template" : "0", "Test::More" : "0" } } }, "release_status" : "stable", "version" : "0.04" } HTML-Auto-0.04/Makefile.PL0000644000175000017500000000111611754735364014725 0ustar andrefsandrefsuse strict; use warnings; use ExtUtils::MakeMaker; WriteMakefile( NAME => 'HTML::Auto', AUTHOR => q{Nuno Carvalho }, VERSION_FROM => 'lib/HTML/Auto.pm', ABSTRACT_FROM => 'lib/HTML/Auto.pm', ($ExtUtils::MakeMaker::VERSION >= 6.3002 ? ('LICENSE'=> 'perl') : ()), PL_FILES => {}, PREREQ_PM => { 'Test::More' => 0, 'Template' => 0, }, dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', }, clean => { FILES => 'HTML-Auto-*' }, ); HTML-Auto-0.04/lib/0000755000175000017500000000000011763420347013512 5ustar andrefsandrefsHTML-Auto-0.04/lib/HTML/0000755000175000017500000000000011763420347014256 5ustar andrefsandrefsHTML-Auto-0.04/lib/HTML/Auto/0000755000175000017500000000000011763420347015166 5ustar andrefsandrefsHTML-Auto-0.04/lib/HTML/Auto/Templates.pm0000644000175000017500000001035011757002675017464 0ustar andrefsandrefspackage HTML::Auto::Templates; use base qw/Template::Provider/; use warnings; use strict; =head1 NAME HTML::Auto::Templates - this module stores HTML::Auto templates =head1 VERSION Version 0.02 =cut our $VERSION = '0.02'; my $templates = { 'matrix' => <<'EOT' [% FOREACH i IN cols %] [% END %] [% i_c = 0 %] [% FOREACH i IN vals %] [% j_c = 0 %] [% FOREACH j IN i %] [% j_c = j_c + 1 %] [% END %] [% i_c = i_c + 1 %] [% END %]
[% i -%]
[% lines.shift -%][% j %] [% IF more.$i_c.$j_c %] [% more.$i_c.$j_c %] [% END %]
EOT , 'h' => <<'EOT'
[% FOREACH i IN list %]
[% i %]
[% END %]
EOT , 'v' => <<'EOT' [% FOREACH i IN list %]
[% i %]
[% END %] EOT }; =head2 _template_modified TODO =cut sub _template_modified { my($self,$path) = @_; return 1; } =head2 _template_content TODO =cut sub _template_content { my($self,$path) = @_; $path =~ s#^templates/##; $self->debug("get $path") if $self->{DEBUG}; my $data = $templates->{$path}; my $error = "error: $path not found"; my $mod_date = 1; return $data; } =head1 AUTHOR Nuno Carvalho, C<< >> =head1 BUGS Please report any bugs or feature requests to C, or through the web interface at L. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. =head1 SUPPORT You can find documentation for this module with the perldoc command. perldoc HTML::Auto You can also look for information at: =over 4 =item * RT: CPAN's request tracker L =item * AnnoCPAN: Annotated CPAN documentation L =item * CPAN Ratings L =item * Search CPAN L =back =head1 ACKNOWLEDGEMENTS =head1 LICENSE AND COPYRIGHT Copyright 2012 Project Natura. This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License. See http://dev.perl.org/licenses/ for more information. =cut 1; # End of HTML::Auto HTML-Auto-0.04/lib/HTML/Auto.pm0000644000175000017500000001102711763417577015540 0ustar andrefsandrefspackage HTML::Auto; use warnings; use strict; use Template; use HTML::Auto::Templates; use Data::Dumper; require Exporter; our @ISA = qw(Exporter); our @EXPORT_OK = qw(matrix h v); =encoding utf-8 =head1 NAME HTML::Auto - automatic write HTML for common elements =head1 VERSION Version 0.04 =cut our $VERSION = '0.04'; =head1 SYNOPSIS Simple example: use HTML::Auto qw/matrix h v/; my @cols = qw/c1 c2 c3 c4 c5/; my @lines = qw/l1 l2 l3 l4 l5/; my $data = [ [1,2,3,4,5], [6,7,8,9,0], [1,1,1,1,1], [2,2,2,2,2], [3,3,3,3,3] ]; my $m = matrix(\@cols,\@lines,$data); print v( h($m,$m,$m), h($m,$m), ); Using attributes: use HTML::Auto qw/matrix h v/; my @cols = qw/c1 c2/; my @lines = qw/l1 l2/; my $data = [ [ {v => 1, a => { style => 'background: green'}}, 2 ], [ {v => 3, a => {class => 'foo'}}, {v => 4, a => {style => 'color: red'}} ] ]; my $m = matrix(\@cols,\@lines,$data); print v( h($m) ); With mouse-over span: use HTML::Auto qw/matrix h v/; my @cols = qw/c1 c2/; my @lines = qw/l1 l2/; my $data = [[1,2], [3, { v=> 4, more_info => "This is a pop-up!" }] ]; my $m = matrix(\@cols,\@lines,$data); print v( h($m) ); Passing additional CSS: use HTML::Auto qw/matrix h v/; my @cols = qw/c1 c2/; my @lines = qw/l1 l2/; my $data = [ [ {v => 1, a => { class => 'warn'}}, 2 ], [3,4] ]; my $options = { css => '.warn { background-color: yellow !important; }' }; my $m = matrix(\@cols,\@lines,$data,$options); print v( h($m) ); =head1 SUBROUTINES/METHODS =head2 matrix =cut sub matrix { my ($cols,$lines,$data,$options) = @_; # pre-process data foreach (@$cols) { $_ = ucfirst($_); } foreach (@$lines) { $_ = ucfirst($_); } my $vals = []; my $attrs = []; my $more = []; foreach my $row (@$data){ my $vrow = []; my $arow = []; my $mrow = []; foreach(@$row){ if (ref($_)){ push @$vrow, $_->{v}; push @$arow, $_->{a}; push @$mrow, $_->{more_info}; } else { push @$vrow, $_; push @$arow, undef; push @$mrow, undef; } } push @$vals, $vrow; push @$attrs, $arow; push @$more, $mrow; } my $vars = { cols => $cols, lines => $lines, vals => $vals, attrs => $attrs, more => $more, }; $vars->{css} = $options->{css} if $options->{css}; my $template_name = 'matrix'; __process($template_name, $vars); } =head2 h A function to allow horizontal composition. =cut sub h { my (@list) = @_; my $vars = { list => [@list], }; my $template_name = 'h'; __process($template_name, $vars); } =head2 v A function to allow vertical composition. =cut sub v { my (@list) = @_; my $vars = { list => [@list], }; my $template_name = 'v'; __process($template_name, $vars); } sub __process { my ($template_name,$vars) = @_; # build html from template my $template_config = { INCLUDE_PATH => [ 'templates' ], }; my $template = Template->new({ LOAD_TEMPLATES => [ HTML::Auto::Templates->new($template_config) ], }); my $html; $template->process($template_name, $vars, \$html); $html; } =head1 AUTHOR Nuno Carvalho, C<< >> André Santos, C<< >> =head1 BUGS Please report any bugs or feature requests to C, or through the web interface at L. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. =head1 SUPPORT You can find documentation for this module with the perldoc command. perldoc HTML::Auto You can also look for information at: =over 4 =item * RT: CPAN's request tracker L =item * AnnoCPAN: Annotated CPAN documentation L =item * CPAN Ratings L =item * Search CPAN L =back =head1 ACKNOWLEDGEMENTS =head1 LICENSE AND COPYRIGHT Copyright 2012 Project Natura. This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License. See http://dev.perl.org/licenses/ for more information. =cut 1; # End of HTML::Auto HTML-Auto-0.04/README0000644000175000017500000000207111754735364013634 0ustar andrefsandrefsHTML-Auto This module attempts to provide easy access to some typical structures used in HTML, for example matrixes. The module is still in heavy development. INSTALLATION To install this module, run the following commands: perl Makefile.PL make make test make install SUPPORT AND DOCUMENTATION After installing, you can find documentation for this module with the perldoc command. perldoc HTML::Auto You can also look for information at: RT, CPAN's request tracker http://rt.cpan.org/NoAuth/Bugs.html?Dist=HTML-Auto AnnoCPAN, Annotated CPAN documentation http://annocpan.org/dist/HTML-Auto CPAN Ratings http://cpanratings.perl.org/d/HTML-Auto Search CPAN http://search.cpan.org/dist/HTML-Auto/ LICENSE AND COPYRIGHT Copyright (C) 2010 Nuno Carvalho This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License. See http://dev.perl.org/licenses/ for more information. HTML-Auto-0.04/Changes0000644000175000017500000000113211763417700014233 0ustar andrefsandrefsRevision history for HTML-Auto 0.04 Tue Jun 5 16:02:52 WEST 2012 Fixed UTF-8 in POD 0.03 Tue May 22 22:50:31 WEST 2012 Cells can have a hover pop-up. Additional CSS can be provided. Added some tests. 0.02 Sat Apr 21 14:53:52 WEST 2012 Update docs. 0.01 Sun Sep 25 16:45:04 WEST 2011 First version. 0.01_3 Tue Sep 20 23:24:32 WEST 2011 Matrix elements may be scalars. 0.01_2 Sun Jan 30 13:58:32 WET 2011 Fix makefile dependencies. 0.01_1 Fri Jan 28 14:11:09 WET 2011 First devel release. HTML-Auto-0.04/MANIFEST0000644000175000017500000000046711763420347014104 0ustar andrefsandrefsChanges MANIFEST Makefile.PL README lib/HTML/Auto.pm lib/HTML/Auto/Templates.pm t/00-load.t t/01-basic.t t/manifest.t t/pod-coverage.t t/pod.t META.yml Module YAML meta-data (added by MakeMaker) META.json Module JSON meta-data (added by MakeMaker)