summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/global.pl10
-rw-r--r--lib/VNDB/Func.pm30
-rw-r--r--lib/VNDB/Handler/Releases.pm147
-rw-r--r--static/f/style.css19
4 files changed, 202 insertions, 4 deletions
diff --git a/data/global.pl b/data/global.pl
index 950d1577..3b582f7f 100644
--- a/data/global.pl
+++ b/data/global.pl
@@ -173,6 +173,16 @@ our %S = (
xb3 => 'Xbox 360',
oth => 'Other'
},
+ media => {
+ #DB display qty
+ cd => [ 'CD', 1 ],
+ dvd => [ 'DVD', 1 ],
+ gdr => [ 'GD-ROM', 1 ],
+ blr => [ 'Blu-Ray disk', 1 ],
+ in => [ 'Internet download', 0 ],
+ pa => [ 'Patch', 0 ],
+ otc => [ 'Other (console)', 0 ],
+ },
);
diff --git a/lib/VNDB/Func.pm b/lib/VNDB/Func.pm
index ac555d1d..8971c6a8 100644
--- a/lib/VNDB/Func.pm
+++ b/lib/VNDB/Func.pm
@@ -5,7 +5,7 @@ use strict;
use warnings;
use Exporter 'import';
use POSIX 'strftime';
-our @EXPORT = qw| shorten date datestr monthstr userstr bb2html |;
+our @EXPORT = qw| shorten date datestr monthstr userstr bb2html gtintype |;
# I would've done this as a #define if this was C...
@@ -143,5 +143,33 @@ sub bb2html {
}
+# GTIN code as argument,
+# Returns 'JAN', 'EAN', 'UPC' or undef,
+# Also 'normalizes' the first argument in place
+sub gtintype {
+ $_[0] =~ s/[^\d]+//g;
+ $_[0] =~ s/^0+//;
+ my $c = shift;
+ return undef if $c !~ /^[0-9]{12,13}$/; # only gtin-12 and 13
+ $c = ('0'x(13-length $c)) . $c; # pad with zeros
+
+ # calculate check digit according to
+ # http://www.gs1.org/productssolutions/barcodes/support/check_digit_calculator.html#how
+ my @n = reverse split //, $c;
+ my $n = shift @n;
+ $n += $n[$_] * ($_ % 2 != 0 ? 1 : 3) for (0..$#n);
+ return undef if $n % 10 != 0;
+
+ # Do some rough guesses based on:
+ # http://www.gs1.org/productssolutions/barcodes/support/prefix_list.html
+ # and http://en.wikipedia.org/wiki/List_of_GS1_country_codes
+ local $_ = $c;
+ return 'JAN' if /^4[59]/; # prefix code 450-459 & 490-499
+ return 'UPC' if /^(?:0[01]|0[6-9]|13|75[45])/; # prefix code 000-019 & 060-139 & 754-755
+ return undef if /(?:0[2-5]|2|97[789]|9[6-9])/; # some codes we don't want: 020–059 & 200-299 & 977-999
+ return 'EAN'; # let's just call everything else EAN :)
+}
+
+
1;
diff --git a/lib/VNDB/Handler/Releases.pm b/lib/VNDB/Handler/Releases.pm
new file mode 100644
index 00000000..6c033d5c
--- /dev/null
+++ b/lib/VNDB/Handler/Releases.pm
@@ -0,0 +1,147 @@
+
+package VNDB::Handler::Releases;
+
+use strict;
+use warnings;
+use YAWF ':html';
+use VNDB::Func;
+
+
+YAWF::register(
+ qr{r([1-9]\d*)}, \&page,
+);
+
+
+sub page {
+ my($self, $rid) = @_;
+
+ my $r = $self->dbReleaseGet(id => $rid, what => 'vn producers platforms media')->[0];
+ return 404 if !$r->{id};
+
+ $self->htmlHeader(title => $r->{title});
+ $self->htmlMainTabs('r', $r);
+ div class => 'mainbox release';
+ h1 $r->{title};
+ h2 class => 'alttitle', $r->{original} if $r->{original};
+
+ _infotable($self, $r);
+
+ if($r->{notes}) {
+ p class => 'description';
+ lit bb2html $r->{notes};
+ end;
+ }
+
+ end;
+ $self->htmlFooter;
+}
+
+
+sub _infotable {
+ my($self, $r) = @_;
+ table;
+ Tr;
+ td class => 'key', ' ';
+ td ' ';
+ end;
+ my $i = 0;
+
+ Tr ++$i % 2 ? (class => 'odd') : ();
+ td 'Relation';
+ td;
+ for (@{$r->{vn}}) {
+ a href => "/v$_->{vid}", title => $_->{original}||$_->{title}, shorten $_->{title}, 60;
+ br if $_ != $r->{vn}[$#{$r->{vn}}];
+ }
+ end;
+ end;
+
+ Tr ++$i % 2 ? (class => 'odd') : ();
+ td 'Type';
+ td;
+ my $type = $self->{release_types}[$r->{type}];
+ acronym class => 'icons '.lc(substr $type, 0, 3), title => $type, ' ';
+ txt ' '.$type;
+ end;
+ end;
+
+ Tr ++$i % 2 ? (class => 'odd') : ();
+ td 'Language';
+ td;
+ acronym class => "icons lang $r->{language}", title => $self->{languages}{$r->{language}}, ' ';
+ txt ' '.$self->{languages}{$r->{language}};
+ end;
+ end;
+
+ if(@{$r->{platforms}}) {
+ Tr ++$i % 2 ? (class => 'odd') : ();
+ td 'Platform'.($#{$r->{platforms}} ? 's' : '');
+ td;
+ for(@{$r->{platforms}}) {
+ acronym class => "icons $_", title => $self->{platforms}{$_}, ' ';
+ txt ' '.$self->{platforms}{$_};
+ br if $_ ne $r->{platforms}[$#{$r->{platforms}}];
+ }
+ end;
+ end;
+ }
+
+ if(@{$r->{media}}) {
+ Tr ++$i % 2 ? (class => 'odd') : ();
+ td 'Medi'.($#{$r->{media}} ? 'a' : 'um');
+ td join ', ', map {
+ my $med = $self->{media}{$_->{medium}};
+ $med->[1] ? sprintf('%d %s%s', $_->{qty}, $med->[0], $_->{qty}>1?'s':'') : $med->[0]
+ } @{$r->{media}};
+ end;
+ }
+
+ Tr ++$i % 2 ? (class => 'odd') : ();
+ td 'Released';
+ td;
+ lit datestr $r->{released};
+ end;
+ end;
+
+ if($r->{minage} >= 0) {
+ Tr ++$i % 2 ? (class => 'odd') : ();
+ td 'Age rating';
+ td $self->{age_ratings}{$r->{minage}};
+ end;
+ }
+
+ if(@{$r->{producers}}) {
+ Tr ++$i % 2 ? (class => 'odd') : ();
+ td 'Producer'.($#{$r->{producers}} ? 's' : '');
+ td;
+ for (@{$r->{producers}}) {
+ a href => "/p$_->{id}", title => $_->{original}||$_->{name}, shorten $_->{name}, 60;
+ br if $_ != $r->{producers}[$#{$r->{producers}}];
+ }
+ end;
+ end;
+ }
+
+ if($r->{gtin}) {
+ Tr ++$i % 2 ? (class => 'odd') : ();
+ td gtintype $r->{gtin};
+ td $r->{gtin};
+ end;
+ }
+
+ if($r->{website}) {
+ Tr ++$i % 2 ? (class => 'odd') : ();
+ td 'Links';
+ td;
+ a href => $r->{website}, rel => 'nofollow', 'Official website';
+ end;
+ end;
+ }
+
+ end;
+}
+
+
+
+1;
+
diff --git a/static/f/style.css b/static/f/style.css
index 04ce815d..8372f0b3 100644
--- a/static/f/style.css
+++ b/static/f/style.css
@@ -68,6 +68,9 @@ h2 p {
font-weight: normal;
display: inline;
}
+p.description {
+ margin: 10px 100px!important;
+}
@@ -707,9 +710,6 @@ ul#catselect li li.exc { background-position: 0px -33px; color: #c00; }
/***** Producer page/list *******/
-.producerpage p.description {
- margin: 10px 100px!important;
-}
.producerpage ul {
margin: 0 50px;
}
@@ -744,6 +744,19 @@ ul#catselect li li.exc { background-position: 0px -33px; color: #c00; }
+/***** Release page *****/
+
+.release table {
+ width: 400px;
+ margin: 0 auto;
+}
+.release .key {
+ width: 70px;
+}
+
+
+
+
/***** Warning/Notice Box *****/
div.warning, div.notice {