From 3ddfef35d69d78074c30793012a9f9fea8ca8f73 Mon Sep 17 00:00:00 2001 From: Yorhel Date: Tue, 9 Dec 2008 13:40:48 +0100 Subject: VNList status indicator on VN pages --- lib/ChangeLog | 2 ++ lib/VNDB/DB/ULists.pm | 4 +++- lib/VNDB/Func.pm | 17 ++++++++++++++++- lib/VNDB/Handler/ULists.pm | 10 +--------- lib/VNDB/Handler/VNPage.pm | 18 +++++++++++++++++- static/f/style.css | 13 ++++++++++--- 6 files changed, 49 insertions(+), 15 deletions(-) diff --git a/lib/ChangeLog b/lib/ChangeLog index 5492631d..e5b23d0a 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -34,6 +34,8 @@ TODO: system in the future) - Improved formsub interface - Improved VN relation editor interface + - Voted/non-voted filter to user's VNLists + - VNList status can only be changed from release pages 1.23 - 2008-10-22 (r117) - Removed redirects for old revision URLs (the code wasn't very secure...) diff --git a/lib/VNDB/DB/ULists.pm b/lib/VNDB/DB/ULists.pm index 0f84acb3..c47af8e5 100644 --- a/lib/VNDB/DB/ULists.pm +++ b/lib/VNDB/DB/ULists.pm @@ -20,8 +20,10 @@ sub dbVNListGet { my %where = ( 'uid = ?' => $o{uid}, - $o{rid} ? ( + $o{rid} && !ref $o{rid} ? ( 'rid = ?' => $o{rid} ) : (), + $o{rid} && ref $o{rid} ? ( + 'rid IN(!l)' => [$o{rid}] ) : (), ); return $self->dbAll(q| diff --git a/lib/VNDB/Func.pm b/lib/VNDB/Func.pm index bf0a871f..52aa16a4 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 gtintype |; +our @EXPORT = qw| shorten date datestr monthstr userstr bb2html gtintype liststat |; # I would've done this as a #define if this was C... @@ -171,5 +171,20 @@ sub gtintype { } +# Argument: hashref with rstat and vstat +# Returns: empty string if not in list, otherwise colour-encoded list status +sub liststat { + my $l = shift; + return '' if !$l; + my $rs = $YAWF::OBJ->{vn_rstat}[$l->{rstat}]; + $rs = qq|$rs| if $l->{rstat} == 2; # Obtained + $rs = qq|$rs| if $l->{rstat} < 2; # Unknown/pending + my $vs = $YAWF::OBJ->{vn_vstat}[$l->{vstat}]; + $vs = qq|$vs| if $l->{vstat} == 2; # Finished + $vs = qq|$vs| if $l->{vstat} == 0 || $l->{vstat} == 4; # Unknown/dropped + return "$rs / $vs"; +} + + 1; diff --git a/lib/VNDB/Handler/ULists.pm b/lib/VNDB/Handler/ULists.pm index b94cd8e6..6c1c338f 100644 --- a/lib/VNDB/Handler/ULists.pm +++ b/lib/VNDB/Handler/ULists.pm @@ -303,15 +303,7 @@ sub _vnlist_browse { a href => "/r$_->{rid}", title => $_->{original}||$_->{title}, shorten $_->{title}, 50; end; td colspan => 2, class => 'tc4'; - my $rs = $self->{vn_rstat}[$_->{rstat}]; - $rs = qq|$rs| if $_->{rstat} == 2; # Obtained - $rs = qq|$rs| if $_->{rstat} < 2; # Unknown/pending - lit $rs; - txt ' / '; - my $vs = $self->{vn_vstat}[$_->{vstat}]; - $vs = qq|$vs| if $_->{vstat} == 2; # Finished - $vs = qq|$vs| if $_->{vstat} == 0 || $_->{vstat} == 4; # Unknown/dropped - lit $vs; + lit liststat($_); end; end; } diff --git a/lib/VNDB/Handler/VNPage.pm b/lib/VNDB/Handler/VNPage.pm index bc56dd8c..3a257404 100644 --- a/lib/VNDB/Handler/VNPage.pm +++ b/lib/VNDB/Handler/VNPage.pm @@ -360,6 +360,13 @@ sub _releases { return; } + if($self->authInfo->{id}) { + my $l = $self->dbVNListGet(uid => $self->authInfo->{id}, rid => [map $_->{id}, @$r]); + for my $i (@$l) { + (grep $i->{rid} == $_->{id}, @$r)[0]{ulist} = $i; + } + } + my @lang; for my $l (@$r) { push @lang, $l->{language} if !grep $l->{language} eq $_, @lang; @@ -368,7 +375,7 @@ sub _releases { table; for my $l (@lang) { Tr class => 'lang'; - td colspan => 5; + td colspan => 6; acronym class => 'icons lang '.$l, title => $self->{languages}{$l}, ' '; txt $self->{languages}{$l}; end; @@ -388,6 +395,15 @@ sub _releases { a href => "/r$rel->{id}", title => $rel->{original}||$rel->{title}, $rel->{title}; end; td class => 'tc5'; + if($rel->{ulist}) { + a href => "/r$rel->{id}"; + lit liststat $rel->{ulist}; + end; + } else { + txt ' '; + } + end; + td class => 'tc6'; if($rel->{website}) { a href => $rel->{website}, rel => 'nofollow', class => 'icons ext', title => 'WWW', ' '; } else { diff --git a/static/f/style.css b/static/f/style.css index 6394676d..085a275e 100644 --- a/static/f/style.css +++ b/static/f/style.css @@ -85,6 +85,8 @@ h2 p { p.description { margin: 10px 100px!important; } +b.done { font-weight: normal; color: #0c0 } +b.todo { font-weight: normal; color: #c00 } @@ -548,7 +550,14 @@ div.vndescription p { } .releases td.tc5 { text-align: right; - width: 20px; +} +.releases td.tc5 a { + color: #ddd!important; + border: 0; +} +.releases td.tc6 { + text-align: right; + width: 25px; padding: 0; } a.addnew { @@ -838,8 +847,6 @@ ul#catselect li li.exc { background-position: 0px -33px; color: #c00; } .browse.rlist .relhid .tc2 { padding: 0; width: 30px; } .browse.rlist .relhid .tc3 { width: auto } .browse.rlist .relhid .tc4 { text-align: right } -.rlist .done { font-weight: normal; color: #0c0 } -.rlist .todo { font-weight: normal; color: #c00 } -- cgit v1.2.3