summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/VNDB/DB/ULists.pm2
-rw-r--r--lib/VNDB/Func.pm9
-rw-r--r--lib/VNDB/Handler/Producers.pm2
-rw-r--r--lib/VNDB/Handler/Users.pm64
-rw-r--r--lib/VNDB/Handler/VNBrowse.pm2
-rw-r--r--lib/VNDB/Handler/VNPage.pm27
-rw-r--r--lib/VNDB/Util/CommonHTML.pm61
-rw-r--r--lib/VNDB/Util/LayoutHTML.pm3
-rw-r--r--static/f/style.css33
9 files changed, 169 insertions, 34 deletions
diff --git a/lib/VNDB/DB/ULists.pm b/lib/VNDB/DB/ULists.pm
index c47af8e5..212388d0 100644
--- a/lib/VNDB/DB/ULists.pm
+++ b/lib/VNDB/DB/ULists.pm
@@ -137,7 +137,7 @@ sub dbVoteGet {
my %where = (
$o{uid} ? ( 'n.uid = ?' => $o{uid} ) : (),
$o{vid} ? ( 'n.vid = ?' => $o{vid} ) : (),
- $o{hide} ? ( 'u.show_list = FALSE' => 1 ) : (),
+ $o{hide} ? ( 'u.show_list = TRUE' => 1 ) : (),
);
my($r, $np) = $self->dbPage(\%o, q|
diff --git a/lib/VNDB/Func.pm b/lib/VNDB/Func.pm
index 52aa16a4..0fb0e6a1 100644
--- a/lib/VNDB/Func.pm
+++ b/lib/VNDB/Func.pm
@@ -3,9 +3,10 @@ package VNDB::Func;
use strict;
use warnings;
+use YAWF ':html';
use Exporter 'import';
use POSIX 'strftime';
-our @EXPORT = qw| shorten date datestr monthstr userstr bb2html gtintype liststat |;
+our @EXPORT = qw| shorten date datestr monthstr userstr bb2html gtintype liststat clearfloat |;
# I would've done this as a #define if this was C...
@@ -186,5 +187,11 @@ sub liststat {
}
+# Clears a float, to make sure boxes always have the correct height
+sub clearfloat {
+ div class => 'clearfloat', '';
+}
+
+
1;
diff --git a/lib/VNDB/Handler/Producers.pm b/lib/VNDB/Handler/Producers.pm
index c857aa74..d28a4746 100644
--- a/lib/VNDB/Handler/Producers.pm
+++ b/lib/VNDB/Handler/Producers.pm
@@ -199,7 +199,7 @@ sub list {
end;
}
}
- br style => 'clear: left';
+ clearfloat;
end;
$self->htmlBrowseNavigate($pageurl, $f->{p}, $np, 'b');
$self->htmlFooter;
diff --git a/lib/VNDB/Handler/Users.pm b/lib/VNDB/Handler/Users.pm
index b2ecc841..80bc11ec 100644
--- a/lib/VNDB/Handler/Users.pm
+++ b/lib/VNDB/Handler/Users.pm
@@ -27,11 +27,73 @@ sub userpage {
my $u = $self->dbUserGet(uid => $uid)->[0];
return 404 if !$u->{id};
+ my $votes = $u->{c_votes} && $self->dbVoteStats(uid => $uid);
+
$self->htmlHeader(title => ucfirst($u->{username})."'s Profile");
$self->htmlMainTabs('u', $u);
- div class => 'mainbox';
+ div class => 'mainbox userpage';
h1 ucfirst($u->{username})."'s Profile";
+
+ table;
+ Tr;
+ td class => 'key', ' ';
+ td ' ';
+ end;
+ my $i = 0;
+
+ Tr ++$i % 2 ? (class => 'odd') : ();
+ td 'Username';
+ td;
+ txt ucfirst($u->{username}).' (';
+ a href => "/u$uid", "u$uid";
+ txt ')';
+ end;
+ end;
+
+ Tr ++$i % 2 ? (class => 'odd') : ();
+ td 'Registered';
+ td date $u->{registered};
+ end;
+
+ Tr ++$i % 2 ? (class => 'odd') : ();
+ td 'Edits';
+ td;
+ if($u->{c_changes}) {
+ a href => "/u$uid/hist", $u->{c_changes};
+ } else {
+ txt '-';
+ }
+ end;
+ end;
+
+ Tr ++$i % 2 ? (class => 'odd') : ();
+ td 'Votes';
+ td;
+ if(!$u->{show_list}) {
+ txt 'hidden';
+ } elsif($votes) {
+ my($total, $count) = (0, 0);
+ for (1..@$votes) {
+ $total += $_*$votes->[$_-1];
+ $count += $votes->[$_-1];
+ }
+ a href => "/u$uid/list?v=1", $count;
+ txt sprintf ' (%.2f average)', $total/$count;
+ } else {
+ txt '-';
+ }
+ end;
+ end;
+
+ end;
end;
+
+ if($u->{show_list} && $votes) {
+ div class => 'mainbox';
+ h1 'Vote statistics';
+ $self->htmlVoteStats(u => $u, $votes);
+ end;
+ }
$self->htmlFooter;
}
diff --git a/lib/VNDB/Handler/VNBrowse.pm b/lib/VNDB/Handler/VNBrowse.pm
index c0c3754e..dd79990e 100644
--- a/lib/VNDB/Handler/VNBrowse.pm
+++ b/lib/VNDB/Handler/VNBrowse.pm
@@ -172,7 +172,7 @@ sub _filters {
end;
}
- br style => 'clear: left';
+ clearfloat;
end;
end;
end;
diff --git a/lib/VNDB/Handler/VNPage.pm b/lib/VNDB/Handler/VNPage.pm
index 2bfe4eac..57773839 100644
--- a/lib/VNDB/Handler/VNPage.pm
+++ b/lib/VNDB/Handler/VNPage.pm
@@ -467,35 +467,12 @@ sub _stats {
my($self, $v) = @_;
my $stats = $self->dbVoteStats(vid => $v->{id});
- my($max, $count, $total) = (0, 0);
- for (0..$#$stats) {
- $max = $stats->[$_] if $stats->[$_] > $max;
- $count += $stats->[$_];
- $total += $stats->[$_]*($_+1);
- }
-
div class => 'mainbox';
h1 'User stats';
- if(!$max) {
+ if(!grep $_ > 0, @$stats) {
p "Nobody has voted on this visual novel yet...";
} else {
- table class => 'votegraph';
- thead; Tr;
- td colspan => 2, 'Vote graph';
- end; end;
- for (reverse 0..$#$stats) {
- Tr;
- td class => 'number', $_+1;
- td class => 'graph';
- div style => 'width: '.($stats->[$_] ? $stats->[$_]/$max*250 : 0).'px', ' ';
- txt $stats->[$_];
- end;
- end;
- }
- tfoot; Tr;
- td colspan => 2, sprintf '%d votes total, average %.2f (%s)', $count, $total/$count, $self->{votes}[sprintf '%.0f', $total/$count-1];
- end; end;
- end;
+ $self->htmlVoteStats(v => $v, $stats);
}
end;
}
diff --git a/lib/VNDB/Util/CommonHTML.pm b/lib/VNDB/Util/CommonHTML.pm
index 5cf3d729..df114cd7 100644
--- a/lib/VNDB/Util/CommonHTML.pm
+++ b/lib/VNDB/Util/CommonHTML.pm
@@ -9,7 +9,10 @@ use Algorithm::Diff::XS 'compact_diff';
use VNDB::Func;
use Encode 'encode_utf8', 'decode_utf8';
-our @EXPORT = qw|htmlMainTabs htmlDenied htmlHiddenMessage htmlBrowse htmlBrowseNavigate htmlRevision htmlEditMessage htmlItemMessage|;
+our @EXPORT = qw|
+ htmlMainTabs htmlDenied htmlHiddenMessage htmlBrowse htmlBrowseNavigate
+ htmlRevision htmlEditMessage htmlItemMessage htmlVoteStats
+|;
# generates the "main tabs". These are the commonly used tabs for
@@ -383,4 +386,60 @@ sub htmlItemMessage {
}
+# generates two tables, one with a vote graph, other with recent votes
+sub htmlVoteStats {
+ my($self, $type, $obj, $stats) = @_;
+
+ my($max, $count, $total) = (0, 0);
+ for (0..$#$stats) {
+ $max = $stats->[$_] if $stats->[$_] > $max;
+ $count += $stats->[$_];
+ $total += $stats->[$_]*($_+1);
+ }
+ div class => 'votestats';
+ table class => 'votegraph';
+ thead; Tr;
+ td colspan => 2, 'Vote graph';
+ end; end;
+ for (reverse 0..$#$stats) {
+ Tr;
+ td class => 'number', $_+1;
+ td class => 'graph';
+ div style => 'width: '.($stats->[$_] ? $stats->[$_]/$max*250 : 0).'px', ' ';
+ txt $stats->[$_];
+ end;
+ end;
+ }
+ tfoot; Tr;
+ td colspan => 2, sprintf '%d votes total, average %.2f%s', $count, $total/$count,
+ $type eq 'v' ? ' ('.$self->{votes}[sprintf '%.0f', $total/$count-1].')' : '';
+ end; end;
+ end;
+
+ my $recent = $self->dbVoteGet(
+ $type.'id' => $obj->{id}, results => 8, order => 'date DESC', hide => 1,
+ );
+ table class => 'recentvotes';
+ thead; Tr;
+ td colspan => 3, 'Recent votes';
+ end; end;
+ for (0..$#$recent) {
+ Tr $_ % 2 == 0 ? (class => 'odd') : ();
+ td;
+ if($type eq 'u') {
+ a href => "/v$recent->[$_]{vid}", title => $recent->[$_]{original}||$recent->[$_]{title}, shorten $recent->[$_]{title}, 40;
+ } else {
+ a href => "/u$recent->[$_]{uid}", $recent->[$_]{username};
+ }
+ end;
+ td $recent->[$_]{vote};
+ td date $recent->[$_]{date};
+ end;
+ }
+ end;
+ clearfloat;
+ end;
+}
+
+
1;
diff --git a/lib/VNDB/Util/LayoutHTML.pm b/lib/VNDB/Util/LayoutHTML.pm
index 061c4b16..ad0be091 100644
--- a/lib/VNDB/Util/LayoutHTML.pm
+++ b/lib/VNDB/Util/LayoutHTML.pm
@@ -5,6 +5,7 @@ use strict;
use warnings;
use YAWF ':html';
use Exporter 'import';
+use VNDB::Func;
our @EXPORT = qw|htmlHeader htmlFooter|;
@@ -125,7 +126,7 @@ sub _menu {
dd $stats->{$$_[0]};
}
end;
- br style => 'clear: left';
+ clearfloat;
end;
end;
end;
diff --git a/static/f/style.css b/static/f/style.css
index 085a275e..35405b54 100644
--- a/static/f/style.css
+++ b/static/f/style.css
@@ -88,6 +88,10 @@ p.description {
b.done { font-weight: normal; color: #0c0 }
b.todo { font-weight: normal; color: #c00 }
+.clearfloat {
+ clear: both;
+ height: 0;
+}
@@ -585,11 +589,21 @@ a.addnew {
margin: 0;
}
+
+
+
+
+/***** Vote stats ****/
+
+.votestats { width: 600px; margin: 0 auto; }
+.votegraph { float: left; margin-right: 20px }
.votegraph td { padding: 0 2px; }
.votegraph td.number { text-align: right }
.votegraph td div { float: left; height: 14px; background-color: #258; margin-right: 2px; }
-.votegraph thead td { background: transparent; text-align: center; }
-.votegraph tfoot td { text-align: right }
+.votestats thead td { background: transparent; text-align: center; padding: 2px; }
+.votestats tfoot td { text-align: right }
+
+.recentvotes { width: 300px }
@@ -850,6 +864,21 @@ ul#catselect li li.exc { background-position: 0px -33px; color: #c00; }
+
+/***** Userpage *****/
+
+.userpage table {
+ width: 400px;
+ margin: 0 auto;
+}
+.userpage .key {
+ width: 70px;
+}
+
+
+
+
+
/***** Warning/Notice Box *****/
div.warning, div.notice {