X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FSQL%2FTranslator%2FProducer%2FHTML.pm;h=f35eb3cd488387ec44e3c5650ab71602a23e9a64;hb=935800450f88b0500c4fa7c3b174cd22b5f9eb56;hp=812a7d0dbe2a0ea6e875f2592e1ff2ed18b411ab;hpb=977651a56d55fa4b2aacb19977667abd7f241c9a;p=dbsrgits%2FSQL-Translator.git
diff --git a/lib/SQL/Translator/Producer/HTML.pm b/lib/SQL/Translator/Producer/HTML.pm
index 812a7d0..f35eb3c 100644
--- a/lib/SQL/Translator/Producer/HTML.pm
+++ b/lib/SQL/Translator/Producer/HTML.pm
@@ -1,31 +1,12 @@
package SQL::Translator::Producer::HTML;
-# -------------------------------------------------------------------
-# $Id: HTML.pm,v 1.11 2004-02-09 23:02:15 kycl4rk Exp $
-# -------------------------------------------------------------------
-# Copyright (C) 2002-4 SQLFairy Authors
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License as
-# published by the Free Software Foundation; version 2.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-# 02111-1307 USA
-# -------------------------------------------------------------------
-
use strict;
use Data::Dumper;
use vars qw($VERSION $NOWRAP $NOLINKTABLE $NAME);
-$VERSION = sprintf "%d.%02d", q$Revision: 1.11 $ =~ /(\d+)\.(\d+)/;
-$NAME = join ', ', __PACKAGE__, $VERSION;
+$VERSION = '1.59';
+
+$NAME = __PACKAGE__;
$NOWRAP = 0 unless defined $NOWRAP;
$NOLINKTABLE = 0 unless defined $NOLINKTABLE;
@@ -68,9 +49,8 @@ sub produce {
-title => $title,
%stylesheet,
-meta => { generator => $NAME },
- });
+ }),
$q->h1({ -class => 'SchemaDescription' }, $title),
- $q->a({ -name => 'top' }),
$q->hr;
}
@@ -84,7 +64,8 @@ sub produce {
# Leading table of links
push @html,
$q->comment("Table listing ($count)"),
- $q->start_table({ -width => '100%', -class => 'LinkTable' }),
+ $q->a({ -name => 'top' }),
+ $q->start_table({ -width => '100%', -class => 'LinkTable'}),
# XXX This needs to be colspan="$#{$table->fields}" class="LinkTableHeader"
$q->Tr(
@@ -95,7 +76,7 @@ sub produce {
),
);
- for my $table (sort @table_names) {
+ for my $table (@table_names) {
my $table_name = $table->name;
push @html,
$q->comment("Start link to table '$table_name'"),
@@ -113,7 +94,8 @@ sub produce {
my $table_name = $table->name or next;
my @fields = $table->get_fields or next;
push @html,
- $q->comment("Starting table '$table_name'");
+ $q->comment("Starting table '$table_name'"),
+ $q->a({ -name => $table_name }),
$q->table({ -class => 'TableHeader', -width => '100%' },
$q->Tr({ -class => 'TableHeaderRow' },
$q->td({ -class => 'TableHeaderCell' }, $q->h3($table_name)),
@@ -135,7 +117,7 @@ sub produce {
# Fields
#
push @html,
- $q->start_table,
+ $q->start_table({ -border => 1 }),
$q->Tr(
$q->th({ -class => 'FieldHeader' },
[
@@ -149,6 +131,7 @@ sub produce {
)
);
+ my $i = 0;
for my $field ( @fields ) {
my $name = $field->name || '';
$name = qq[$name];
@@ -172,8 +155,10 @@ sub produce {
push @other, 'UNIQUE' if $field->is_unique;
push @other, 'NOT NULL' unless $field->is_nullable;
push @other, $comment if $comment;
+ my $class = $i++ % 2 ? 'even' : 'odd';
push @html,
$q->Tr(
+ { -class => "tr-$class" },
$q->td({ -class => "FieldCellName" }, $name),
$q->td({ -class => "FieldCellType" }, $data_type),
$q->td({ -class => "FieldCellSize" }, $size),
@@ -208,13 +193,40 @@ sub produce {
push @html, $q->end_table;
}
+ #
+ # Constraints
+ #
+ my @constraints =
+ grep { $_->type ne PRIMARY_KEY } $table->get_constraints;
+ if ( @constraints ) {
+ push @html,
+ $q->h3('Constraints'),
+ $q->start_table({ -border => 1 }),
+ $q->Tr({ -class => 'IndexRow' },
+ $q->th([ 'Type', 'Fields' ])
+ );
+
+ for my $c ( @constraints ) {
+ my $type = $c->type || '';
+ my $fields = join( ', ', $c->fields ) || '';
+
+ push @html,
+ $q->Tr({ -class => 'IndexCell' },
+ $q->td( [ $type, $fields ] )
+ );
+ }
+
+ push @html, $q->end_table;
+ }
+
push @html, $q->hr;
}
+ my $sqlt_version = $t->version;
if ($wrap) {
push @html,
qq[Created by ],
- qq[SQL::Translator],
+ qq[SQL::Translator $sqlt_version],
$q->end_html;
}
@@ -302,7 +314,7 @@ insignificant whitespace and be generally smaller.
=head1 AUTHORS
-Ken Y. Clark Ekclark@cpan.orgE,
+Ken Youens-Clark Ekclark@cpan.orgE,
Darren Chamberlain Edarren@cpan.orgE.
=cut