summaryrefslogtreecommitdiff
path: root/lib/VNDB/Util
diff options
context:
space:
mode:
Diffstat (limited to 'lib/VNDB/Util')
-rw-r--r--lib/VNDB/Util/CommonHTML.pm9
-rw-r--r--lib/VNDB/Util/FormHTML.pm3
-rw-r--r--lib/VNDB/Util/LayoutHTML.pm25
-rw-r--r--lib/VNDB/Util/Misc.pm24
4 files changed, 52 insertions, 9 deletions
diff --git a/lib/VNDB/Util/CommonHTML.pm b/lib/VNDB/Util/CommonHTML.pm
index 70fdfde3..6b6725c6 100644
--- a/lib/VNDB/Util/CommonHTML.pm
+++ b/lib/VNDB/Util/CommonHTML.pm
@@ -402,7 +402,7 @@ sub htmlVoteStats {
td colspan => 2, 'Vote graph';
end; end;
tfoot; Tr;
- td colspan => 2, sprintf '%d votes total, average %.2f%s', $count, $total/$count,
+ td colspan => 2, sprintf '%d vote%s total, average %.2f%s', $count, $count != 1 ? 's' : '', $total/$count,
$type eq 'v' ? ' ('.$self->{votes}[sprintf '%.0f', $total/$count-1].')' : '';
end; end;
for (reverse 0..$#$stats) {
@@ -443,7 +443,14 @@ sub htmlVoteStats {
}
end;
}
+
clearfloat;
+ if($type eq 'v') {
+ div;
+ h3 'Popularity';
+ p sprintf 'Ranked #%d out of %d with a score of %.2f.', $obj->{ranking}, $self->{stats}{vn}, $obj->{c_popularity}*100;
+ end;
+ }
end;
}
diff --git a/lib/VNDB/Util/FormHTML.pm b/lib/VNDB/Util/FormHTML.pm
index ff23682d..75471830 100644
--- a/lib/VNDB/Util/FormHTML.pm
+++ b/lib/VNDB/Util/FormHTML.pm
@@ -49,7 +49,8 @@ my %formerr_exeptions = (
usrexists => 'Someone already has this username, please choose something else',
mailexists => 'Someone already registered with that email address',
noimage => 'Image must be in JPEG or PNG format',
- toolarge => 'Image is too large, only 50kB allowed',
+ toolarge => 'Image is too large, only 500kB allowed',
+ oneaday => 'You can only register one account from the same IP within 24 hours',
);
diff --git a/lib/VNDB/Util/LayoutHTML.pm b/lib/VNDB/Util/LayoutHTML.pm
index a8773894..ccf2a9c6 100644
--- a/lib/VNDB/Util/LayoutHTML.pm
+++ b/lib/VNDB/Util/LayoutHTML.pm
@@ -12,8 +12,8 @@ our @EXPORT = qw|htmlHeader htmlFooter|;
sub htmlHeader { # %options->{ title, js, noindex, search }
my($self, %o) = @_;
- my $skin = $self->authInfo->{skin} || $self->{skin_default};
- $skin = $self->{skin_default} if !-d "$VNDB::ROOT/static/s/$skin";
+ my $skin = $self->reqParam('skin') || $self->authInfo->{skin} || $self->{skin_default};
+ $skin = $self->{skin_default} if !$self->{skins}{$skin} || !-d "$VNDB::ROOT/static/s/$skin";
# heading
html;
@@ -27,12 +27,16 @@ sub htmlHeader { # %options->{ title, js, noindex, search }
script type => 'text/javascript', src => $self->{url_static}.'/f/script.js?'.$self->{version};
# most browsers don't like a self-closing <script> tag...
end;
+ if($self->authInfo->{customcss}) {
+ (my $css = $self->authInfo->{customcss}) =~ s/\n/ /g;
+ style type => 'text/css', $css;
+ }
meta name => 'robots', content => 'noindex, follow', undef if $o{noindex};
end;
body;
div id => 'bgright', ' ';
div id => 'header';
- h1 $self->debug ? (class => 'debug') : ();
+ h1;
a href => '/', lc $self->{site_title};
end;
end;
@@ -118,14 +122,13 @@ sub _menu {
[ threads => 'Threads' ],
[ posts => 'Posts' ],
);
- my $stats = $self->dbStats;
div class => 'menubox';
h2 'Database Statistics';
div;
dl;
for (@stats) {
dt $$_[1];
- dd $stats->{$$_[0]};
+ dd $self->{stats}{$$_[0]};
}
end;
clearfloat;
@@ -141,9 +144,19 @@ sub htmlFooter {
txt "vndb $self->{version} | ";
a href => '/d7', 'about us';
txt ' | ';
- a href => 'mailto:contact@vndb.org', 'contact@vndb.org';
+ a href => "mailto:$self->{admin_email}", $self->{admin_email};
+ txt ' | ';
+ a href => $self->{source_url}, 'source';
end;
end; # /div maincontent
+ if($self->debug) {
+ div id => 'debug';
+ h2 'This is not VNDB!';
+ txt 'The real VNDB is ';
+ a href => 'http://vndb.org/', 'here';
+ txt '.';
+ end;
+ }
end; # /body
end; # /html
diff --git a/lib/VNDB/Util/Misc.pm b/lib/VNDB/Util/Misc.pm
index 94cdcd1e..139eb571 100644
--- a/lib/VNDB/Util/Misc.pm
+++ b/lib/VNDB/Util/Misc.pm
@@ -6,7 +6,7 @@ use warnings;
use Exporter 'import';
use Tie::ShareLite ':lock';
-our @EXPORT = qw|multiCmd|;
+our @EXPORT = qw|multiCmd vnCacheUpdate|;
# Sends a command to Multi
@@ -26,3 +26,25 @@ sub multiCmd {
$s->unlock();
$self->{_multiCmd} = [];
}
+
+
+# Recalculates the vn.c_* columns and regenerates the related relation graphs on any change
+# Arguments: list of vids to be updated
+sub vnCacheUpdate {
+ my($self, @vns) = @_;
+
+ my $before = $self->dbVNGet(id => \@vns, order => 'v.id', what => 'relations');
+ $self->dbVNCache(@vns);
+ my $after = $self->dbVNGet(id => \@vns, order => 'v.id');
+
+ my @upd = map {
+ @{$before->[$_]{relations}} && (
+ $before->[$_]{c_released} != $after->[$_]{c_released}
+ || $before->[$_]{c_languages} ne $after->[$_]{c_languages}
+ ) ? $before->[$_]{id} : ();
+ } 0..$#$before;
+ $self->multiCmd('relgraph '.join(' ', @upd)) if @upd;
+}
+
+
+1;