From 801230abf44ae90dce18f54852cb550435b35142 Mon Sep 17 00:00:00 2001 From: Yorhel Date: Sat, 14 Mar 2009 13:57:57 +0100 Subject: Handling of g# in Multi and bb2html, and IRC notify on tag creation --- lib/Multi/IRC.pm | 11 ++++++----- lib/VNDB/Func.pm | 2 +- lib/VNDB/Handler/Tags.pm | 8 ++++++-- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/lib/Multi/IRC.pm b/lib/Multi/IRC.pm index 224b35d4..ec230bd0 100644 --- a/lib/Multi/IRC.pm +++ b/lib/Multi/IRC.pm @@ -57,7 +57,7 @@ sub spawn { sub _start { $_[KERNEL]->alias_set('irc'); - $_[KERNEL]->call(core => register => qr/^ircnotify ([vrpt][0-9]+\.[0-9]+)$/, 'ircnotify'); + $_[KERNEL]->call(core => register => qr/^ircnotify ([vrptg][0-9]+\.[0-9]+)$/, 'ircnotify'); $_[HEAP]{irc}->plugin_add( Logger => POE::Component::IRC::Plugin::Logger->new( @@ -167,7 +167,7 @@ sub vndbid { # dest, msg, force for (keys %{$_[HEAP]{log}}); # Four possible options: - # 1. [tvpru]+ -> item/user/thread (nf) + # 1. [tvprug]+ -> item/user/thread/tag (nf) # 2. [vprt]+.+ -> revision/reply (ef) # 3. d+ -> documentation page (nf) # 4. d+.+ -> documentation page # section (sf) @@ -184,7 +184,7 @@ sub vndbid { # dest, msg, force for (split /[, ]/, $m) { next if length > 15 or m{[a-z]{3,6}://}i; # weed out URLs and too long things push @id, /^(?:.*[^\w]|)([dvprt])([1-9][0-9]*)\.([1-9][0-9]*)(?:[^\w].*|)$/ ? [ $1, $2, $3 ] # matches 2 and 4 - : /^(?:.*[^\w]|)([dvprtu])([1-9][0-9]*)(?:[^\w].*|)$/ ? [ $1, $2, 0 ] : (); # matches 1 and 3 + : /^(?:.*[^\w]|)([dvprtug])([1-9][0-9]*)(?:[^\w].*|)$/ ? [ $1, $2, 0 ] : (); # matches 1 and 3 } # loop through the matched IDs and search the database @@ -194,13 +194,14 @@ sub vndbid { # dest, msg, force next if $_[HEAP]{log}{$t.$id.'.'.$rev} && !$_[ARG2]; $_[HEAP]{log}{$t.$id.'.'.$rev} = time; - # option 1: item/user/thread - if($t =~ /[vprtu]/ && !$rev) { + # option 1: item/user/thread/tag + if($t =~ /[vprtug]/ && !$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 = ?' : + $t eq 'g' ? 'SELECT name AS title FROM tags WHERE id = ?' : 'SELECT rr.title FROM releases_rev rr JOIN releases r ON r.latest = rr.id WHERE r.id = ?' ); $s->execute($id); diff --git a/lib/VNDB/Func.pm b/lib/VNDB/Func.pm index 952f214c..7556d1a9 100644 --- a/lib/VNDB/Func.pm +++ b/lib/VNDB/Func.pm @@ -155,7 +155,7 @@ sub bb2html { next; } elsif(!grep(/url/, @open) && ( s{^(.*[^\w]|)([tdvpr][1-9][0-9]*)\.([1-9][0-9]*)([^\w].*|)$}{$e->($1).qq|$2.$3|.$e->($4)}e || - s{^(.*[^\w]|)([tduvpr][1-9][0-9]*)([^\w].*|)$}{$e->($1).qq|$2|.$e->($3)}e)) { + s{^(.*[^\w]|)([tdvprug][1-9][0-9]*)([^\w].*|)$}{$e->($1).qq|$2|.$e->($3)}e)) { $length += length $lit; last if $maxlength && $length > $maxlength; $result .= $_; diff --git a/lib/VNDB/Handler/Tags.pm b/lib/VNDB/Handler/Tags.pm index 8e4ada7a..2d25efc8 100644 --- a/lib/VNDB/Handler/Tags.pm +++ b/lib/VNDB/Handler/Tags.pm @@ -250,8 +250,12 @@ sub tagedit { if(!$frm->{_err}) { $frm->{meta} = $frm->{meta} ? 1 : 0; $frm->{parents} = [ split / /, $frm->{parents} ]; - $self->dbTagEdit($tag, %$frm, upddate => $frm->{state} == 2 && $t->{state} != 2) if $tag; - $tag = $self->dbTagAdd(%$frm) if !$tag; + if(!$tag) { + $tag = $self->dbTagAdd(%$frm); + $self->multiCmd("ircnotify g$tag"); + } else { + $self->dbTagEdit($tag, %$frm, upddate => $frm->{state} == 2 && $t->{state} != 2); + } $self->resRedirect("/g$tag", 'post'); } } -- cgit v1.2.3