From e4b912bc68cebff9c42ef17e7356e9cf5a218272 Mon Sep 17 00:00:00 2001 From: Yorhel Date: Mon, 9 Nov 2009 17:06:45 +0100 Subject: bb2html: Added [code] tag and fixed a minor bug The previous version also had a problem with closing tags when a $maxlength was defined. With $maxlength, not all tags actually open a tag in HTML, after all. --- lib/VNDB/Func.pm | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'lib/VNDB/Func.pm') diff --git a/lib/VNDB/Func.pm b/lib/VNDB/Func.pm index ad38215e..49df0121 100644 --- a/lib/VNDB/Func.pm +++ b/lib/VNDB/Func.pm @@ -22,6 +22,7 @@ sub shorten { # [raw] .. [/raw] # [spoiler] .. [/spoiler] # [quote] .. [/quote] +# [code] .. [/code] # v+, v+.+ # http://../ sub bb2html { @@ -51,7 +52,7 @@ sub bb2html { $rmnewline-- && $_ eq "\n" && next if $rmnewline; my $lit = $_; - if($open[$#open] ne 'raw') { + if($open[$#open] ne 'raw' && $open[$#open] ne 'code') { if (lc$_ eq '[raw]') { push @open, 'raw'; next } elsif (lc$_ eq '[spoiler]') { push @open, 'spoiler'; $result .= ''; next } elsif (lc$_ eq '[quote]') { @@ -59,6 +60,11 @@ sub bb2html { $result .= '
' if !$maxlength; $rmnewline = 1; next + } elsif (lc$_ eq '[code]') { + push @open, 'code'; + $result .= '
' if !$maxlength;
+        $rmnewline = 1;
+        next
       } elsif (lc$_ eq '[/spoiler]') {
         if($open[$#open] eq 'spoiler') {
           $result .= '';
@@ -97,8 +103,12 @@ sub bb2html {
         $result .= $_;
         next;
       }
-    } elsif(lc$_ eq '[/raw]') {
-      pop @open if $open[$#open] eq 'raw';
+    } elsif($open[$#open] eq 'raw' && lc$_ eq '[/raw]') {
+      pop @open;
+      next;
+    } elsif($open[$#open] eq 'code' && lc$_ eq '[/code]') {
+      $result .= '
' if !$maxlength; + pop @open; next; } @@ -108,8 +118,11 @@ sub bb2html { $result .= $e->($_); } - $result .= $_ eq 'url' ? '' : $_ eq 'quote' ? '
' : '' - while((local $_ = pop @open) ne 'first'); + # close open tags + while((local $_ = pop @open) ne 'first') { + $result .= $_ eq 'url' ? '' : $_ eq 'spoiler' ? '' : ''; + $result .= $_ eq 'quote' ? '' : $_ eq 'code' ? '' : '' if !$maxlength; + } $result .= '...' if $maxlength && $length > $maxlength; return $result; -- cgit v1.2.3 From 0a4f97f0186d6941a4cab2e3bd05201f1fed1441 Mon Sep 17 00:00:00 2001 From: Yorhel Date: Sat, 14 Nov 2009 10:50:22 +0100 Subject: SQL/L10N: Allow NULL for releases_rev.minage and make the values translatable --- lib/VNDB/Func.pm | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'lib/VNDB/Func.pm') diff --git a/lib/VNDB/Func.pm b/lib/VNDB/Func.pm index 49df0121..1801e3b8 100644 --- a/lib/VNDB/Func.pm +++ b/lib/VNDB/Func.pm @@ -6,7 +6,7 @@ use warnings; use YAWF ':html'; use Exporter 'import'; use POSIX 'strftime', 'ceil', 'floor'; -our @EXPORT = qw| shorten bb2html gtintype liststat clearfloat cssicon tagscore mt |; +our @EXPORT = qw| shorten bb2html gtintype liststat clearfloat cssicon tagscore mt minage |; # I would've done this as a #define if this was C... @@ -221,5 +221,20 @@ sub mt { } +sub minage { + my($a, $ex) = @_; + my $str = !defined($a) ? mt '_minage_null' : !$a ? mt '_minage_all' : mt '_minage_age', $a; + $ex = !defined($a) ? '' : { + 0 => 'CERO A', + 12 => 'CERO B', + 15 => 'CERO C', + 17 => 'CERO D', + 18 => 'CERO Z', + }->{$a} if $ex; + return $str if !$ex; + return $str.' '.mt('_minage_example', $ex); +} + + 1; -- cgit v1.2.3