X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=lib%2FNDWeb%2FInclude.pm;h=1cbcca9de3e09790280105192f16df6345ab1f2d;hb=85d8a494df2ada3f891653a950246046d23a981d;hp=b5acfbb43d8ca8f6e7d6eb58515b92f5e7f368b0;hpb=27f93c2b1d0e6c9c8a073b18ed508cf68ded6003;p=ndwebbie.git diff --git a/lib/NDWeb/Include.pm b/lib/NDWeb/Include.pm index b5acfbb..1cbcca9 100644 --- a/lib/NDWeb/Include.pm +++ b/lib/NDWeb/Include.pm @@ -21,7 +21,7 @@ package NDWeb::Include; use strict; use warnings; require Exporter; -use BBCode::Parser; +use Parse::BBCode; use CGI qw/:standard/; our @ISA = qw/Exporter/; @@ -40,21 +40,37 @@ sub comma_value ($) { return $v; } + +my $bbc = Parse::BBCode->new({ + tags => { + Parse::BBCode::HTML->defaults, + '' => sub { + my $e = ($_[2]); + $e =~ s/\r?\n|\r/
\n/g; + $e + }, + url => 'url:%s', + quote => 'block:
+
%{html}a wrote:
+
%s
', + code => 'block:
%{html}s
', + img => 'url:%s', + li => 'block:
  • %{parse}s
  • ', + size => '%s', + + }, + close_open_tags => 1, + }); + sub parseMarkup ($) { my ($text) = @_; - #$text =~ s{\n}{\n
    }g; - #$text =~ s{\[B\](.*?)\[/B\]}{$1}gi; - #$text =~ s{\[I\](.*?)\[/I\]}{$1}gi; - #$text =~ s{\[url\](.*?)\[/url\]}{$1}gi; - #$text =~ s{\[PRE\](.*?)\[/PRE\]}{
    $1
    }sgi; - #$text =~ s{\[PRE\](.*?)\[/PRE\]}{
    $1
    }sgi; - #$1 =~ s{
    }{}g; - - eval{ - my $tree = BBCode::Parser->DEFAULT->parse($text); - $text = $tree->toHTML; - }; + $text = $bbc->render($text); + if ($bbc->error){ + my $tree = $bbc->get_tree; + $text = $tree->raw_text; + $text = $bbc->render($text); + } $text =~ s/\x{3}\d\d?//g; #mirc color TODO: possibly match until \x{0F} and change to [color] block $text =~ s/[^\x{9}\x{A}\x{D}\x{20}-\x{D7FF}\x{E000}-\x{FFFD}\x{10000}-\x{10FFFF}]//g; return $text; @@ -64,10 +80,10 @@ sub intelquery { my ($columns,$where) = @_; return qq{ SELECT $columns, i.mission, i.tick AS landingtick,MIN(i.eta) AS eta, i.amount, i.ingal, u.username -FROM (fleets i NATURAL JOIN users u) - JOIN current_planet_stats t ON i.target = t.id - JOIN current_planet_stats o ON i.sender = o.id -WHERE $where +FROM (intel i NATURAL JOIN users u) + JOIN current_planet_stats t ON i.target = t.pid + JOIN current_planet_stats o ON i.sender = o.pid +WHERE $where GROUP BY i.tick,i.mission,t.x,t.y,t.z,o.x,o.y,o.z,i.amount,i.ingal,u.username,t.alliance,o.alliance,t.nick,o.nick,i.sender,i.target ORDER BY i.tick DESC, i.mission}; }