diff options
author | yorhel <yorhel@1fe2e327-d9db-4752-bcf7-ef0cb4a1748b> | 2008-07-08 07:27:56 +0000 |
---|---|---|
committer | yorhel <yorhel@1fe2e327-d9db-4752-bcf7-ef0cb4a1748b> | 2008-07-08 07:27:56 +0000 |
commit | db47e11b580efa1938de892e6c08ba47ba2c6cc4 (patch) | |
tree | 3d2133912d93585e7bf36b41a6b1f85c40a0031a /lib | |
parent | 4c821b8138b0f9820cada6be7e051fe00434c54e (diff) |
Wrote an integrated messageboard, and fixed a few (very) small things along the way
git-svn-id: svn://vndb.org/vndb@54 1fe2e327-d9db-4752-bcf7-ef0cb4a1748b
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ChangeLog | 5 | ||||
-rw-r--r-- | lib/Multi/IRC.pm | 35 | ||||
-rw-r--r-- | lib/VNDB.pm | 19 | ||||
-rw-r--r-- | lib/VNDB/Discussions.pm | 185 | ||||
-rw-r--r-- | lib/VNDB/HomePages.pm | 10 | ||||
-rw-r--r-- | lib/VNDB/Users.pm | 1 | ||||
-rw-r--r-- | lib/VNDB/Util/DB.pm | 201 | ||||
-rw-r--r-- | lib/VNDB/VN.pm | 2 | ||||
-rw-r--r-- | lib/global.pl | 22 |
9 files changed, 459 insertions, 21 deletions
diff --git a/lib/ChangeLog b/lib/ChangeLog index 6fe6f160..0a39be9a 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -6,6 +6,11 @@ TODO: (preferably with the option to re-add them when unhiding) + Add a link for the hidden 'h' option at /hist +1.19 - ? + - Integrated discussion board + - Colored diff for alies field + - 'ttabs' for user entries + 1.18 - 2008-07-02 (r51) - Releases, producers and visual novel items can't be fully deleted anymore - Hidden vote and vnlist items from the 'recent' lists on VN stat pages for diff --git a/lib/Multi/IRC.pm b/lib/Multi/IRC.pm index 2c95ddc9..708f4b06 100644 --- a/lib/Multi/IRC.pm +++ b/lib/Multi/IRC.pm @@ -146,24 +146,26 @@ sub vndbid { # dest, msg for (keys %{$_[HEAP]{log}}); # Four possible options: - # 1. [vpru]+ -> item page + # 1. [tvpru]+ -> item page # 2. [vpr]+.+ -> item revision # 3. d+ -> documentation page # 4. d+.+ -> documentation page # section + # 5. t+.+ -> reply to a thread my @formats = ( - BOLD.RED.'['.NORMAL.BOLD.'%s%d' .RED.']'.NORMAL.' %s ' .RED.'@'.NORMAL.LIGHT_GREY.' %s/%1$s%2$d'.NORMAL, - BOLD.RED.'['.NORMAL.BOLD.'%s%d.%d'.RED.']'.NORMAL.' %s '.RED.'by'.NORMAL.' %s '.RED.'@'.NORMAL.LIGHT_GREY.' %s/%1$s%2$d.%3$d'.NORMAL, - BOLD.RED.'['.NORMAL.BOLD.'d%d' .RED.']'.NORMAL.' %s ' .RED.'@'.NORMAL.LIGHT_GREY.' %s/d%1$d'.NORMAL, - BOLD.RED.'['.NORMAL.BOLD.'d%d.%d' .RED.']'.NORMAL.' %s '.RED.'->'.NORMAL.' %s '.RED.'@'.NORMAL.LIGHT_GREY.' %s/d%1$d#%2$d'.NORMAL, + BOLD.RED.'['.NORMAL.BOLD.'%s%d' .RED.']' .NORMAL.' %s ' .RED.'@'.NORMAL.LIGHT_GREY.' %s/%1$s%2$d'.NORMAL, + BOLD.RED.'['.NORMAL.BOLD.'%s%d.%d'.RED.']'.NORMAL.RED.' Edit of' .NORMAL.' %s '.RED.'by'.NORMAL.' %s '.RED.'@'.NORMAL.LIGHT_GREY.' %s/%1$s%2$d.%3$d'.NORMAL, + BOLD.RED.'['.NORMAL.BOLD.'d%d' .RED.']' .NORMAL.' %s ' .RED.'@'.NORMAL.LIGHT_GREY.' %s/d%1$d'.NORMAL, + BOLD.RED.'['.NORMAL.BOLD.'d%d.%d' .RED.']' .NORMAL.' %s '.RED.'->'.NORMAL.' %s '.RED.'@'.NORMAL.LIGHT_GREY.' %s/d%1$d#%2$d'.NORMAL, + BOLD.RED.'['.NORMAL.BOLD.'t%d.%d' .RED.']'.NORMAL.RED.' Reply to'.NORMAL.' %s '.RED.'by'.NORMAL.' %s '.RED.'@'.NORMAL.LIGHT_GREY.' %s/t%1$d.%2$d'.NORMAL, ); # get a list of possible IDs (a la sub summary in defs.pl) my @id; # [ type, id, ref ] for (split /[, ]/, $m) { next if length > 15 or m{[a-z]{3,6}://}i; # weed out URLs and too long things - push @id, /^(?:.*[^\w]|)([dvpr])([0-9]+)\.([0-9]+)(?:[^\w].*|)$/ ? [ $1, $2, $3 ] # matches 2 and 4 - : /^(?:.*[^\w]|)([duvpr])([0-9]+)(?:[^\w].*|)$/ ? [ $1, $2, 0 ] : (); # matches 1 and 3 + push @id, /^(?:.*[^\w]|)([dvprt])([0-9]+)\.([0-9]+)(?:[^\w].*|)$/ ? [ $1, $2, $3 ] # matches 2, 4 and 5 + : /^(?:.*[^\w]|)([dvprtu])([0-9]+)(?:[^\w].*|)$/ ? [ $1, $2, 0 ] : (); # matches 1 and 3 } # loop through the matched IDs and search the database @@ -174,11 +176,12 @@ sub vndbid { # dest, msg $_[HEAP]{log}{$t.$id.'.'.$rev} = time; # option 1: item page - if($t =~ /[vpru]/ && !$rev) { + if($t =~ /[vprtu]/ && !$rev) { 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 = ?' : $t eq 'u' ? 'SELECT u.username AS title FROM users u WHERE u.id = ?' : $t eq 'p' ? 'SELECT pr.name AS title FROM producers_rev pr JOIN producers p ON p.latest = pr.id WHERE p.id = ?' : + $t eq 't' ? 'SELECT title FROM threads WHERE id = ?' : 'SELECT rr.title FROM releases_rev rr JOIN releases r ON r.latest = rr.id WHERE r.id = ?' ); $s->execute($id); @@ -231,6 +234,22 @@ sub vndbid { # dest, msg next if !$sub; $_[KERNEL]->post(circ => privmsg => $_[ARG0], sprintf $formats[3], $id, $rev, $title, $sub, $VNDB::VNDBopts{root_url}); + + # option 5: reply to a thread + } elsif($t eq 't' && $rev) { + my $s = $Multi::SQL->prepare(q| + SELECT t.title, u.username + FROM threads t + JOIN threads_posts tp ON tp.tid = t.id + JOIN users u ON u.id = tp.uid + WHERE t.id = ? + AND tp.num = ?|); + $s->execute($id, $rev); + my $r = $s->fetchrow_hashref; + $s->finish; + next if !$r || ref($r) ne 'HASH'; + $_[KERNEL]->post(circ => privmsg => $_[ARG0], sprintf $formats[4], + $id, $rev, $r->{title}, $r->{username}, $VNDB::VNDBopts{root_url}); } } } diff --git a/lib/VNDB.pm b/lib/VNDB.pm index 366ffa3e..91e8eb49 100644 --- a/lib/VNDB.pm +++ b/lib/VNDB.pm @@ -14,6 +14,7 @@ use VNDB::Util::Response; use VNDB::Util::DB; use VNDB::Util::Tools; use VNDB::Util::Auth; +use VNDB::Discussions; use VNDB::HomePages; use VNDB::Producers; use VNDB::Releases; @@ -90,6 +91,24 @@ my %VNDBuris = ( # wildcards: * -> (.+), + -> ([0-9]+) hist => {'*'=> sub { shift->History('p', shift, $_[1]) } }, }, 'p+.+' => sub { shift->PPage($_[0][0], $_[0][1]) }, + # discussions + t => { + '/' => sub { shift->TIndex }, + search => sub {}, # search? + '*' => { + '/' => sub { shift->TTag($_[1]) }, + new => sub { shift->TEdit(0, 0, $_[1]) }, + }, + }, + 't+' => { + '/' => sub { shift->TThread(shift) }, + reply => sub { shift->TEdit(shift) }, + '+' => sub { shift->TThread(shift, shift) }, + }, + 't+.+' => { + edit => sub { shift->TEdit($_[0][0], $_[0][1]) }, + '/' => sub { $_[0]->ResRedirect('/t'.$_[1][0].($_[1][1]>$_[0]->{postsperpage}?'/'.ceil($_[1][1]/$_[0]->{postsperpagee}):'').'#'.$_[1][1], 'perm') }, + }, # stuff (.xml extension to make sure they aren't counted as pageviews) xml => { 'producers.xml' => sub { shift->PXML }, diff --git a/lib/VNDB/Discussions.pm b/lib/VNDB/Discussions.pm new file mode 100644 index 00000000..233b41da --- /dev/null +++ b/lib/VNDB/Discussions.pm @@ -0,0 +1,185 @@ + +package VNDB::Discussions; + +use strict; +use warnings; +use Exporter 'import'; +use POSIX 'ceil'; + +use vars ('$VERSION', '@EXPORT'); +$VERSION = $VNDB::VERSION; +@EXPORT = qw| TThread TEdit TIndex TTag |; + + +sub TThread { + my $self = shift; + my $id = shift; + my $page = shift||1; + + my $t = $self->DBGetThreads(id => $id, what => 'tagtitles')->[0]; + return $self->ResNotFound if !$t || $t->{hidden} && !$self->AuthCan('boardmod'); + + my $p = $self->DBGetPosts(tid => $id, results => $self->{postsperpage}, page => $page); + return $self->ResNotFound if !$p->[0]; + + $self->ResAddTpl(tthread => { + t => $t, + ppp => $self->{postsperpage}, + page => $page, + p => $p, + }); +} + + +# tid num action +# 0 0 Start a new thread +# x 0 Reply to a thread +# x 1 Edit thread (and first post) +# x x Edit post +sub TEdit { + my $self = shift; + my $tid = shift||0; + my $num = shift||0; + my $tag = shift||''; + + my $t = $tid && $self->DBGetThreads(id => $tid, what => 'tags')->[0]; + return $self->ResNotFound if $tid && !$t; + + my $p = $num && $self->DBGetPosts(tid => $tid, num => $num)->[0]; + + my $frm = {}; + if($self->ReqMethod eq 'POST') { + $frm = $self->FormCheck( + { name => 'msg', required => 1, maxlength => 1024 }, + !$tid || $num == 1 ? ( + { name => 'title', required => 1, maxlength => 50 }, + { name => 'tags', required => 1, maxlength => 50 }, + ) : (), + $self->AuthCan('boardmod') ? ( + { name => 'hide', required => 0 }, + { name => 'lock', required => 0 } + ) : (), + ); + $frm->{msg} =~ s/[\r\s\n]$//g; + + my @tags = !$frm->{tags} || $frm->{_err} ? () : map { + $frm->{_err} = [ 'wrongtag' ] if + !/^([a-z]{1,2})([0-9]*)$/ || !$VNDB::DTAGS->{$1} + || $1 eq 'v' && (!$2 || !$self->DBGetVN(id => $2)->[0]) + #|| $1 eq 'r' && (!$2 || !$self->DBGetRelease(id => $2)->[0]) + || $1 eq 'p' && (!$2 || !$self->DBGetProducer(id => $2)->[0]) + || $1 eq 'u' && (!$2 || !$self->DBGetUser(id => $2)->[0]) + || $1 eq 'an' && !$self->AuthCan('boardmod'); + [ $1, $2||0 ] + } split / /, $frm->{tags}; + + if(!$frm->{_err}) { + my $otid = $tid; + if(!$tid || $num == 1) { + my @tags = + my %thread = ( + id => $tid, + title => $frm->{title}, + tags => \@tags, + hidden => $frm->{hide}, + locked => $frm->{lock}, + ); + $self->DBEditThread(%thread) if $tid; # edit thread + $tid = $self->DBAddThread(%thread) if !$tid; # create thread + } + + my %post = ( + tid => $tid, + num => !$otid ? 1 : $num, + msg => $frm->{msg}, + hidden => $num != 1 && $frm->{hide}, + ); + $self->DBEditPost(%post) if $num; # edit post + $num = $self->DBAddPost(%post) if !$num; # add post + + my $pagenum = ceil($num/$self->{postsperpage}); + $pagenum = $pagenum > 1 ? '/'.$pagenum : ''; + $self->ResRedirect('/t'.$tid.$pagenum.'#'.$num, 'POST'); + } + } + + if($p) { + $frm->{msg} ||= $p->{msg}; + $frm->{hide} = $p->{hidden}; + if($num == 1) { + $frm->{tags} ||= join ' ', sort map $_->[1]?$_->[0].$_->[1]:$_->[0], @{$t->{tags}}; + $frm->{title} ||= $t->{title}; + $frm->{lock} = $t->{locked}; + $frm->{hide} = $t->{hidden}; + } + } + $frm->{tags} ||= $tag; + + $self->ResAddTpl(tedit => { + t => $t, + p => $p, + tag => $tag, + form => $frm, + }); +} + + +sub TIndex { + my $self = shift; + + my %opts = ( + results => 6, + what => 'firstpost lastpost tags', + order => 'tp2.date DESC', + ); + + $self->ResAddTpl(tindex => { + ppp => $self->{postsperpage}, + map +($_, scalar $self->DBGetThreads(%opts, type => $_)), qw| an db v p u| + }); +} + + +sub TTag { + my $self = shift; + my $tag = shift; + my($type, $iid) = ($1, $2||0) if $tag =~ /^([a-z]{1,2})([0-9]*)$/; + + my $f = $self->FormCheck( + { name => 'p', required => 0, default => 1, template => 'int' }, + ); + + my $o = !$iid ? undef : + $type eq 'u' ? $self->DBGetUser(uid => $iid)->[0] : + $type eq 'v' ? $self->DBGetVN(id => $iid)->[0] : + #$type eq 'r' ? $self->DBGetRelease(id => $iid)->[0] : + $self->DBGetProducer(id => $iid)->[0]; + return $self->ResNotFound if $iid && !$o || !$VNDB::DTAGS->{$type}; + my $title = $o ? $o->{username} || $o->{romaji} || $o->{title} || $o->{name} : $VNDB::DTAGS->{$type}; + + my($t, $np) = $self->DBGetThreads( + type => $type, + iid => $iid, + results => 50, + page => $f->{p}, + what => 'firstpost lastpost tagtitles', + order => $tag eq 'an' ? 't.id DESC' : 'tp2.date DESC', + ); + + $self->ResAddTpl(ttag => { + page => $f->{p}, + npage => $np, + obj => $o, + type => $type, + iid => $iid, + title => $title, + tag => $tag, + t => $t, + ppp => $self->{postsperpage}, + }); +} + + + +1; + diff --git a/lib/VNDB/HomePages.pm b/lib/VNDB/HomePages.pm index 5c1ef3ef..7a70797a 100644 --- a/lib/VNDB/HomePages.pm +++ b/lib/VNDB/HomePages.pm @@ -13,14 +13,10 @@ $VERSION = $VNDB::VERSION; sub HomePage { my $self = shift; - # recent edits - # recently added visual novels - # recently added producers - # random visual novels - # recent votes - # popular visual novels - + my $an = $self->DBGetThreads(type => 'an', order => 't.id DESC', results => 1)->[0]; $self->ResAddTpl(home => { + an => $an, + anpost => $self->DBGetPosts(tid => $an->{id}, num => 1)->[0], recentedits => scalar $self->DBGetHist( results => 10, what => 'iid ititle'), recentvns => scalar $self->DBGetHist( results => 10, what => 'iid ititle', edits => 0, type => 'v'), recentps => scalar $self->DBGetHist( results => 10, what => 'iid ititle', edits => 0, type => 'p'), diff --git a/lib/VNDB/Users.pm b/lib/VNDB/Users.pm index 4262f59d..4b4e65ef 100644 --- a/lib/VNDB/Users.pm +++ b/lib/VNDB/Users.pm @@ -173,6 +173,7 @@ sub UsrEdit { done => $d, adm => $adm, user => $user, + u => $u }); } diff --git a/lib/VNDB/Util/DB.pm b/lib/VNDB/Util/DB.pm index a0c851bb..8391f58f 100644 --- a/lib/VNDB/Util/DB.pm +++ b/lib/VNDB/Util/DB.pm @@ -19,6 +19,7 @@ $VERSION = $VNDB::VERSION; DBGetVN DBAddVN DBEditVN DBHideVN DBUndefRG DBVNCache DBGetRelease DBAddRelease DBEditRelease DBHideRelease DBGetProducer DBGetProducerVN DBAddProducer DBEditProducer DBHideProducer + DBGetThreads DBGetPosts DBAddPost DBEditPost DBEditThread DBAddThread DBExec DBRow DBAll DBLastId |; @@ -1130,6 +1131,206 @@ sub DBHideProducer { # id, hidden + +#-----------------------------------------------------------------------------# +# D I S C U S S I O N S # +#-----------------------------------------------------------------------------# + + +sub DBGetThreads { # %options->{ id type iid results page what } + my($s, %o) = @_; + + $o{results} ||= 50; + $o{page} ||= 1; + $o{what} ||= ''; + $o{order} ||= 't.id DESC'; + + my %where = ( + $o{id} ? ( + 't.id = %d' => $o{id} ) : (), + !$o{id} ? ( + 't.hidden = 0' => 1 ) : (), + $o{type} && !$o{iid} ? ( + 't.id IN(SELECT tid FROM threads_tags WHERE type = !s)' => $o{type} ) : (), + $o{type} && $o{iid} ? ( + 'tt.type = !s' => $o{type}, 'tt.iid = %d' => $o{iid} ) : (), + ); + my $where = scalar keys %where ? 'WHERE !W' : ''; + + my $select = 't.id, t.title, t.count, t.locked, t.hidden'; + $select .= ', tp.uid, tp.date, u.username' if $o{what} =~ /firstpost/; + $select .= ', tp2.uid AS luid, tp2.date AS ldate, u2.username AS lusername' if $o{what} =~ /lastpost/; + + my @join; + push @join, 'JOIN threads_posts tp ON tp.tid = t.id AND tp.num = 1' if $o{what} =~ /firstpost/; + push @join, 'JOIN users u ON u.id = tp.uid' if $o{what} =~ /firstpost/; + push @join, 'JOIN threads_posts tp2 ON tp2.tid = t.id AND tp2.num = t.count' if $o{what} =~ /lastpost/; + push @join, 'JOIN users u2 ON u2.id = tp2.uid' if $o{what} =~ /lastpost/; + push @join, 'JOIN threads_tags tt ON tt.tid = t.id' if $o{type} && $o{iid}; + + my $r = $s->DBAll(qq| + SELECT $select + FROM threads t + @join + $where + ORDER BY %s + LIMIT %d OFFSET %d|, + $where ? \%where : (), + $o{order}, + $o{results}+(wantarray?1:0), $o{results}*($o{page}-1) + ); + + if($o{what} =~ /(tags|tagtitles)/ && $#$r >= 0) { + my %r = map { + $r->[$_]{tags} = []; + ($r->[$_]{id}, $_) + } 0..$#$r; + + if($o{what} =~ /tags/) { + ($_->{type}=~s/ +//||1) && push(@{$r->[$r{$_->{tid}}]{tags}}, [ $_->{type}, $_->{iid} ]) for (@{$s->DBAll(q| + SELECT tid, type, iid + FROM threads_tags + WHERE tid IN(!l)|, + [ keys %r ] + )}); + } + if($o{what} =~ /tagtitles/) { + ($_->{type}=~s/ +//||1) && push(@{$r->[$r{$_->{tid}}]{tags}}, [ $_->{type}, $_->{iid}, $_->{title} ]) for (@{$s->DBAll(q| + SELECT tt.tid, tt.type, tt.iid, COALESCE(u.username, vr.title, pr.name) AS title + FROM threads_tags tt + LEFT JOIN vn v ON tt.type = 'v' AND v.id = tt.iid + LEFT JOIN vn_rev vr ON vr.id = v.latest + LEFT JOIN producers p ON tt.type = 'p' AND p.id = tt.iid + LEFT JOIN producers_rev pr ON pr.id = p.latest + LEFT JOIN users u ON tt.type = 'u' AND u.id = tt.iid + WHERE tt.tid IN(!l)|, + [ keys %r ] + )}); + } + } + + return $r if !wantarray; + return ($r, 0) if $#$r < $o{results}; + pop @$r; + return ($r, 1); +} + + +sub DBGetPosts { # %options->{ tid num page results } + my($s, %o) = @_; + + $o{results} ||= 50; + $o{page} ||= 1; + + my %where = ( + 'tp.tid = %d' => $o{tid}, + $o{num} ? ( + 'tp.num = %d' => $o{num} ) : (), + ); + + my $r = $s->DBAll(q| + SELECT tp.num, tp.date, tp.edited, tp.msg, tp.hidden, tp.uid, u.username + FROM threads_posts tp + JOIN users u ON u.id = tp.uid + WHERE !W + ORDER BY tp.num ASC + LIMIT %d OFFSET %d|, + \%where, + $o{results}, $o{results}*($o{page}-1) + ); + + return $r if !wantarray; +} + + +sub DBAddPost { # %options->{ tid uid msg num } + my($s, %o) = @_; + + $o{num} ||= $s->DBRow('SELECT num FROM threads_posts WHERE tid = %d ORDER BY num DESC LIMIT 1', $o{tid})->{num}+1; + $o{uid} ||= $s->AuthInfo->{id}; + + $s->DBExec(q| + INSERT INTO threads_posts (tid, num, uid, msg) + VALUES(%d, %d, %d, !s)|, + @o{qw| tid num uid msg |} + ); + $s->DBExec(q| + UPDATE threads + SET count = count+1 + WHERE id = %d|, + $o{tid}); + + return $o{num}; +} + + +sub DBEditPost { # %options->{ tid num msg hidden } + my($s, %o) = @_; + + my %set = ( + 'msg = !s' => $o{msg}, + 'edited = %d' => time, + 'hidden = %d' => $o{hidden}?1:0, + ); + + $s->DBExec(q| + UPDATE threads_posts + SET !H + WHERE tid = %d + AND num = %d|, + \%set, $o{tid}, $o{num} + ); +} + + +sub DBEditThread { # %options->{ id title locked hidden tags } + my($s, %o) = @_; + + my %set = ( + 'title = !s' => $o{title}, + 'locked = %d' => $o{locked}?1:0, + 'hidden = %d' => $o{hidden}?1:0, + ); + + $s->DBExec(q| + UPDATE threads + SET !H + WHERE id = %d|, + \%set, $o{id}); + + if($o{tags}) { + $s->DBExec('DELETE FROM threads_tags WHERE tid = %d', $o{id}); + $s->DBExec(q| + INSERT INTO threads_tags (tid, type, iid) + VALUES (%d, !s, %d)|, + $o{id}, $_->[0], $_->[1]||0 + ) for (@{$o{tags}}); + } +} + + +sub DBAddThread { # %options->{ title tags } + my($s, %o) = @_; + + my $id = $s->DBRow(q| + INSERT INTO threads (title) + VALUES (!s) + RETURNING id|, $o{title} + )->{id}; + + $s->DBExec(q| + INSERT INTO threads_tags (tid, type, iid) + VALUES (%d, !s, %d)|, + $id, $_->[0], $_->[1] + ) for (@{$o{tags}}); + + return $id; +} + + + + + #-----------------------------------------------------------------------------# # U T I L I T I E S # #-----------------------------------------------------------------------------# diff --git a/lib/VNDB/VN.pm b/lib/VNDB/VN.pm index 2b0e6efc..365204d4 100644 --- a/lib/VNDB/VN.pm +++ b/lib/VNDB/VN.pm @@ -226,7 +226,7 @@ sub VNBrowse { if($chr eq 'search') { # VNDBID return $self->ResRedirect('/'.$1.$2.(!$3 ? '' : $1 eq 'd' ? '#'.$3 : '.'.$3), 'temp') - if $q =~ /^([vrpud])([0-9]+)(?:\.([0-9]+))?$/; + if $q =~ /^([vrptud])([0-9]+)(?:\.([0-9]+))?$/; if(!($q =~ s/^title://)) { # categories diff --git a/lib/global.pl b/lib/global.pl index 514640f9..a4c0d9ec 100644 --- a/lib/global.pl +++ b/lib/global.pl @@ -31,12 +31,13 @@ our %VNDBopts = ( }, ranks => [ [ [ qw| visitor loser user mod admin | ], [] ], - {map{$_,1}qw| hist |}, # 0 - visitor (not logged in) - {map{$_,1}qw| hist |}, # 1 - loser - {map{$_,1}qw| hist edit |}, # 2 - user - {map{$_,1}qw| hist edit mod lock |}, # 3 - mod - {map{$_,1}qw| hist edit mod lock del userlist useredit |}, # 4 - admin + {map{$_,1}qw| hist |}, # 0 - visitor (not logged in) + {map{$_,1}qw| hist |}, # 1 - loser + {map{$_,1}qw| hist board edit |}, # 2 - user + {map{$_,1}qw| hist board boardmod edit mod lock |}, # 3 - mod + {map{$_,1}qw| hist board boardmod edit mod lock del userlist useredit |}, # 4 - admin ], + postsperpage => 25, imgpath => '/www/vndb/static/cv', mappath => '/www/vndb/data/rg', docpath => '/www/vndb/data/docs', @@ -44,6 +45,17 @@ our %VNDBopts = ( $VNDBopts{ranks}[0][1] = { (map{$_,1} map { keys %{$VNDBopts{ranks}[$_]} } 1..5) }; +# I wonder why I even made this hash, almost everything is still hardcoded anyway... +our $DTAGS = { + an => 'Announcements', # 0 - usage restricted to boardmods + db => 'VNDB Discussions', # 0 + v => 'Visual novels', # vid + #r => 'Releases', # rid + p => 'Producers', # pid + u => 'Users', # uid +}; + + our $PLAT = { win => 'Windows', lin => 'Linux', |