diff options
author | yorhel <yorhel@1fe2e327-d9db-4752-bcf7-ef0cb4a1748b> | 2008-05-19 07:01:24 +0000 |
---|---|---|
committer | yorhel <yorhel@1fe2e327-d9db-4752-bcf7-ef0cb4a1748b> | 2008-05-19 07:01:24 +0000 |
commit | 2ce770e7e5817f8838fdaf7bc7eda2a8da972962 (patch) | |
tree | 4aa6306599d38b6af01c8495d6731a838944602e /lib | |
parent | 8b72b6535a553f8751842369a3abc0016d18611e (diff) |
Too many changes to keep track of. See ChangeLog. (I should commit more often -.-)
git-svn-id: svn://vndb.org/vndb@13 1fe2e327-d9db-4752-bcf7-ef0cb4a1748b
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ChangeLog | 12 | ||||
-rw-r--r-- | lib/Multi/Anime.pm | 3 | ||||
-rw-r--r-- | lib/Multi/IRC.pm | 60 | ||||
-rw-r--r-- | lib/Multi/Maintenance.pm | 20 | ||||
-rw-r--r-- | lib/Multi/RG.pm | 2 | ||||
-rw-r--r-- | lib/VNDB.pm | 7 | ||||
-rw-r--r-- | lib/VNDB/Releases.pm | 2 | ||||
-rw-r--r-- | lib/VNDB/Util/DB.pm | 18 | ||||
-rw-r--r-- | lib/VNDB/VN.pm | 72 | ||||
-rw-r--r-- | lib/global.pl | 15 |
10 files changed, 130 insertions, 81 deletions
diff --git a/lib/ChangeLog b/lib/ChangeLog index 3f01492f..a9969ac5 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -10,9 +10,17 @@ TODO: uploaded or not + Use AniDB's daily title dump and implement a search feature to add anime relations without having to visit AniDB. - + Clear up style.css (or wait until the new layout is ready...) -1.15 - ? +1.16 - ? + - Release dates in the current year or month without a specified day will + be considered as not yet released + - Added platform and language icons to the VN browser + - Grouped producers, user stats and general information on the VN page + - Added language icons to producer browser + - A little CSS cleanup + - Grouped category browser into one advanced search + +1.15 - 2008-05-04 - Relation graph now also updated on VN title change - Anime relations - [js] Position of the dropdown box is now relative to the link element diff --git a/lib/Multi/Anime.pm b/lib/Multi/Anime.pm index 44fafb92..0da54e2e 100644 --- a/lib/Multi/Anime.pm +++ b/lib/Multi/Anime.pm @@ -257,7 +257,7 @@ sub updateanime { # aid, data|'notfound' # aid, ANN id, NFO id, year, type, romaji, kanji, lastfetch my @col = $_[ARG1] eq 'notfound' ? ($_[ARG0], 0, 0, 0, 0, '', '', -1) - : (split(/\|/, $_[ARG1]), int time); + : (split(/\|/, $_[ARG1], 7), int time); if($col[7] > 0) { for (@col) { @@ -269,6 +269,7 @@ sub updateanime { # aid, data|'notfound' $col[4] = $_ if lc($VNDB::ANITYPE->[$_][1]) eq lc($col[4]); } $col[4] = 0 if $col[4] !~ /^[0-9]+$/; + $col[2] = '' if $col[2] =~ /^0,/; } # try to UPDATE first diff --git a/lib/Multi/IRC.pm b/lib/Multi/IRC.pm index 984d5d5d..58789675 100644 --- a/lib/Multi/IRC.pm +++ b/lib/Multi/IRC.pm @@ -27,7 +27,7 @@ sub spawn { ); POE::Session->create( package_states => [ - $p => [qw| _start irc_001 irc_public irc_ctcp_action irc_msg vndbid shutdown |], + $p => [qw| _start irc_001 irc_public irc_ctcp_action irc_msg irccmd vndbid shutdown |], ], heap => { irc => $irc, o => { @@ -36,7 +36,8 @@ sub spawn { ircname => 'VNDB.org Multi', channel => '#vndb', @_ - } + }, + log => {}, } ); } @@ -83,9 +84,10 @@ sub irc_001 { sub irc_public { - if($_[ARG2] =~ /^!info/) { - $_[KERNEL]->post(circ => privmsg => $_[ARG1][0], - 'Hello, I am HMX-12 Multi v'.$VNDB::VERSION.' made by the great Yorhel! (Please ask Ayo for more info)'); + if($_[ARG2] =~ /^!/) { + (my $cmd = $_[ARG2]) =~ s/^!//; + my $nick = (split /!/, $_[ARG0])[0]; + $_[KERNEL]->call(irc => irccmd => $_[ARG1][0], $cmd, $nick, $nick.', '); } else { $_[KERNEL]->call(irc => vndbid => $_[ARG1][0], $_[ARG2]); } @@ -99,26 +101,39 @@ sub irc_ctcp_action { sub irc_msg { my $nick = ( split /!/, $_[ARG0] )[0]; + $_[KERNEL]->call(irc => irccmd => $nick => $_[ARG2]); +} - if(!$_[HEAP]{irc}->is_channel_operator($_[HEAP]{o}{channel}, $nick) - && !$_[HEAP]{irc}->is_channel_owner($_[HEAP]{o}{channel}, $nick) - && !$_[HEAP]{irc}->is_channel_admin($_[HEAP]{o}{channel}, $nick)) { - $_[KERNEL]->post(circ => privmsg => $nick, 'You are not my master'); - return; - } - my $m = $_[ARG2]; - if($m =~ /^say (.+)$/) { +sub irccmd { # dest, cmd, [nick], [prep] + my($dest, $cmd, $nick, $prep) = @_[ARG0..$#_]; + $nick ||= $_[ARG0]; + $prep ||= ''; + + if($cmd =~ /^info/) { + return $_[KERNEL]->post(circ => privmsg => $dest, + 'Hello, I am HMX-12 Multi v'.$VNDB::VERSION.' made by the great Yorhel!'); + } + + return $_[KERNEL]->post(circ => privmsg => $dest, + $prep.'You are not my master!') + if !$_[HEAP]{irc}->is_channel_operator($_[HEAP]{o}{channel}, $nick) + && !$_[HEAP]{irc}->is_channel_owner($_[HEAP]{o}{channel}, $nick) + && !$_[HEAP]{irc}->is_channel_admin($_[HEAP]{o}{channel}, $nick); + + if($cmd =~ /^say (.+)$/) { $_[KERNEL]->post(circ => privmsg => $_[HEAP]{o}{channel}, $1); - } elsif($m =~ /^me (.+)$/) { + } elsif($cmd =~ /^me (.+)$/) { $_[KERNEL]->post(circ => ctcp => $_[HEAP]{o}{channel}, "ACTION $1"); - } elsif($m =~ /^cmd (.+)$/) { + } elsif($cmd =~ /^cmd (.+)$/) { $_[KERNEL]->post(core => queue => $1); - } elsif($m =~ /^eval (.+)$/) { - $_[KERNEL]->post(circ => privmsg => $nick, 'eval: '.$_) + $_[KERNEL]->post(circ => privmsg => $dest => sprintf "%sExecuting command '%s'", $prep, $1); + } elsif($cmd =~ /^eval (.+)$/) { + $_[KERNEL]->post(circ => privmsg => $dest, $prep.'eval: '.$_) for (split /\r?\n/, eval($1)||$@); } else { - $_[KERNEL]->post(circ => privmsg => $nick, 'Unkown command'); } + $_[KERNEL]->post(circ => privmsg => $dest, $prep.'Unkown command'); + } # TODO: add command to view the current queue, and a method to send log messages } @@ -126,12 +141,19 @@ sub irc_msg { sub vndbid { # dest, msg my $m = $_[ARG1]; + + $_[HEAP]{log}{$_} < time-60 and delete $_[HEAP]{log}{$_} + for (keys %{$_[HEAP]{log}}); + my @id; push @id, [$1,$2,$3,$4] while $m =~ s/^(.*)([duvpr])([0-9]+)(.*)$/ $1 $4 /i; for (reverse @id) { - next if $$_[0] =~ /(\.org\/|[a-z])$/i || $$_[3] =~ /^[a-z]/i; + next if $$_[0] =~ /[a-z0-9%/]$/i || $$_[3] =~ /^[a-z]/i; my($t, $id, $ext) = (lc($$_[1]), $$_[2], $$_[3]); + next if $_[HEAP]{log}{$t.$id}; + $_[HEAP]{log}{$t.$id} = time; + if($t ne 'd') { my $s = $Multi::SQL->prepare( $t eq 'v' ? 'SELECT vr.title FROM vn_rev vr JOIN vn v ON v.latest = vr.id WHERE v.id = ?' : diff --git a/lib/Multi/Maintenance.pm b/lib/Multi/Maintenance.pm index 1f1a337e..d0aa4dbc 100644 --- a/lib/Multi/Maintenance.pm +++ b/lib/Multi/Maintenance.pm @@ -26,24 +26,18 @@ sub spawn { sub _start { $_[KERNEL]->alias_set('maintenance'); - $_[KERNEL]->call(core => register => qr/^maintenance((?: (?:all|vncache|ratings|prevcache|integrity|unkanime|logrotate))+)$/, 'cmd_maintenance'); + $_[KERNEL]->call(core => register => qr/^maintenance((?: (?:vncache|ratings|prevcache|integrity|unkanime|logrotate))+)$/, 'cmd_maintenance'); - # Perform all maintenance functions every day on 0:00 - $_[KERNEL]->post(core => addcron => '0 0 * * *', 'maintenance all'); - # rotate logs every 1st day of the month at 0:05 - $_[KERNEL]->post(core => addcron => '5 0 1 * *' => 'maintenance logrotate'); + # Perform some maintenance functions every day on 0:00 + $_[KERNEL]->post(core => addcron => '0 0 * * *', 'maintenance ratings integrity unkanime'); + # update caches and rotate logs every 1st day of the month at 0:05 + $_[KERNEL]->post(core => addcron => '5 0 1 * *' => 'maintenance vncache prevcache logrotate'); } sub cmd_maintenance { - local $_ = $_[ARG1]; - - $_[KERNEL]->yield('vncache') if /(?:vncache|all)/; - $_[KERNEL]->yield('ratings') if /(?:ratings|all)/; - $_[KERNEL]->yield('prevcache') if /(?:prevcache|all)/; - $_[KERNEL]->yield('integrity') if /(?:integrity|all)/; - $_[KERNEL]->yield('unkanime') if /(?:unkanime|all)/; - $_[KERNEL]->yield('logrotate') if /logrotate/; + $_[KERNEL]->yield($_) + for (split /\s+/, $_[ARG1]); $_[KERNEL]->post(core => finish => $_[ARG0]); } diff --git a/lib/Multi/RG.pm b/lib/Multi/RG.pm index b32fedba..ebb93013 100644 --- a/lib/Multi/RG.pm +++ b/lib/Multi/RG.pm @@ -130,7 +130,7 @@ sub relscomplete { # heap->nodes and heap->rels are now assumed to contain all n # insert all nodes, ordered by release date for (sort { $a->[2] <=> $b->[2] } values %{$_[HEAP]{nodes}}) { my $date = sprintf '%08d', $_->[2]; - $date =~ s#^([0-9]{4})([0-9]{2}).+#$1==0?'N/A':$1==9999?'TBA':(($2&&$2>0?($_[HEAP]{moy}[$2-1].' '):'').$1)#e; + $date =~ s#^([0-9]{4})([0-9]{2}).+#$1==0?'N/A':$1==9999?'TBA':(($2&&$2<13?($_[HEAP]{moy}[$2-1].' '):'').$1)#e; my $title = unidecode($_->[1]); $title = substr($title, 0, 27).'...' if length($title) > 30; diff --git a/lib/VNDB.pm b/lib/VNDB.pm index 2632a358..93f9e190 100644 --- a/lib/VNDB.pm +++ b/lib/VNDB.pm @@ -79,7 +79,8 @@ my %VNDBuris = ( # wildcards: * -> (.+), + -> ([0-9]+) v => { '/' => sub { shift->VNBrowse }, new => sub { shift->VNEdit(0); }, - '*' => sub { $_[2] =~ /^([a-z0]|all|search|cat)$/ ? shift->VNBrowse($_[1]) : shift->ResNotFound; }, + #search => sub { shift->VNSearch }, + '*' => sub { $_[2] =~ /^([a-z0]|all|search)$/ ? shift->VNBrowse($_[1]) : shift->ResNotFound; }, }, 'v+' => { '/' => sub { shift->VNPage(shift) }, @@ -128,10 +129,14 @@ my %VNDBuris = ( # wildcards: * -> (.+), + -> ([0-9]+) # provide redirects for old URIs my %OLDuris = ( faq => sub { shift->ResRedirect('/d6', 'perm') }, + notes => sub { shift->ResRedirect('/d8', 'perm') }, vn => { rss => sub { shift->ResRedirect('/hist/rss?t=v&e=1', 'perm') }, '*' => sub { shift->ResRedirect('/v/'.$_[1], 'perm') }, }, + v => { + cat => sub { }, + }, 'v+' => { votes => sub { shift->ResRedirect('/v'.(shift).'/stats', 'perm') }, }, diff --git a/lib/VNDB/Releases.pm b/lib/VNDB/Releases.pm index 6f642cba..abf3a786 100644 --- a/lib/VNDB/Releases.pm +++ b/lib/VNDB/Releases.pm @@ -87,7 +87,7 @@ sub REdit { my $released = !$frm->{released}[0] ? 0 : $frm->{released}[0] == 9999 ? 99999999 : - sprintf '%04d%02d%02d', $frm->{released}[0]||0, $frm->{released}[1]||0, $frm->{released}[2]||0; + sprintf '%04d%02d%02d', $frm->{released}[0], $frm->{released}[1]||99, $frm->{released}[2]||99; my $media = [ map { /_/ ? [ split /_/ ] : [ $_, 0 ] } split /,/, $frm->{media} ]; my $producers = [ map { /^([0-9]+)/ ? $1 : () } split /\|\|\|/, $frm->{producers} ]; my $new_vn = [ map { /^([0-9]+)/ ? $1 : () } split /\|\|\|/, $frm->{vn} ]; diff --git a/lib/VNDB/Util/DB.pm b/lib/VNDB/Util/DB.pm index e5eba14f..a2b4a035 100644 --- a/lib/VNDB/Util/DB.pm +++ b/lib/VNDB/Util/DB.pm @@ -538,7 +538,7 @@ sub DBDelVNList { # uid, @vid # uid = 0 to delete all #-----------------------------------------------------------------------------# -sub DBGetVN { # %options->{ id rev char search order results page what cati cate lang } +sub DBGetVN { # %options->{ id rev char search order results page what cati cate lang platform } my $s = shift; my %o = ( page => 1, @@ -573,14 +573,10 @@ sub DBGetVN { # %options->{ id rev char search order results page what cati cate JOIN vn iv ON iv.latest = ivc.vid WHERE cat IN(!L) GROUP BY iv.id)| => $o{cate} ) : (), - $o{lang} && @{$o{lang}} ? ( q| - v.id IN(SELECT irv.vid - FROM releases_rev irr - JOIN releases ir ON irr.id = ir.latest - JOIN releases_vn irv ON irv.rid = irr.id - WHERE irr.language IN(!L) - AND irr.type <> 2 - AND irr.released <= TO_CHAR('today'::timestamp, 'YYYYMMDD')::integer)| => $o{lang} ) : (), + $o{lang} && @{$o{lang}} ? ( + '('.join(' OR ', map "v.c_languages ILIKE '%%$_%%'", @{$o{lang}}).')' => 1 ) : (), + $o{platform} && @{$o{platform}} ? ( + '('.join(' OR ', map "v.c_platforms ILIKE '%%$_%%'", @{$o{platform}}).')' => 1 ) : (), ); if($o{search}) { @@ -613,7 +609,7 @@ sub DBGetVN { # %options->{ id rev char search order results page what cati cate 'JOIN users u ON u.id = c.requester' ) : (), ); - my $sel = 'v.id, v.locked, v.hidden, v.c_released, v.c_languages, v.c_votes, vr.title, vr.id AS cid, v.rgraph'; + my $sel = 'v.id, v.locked, v.hidden, v.c_released, v.c_languages, v.c_votes, v.c_platforms, vr.title, vr.id AS cid, v.rgraph'; $sel .= ', vr.alias, vr.image AS image, vr.img_nsfw, vr.length, vr.desc, vr.l_wp, vr.l_cisv, vr.l_vnn' if $o{what} =~ /extended/; $sel .= ', c.added, c.requester, c.comments, v.latest, u.username, c.prev, c.causedby' if $o{what} =~ /changes/; @@ -909,7 +905,7 @@ sub DBGetRelease { # %options->{ id vid results page rev } )}); } if($o{what} =~ /platforms/) { - ($_->{platform}=~s/\s+//||1)&&push(@{$r->[$r{$_->{rid}}]{platforms}}, $_->{platform}) for (@{$s->DBAll(q| + push(@{$r->[$r{$_->{rid}}]{platforms}}, $_->{platform}) for (@{$s->DBAll(q| SELECT rid, platform FROM releases_platforms WHERE rid IN(!l)|, diff --git a/lib/VNDB/VN.pm b/lib/VNDB/VN.pm index 4732e278..fd46672c 100644 --- a/lib/VNDB/VN.pm +++ b/lib/VNDB/VN.pm @@ -92,7 +92,7 @@ sub VNEdit { { name => 'anime', required => 0, default => '' }, { name => 'img_nsfw', required => 0 }, { name => 'categories', required => 0, default => '' }, - { name => 'relations', required => 0, default => 0 }, + { name => 'relations', required => 0, default => '' }, { name => 'comm', required => 0, default => '' }, ); $frm->{img_nsfw} = $frm->{img_nsfw} ? 1 : 0; @@ -155,8 +155,8 @@ sub VNEdit { $self->VNUpdReverse(\%old, \%new, $id, $cid); } # also regenerate relation graph if the title changes - elsif($frm->{title} ne $b4{title}) { - $self->RunCmd('relraph '.$id); + elsif(@$relations && $frm->{title} ne $b4{title}) { + $self->RunCmd('relgraph '.$id); } # check for new anime data @@ -230,25 +230,49 @@ sub VNBrowse { my $f = $self->FormCheck( { name => 's', required => 0, default => 'title', enum => [ qw|title released votes| ] }, { name => 'o', required => 0, default => 'a', enum => [ 'a','d' ] }, - { name => 'i', required => 0, default => '' }, - { name => 'e', required => 0, default => '' }, - { name => 'l', required => 0, default => '' }, - { name => 'q', required => 0}, + { name => 'q', required => 0, default => '' }, + { name => 'sq', required => 0, default => '' }, { name => 'p', required => 0, template => 'int', default => 1}, ); - my($r, $np) = $chr ne 'cat' || $f->{e} || $f->{i} || $f->{l} ? ($self->DBGetVN( - $chr =~ /^[a-z0]$/ ? ( - char => $chr ) : (), - $chr eq 'search' && $f->{q} ? ( - search => $f->{q} ) : (), - page => $f->{p}, - $chr eq 'cat' ? ( - cati => [ split /,/, $f->{i} ], - cate => [ split /,/, $f->{e} ], - lang => [ grep { $VNDB::LANG->{$_} } split /,/, $f->{l} ], - ) : (), + $f->{q} ||= $f->{sq}; + + my(@cati, @cate, @plat, @lang); + my $q = $f->{q}; + if($chr eq 'search') { + # VNDBID + return $self->ResRedirect('/'.$1, 'temp') + if $q =~ /^([vrpud][0-9]+)$/; + + if(!($q =~ s/^title://)) { + # categories + my %catl = map { + my $ic = $_; + map { $ic.$_ => $VNDB::CAT->{$ic}[1]{$_} } keys %{$VNDB::CAT->{$ic}[1]} + } keys %$VNDB::CAT; + + $q =~ s/-(?:$catl{$_}|c:$_)//ig && push @cate, $_ for keys %catl; + $q =~ s/(?:$catl{$_}|c:$_)//ig && push @cati, $_ for keys %catl; + + # platforms + $_ ne 'oth' && $q =~ s/(?:$VNDB::PLAT->{$_}|p:$_)//ig && push @plat, $_ for keys %$VNDB::PLAT; + + # languages + $q =~ s/($VNDB::LANG->{$_}|l:$_)//ig && push @lang, $_ for keys %$VNDB::LANG; + } + } + $q =~ s/ +$//; + $q =~ s/^ +//; + + my($r, $np) = $chr ne 'search' || $q || @lang || @plat || @cati || @cate ? ($self->DBGetVN( + $chr =~ /^[a-z0]$/ ? ( char => $chr ) : (), + $q ? ( search => $q ) : (), + @cati ? ( cati => \@cati ) : (), + @cate ? ( cate => \@cate ) : (), + @lang ? ( lang => \@lang ) : (), + @plat ? ( platform => \@plat ) : (), results => 50, + page => $f->{p}, order => {title => 'vr.title', released => 'v.c_released', votes => 'v.c_votes' }->{$f->{s}}.{a=>' ASC',d=>' DESC'}->{$f->{o}}, )) : ([], 0); @@ -261,12 +285,13 @@ sub VNBrowse { npage => $np, page => $f->{p}, chr => $chr, - $chr eq 'cat' ? ( - incl => $f->{i}, - excl => $f->{e}, + $chr eq 'search' ? ( + incl => \@cati, + excl => \@cate, cat => $self->DBCategoryCount, - lang => $self->DBLanguageCount, - slang => $f->{l}, + langc => $self->DBLanguageCount, + lang => \@lang, + plat => \@plat, ) : (), order => [ $f->{s}, $f->{o} ], }, @@ -336,4 +361,3 @@ sub VNUpdReverse { # old, new, id, cid 1; - diff --git a/lib/global.pl b/lib/global.pl index 890046b2..cf8d02db 100644 --- a/lib/global.pl +++ b/lib/global.pl @@ -3,7 +3,7 @@ package VNDB; our @DBLOGIN = ( 'dbi:Pg:dbname=vndb', 'vndb', 'passwd' ); our @SHMOPTS = ( -key => 'VNDB', -create => 'yes', -destroy => 'no', -mode => 0666); our $DEBUG = 1; -our $VERSION = '1.15'; +our $VERSION = '1.16'; our $PLAT = { win => 'Windows', @@ -13,9 +13,9 @@ our $PLAT = { gba => 'Game Boy Advance', nds => 'Nintendo DS', psp => 'Playstation Portable', - ps => 'Playstation', + ps1 => 'Playstation 1', ps2 => 'Playstation 2', - dc => 'Dreamcast', + drc => 'Dreamcast', sfc => 'Super Nintendo', wii => 'Nintendo Wii', oth => 'Other' @@ -54,7 +54,7 @@ our $CAT = { g => [ 'Gameplay', { aa => 'Visual Novel', # 0..1 ab => 'Adventure', # 0..1 - ac => 'Action', + ac => "Act\x{200B}ion", # Ugliest. Hack. Ever. rp => 'RPG', st => 'Strategy', si => 'Simulation', @@ -64,7 +64,7 @@ our $CAT = { br => 'Branching', # 0..1 } ], e => [ 'Elements', { - ac => 'Action', + ac => 'Action', co => 'Comedy', dr => 'Drama', fa => 'Fantasy', @@ -82,7 +82,7 @@ our $CAT = { } ], l => [ 'Place', { ea => 'Earth', - fa => 'Fantasy World', + fa => "Fant\x{200B}asy world", sp => 'Space', } ], s => [ 'Sexual content', { @@ -102,7 +102,6 @@ our $LSTAT = [ 'Wishlist', 'Blacklist', 'Playing', - 'Finished', 'Stalled', 'Dropped', 'Other', # XXX: hardcoded at 6 @@ -291,7 +290,7 @@ our $LANG = { 'fr' => q|French|, # 'fur' => q|Friulian|, # 'fy' => q|Frisian|, - 'ga' => q|Irish|, +# 'ga' => q|Irish|, # 'gaa' => q|Ga|, # 'gay' => q|Gayo|, # 'gba' => q|Gbaya|, |