summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/VNDB/BBCode.pm25
-rw-r--r--lib/VNDB/Func.pm2
-rw-r--r--lib/VNDB/Handler/Chars.pm2
-rw-r--r--lib/VNDB/Handler/Producers.pm2
-rw-r--r--lib/VNDB/Handler/Releases.pm2
-rw-r--r--lib/VNDB/Handler/Staff.pm2
-rw-r--r--lib/VNDB/Handler/VNPage.pm7
7 files changed, 31 insertions, 11 deletions
diff --git a/lib/VNDB/BBCode.pm b/lib/VNDB/BBCode.pm
index ffa14d98..95a90d16 100644
--- a/lib/VNDB/BBCode.pm
+++ b/lib/VNDB/BBCode.pm
@@ -5,7 +5,7 @@ use warnings;
use Exporter 'import';
use TUWF::XML 'xml_escape';
-our @EXPORT = qw/bb2html/;
+our @EXPORT = qw/bb2html bb2text/;
# Supported BBCode:
# [spoiler] .. [/spoiler]
@@ -226,4 +226,27 @@ sub bb2html {
$ret;
}
+
+# Convert bbcode into plain text, stripping all tags and spoilers. [url] tags
+# only display the title.
+sub bb2text {
+ my $input = shift;
+
+ my $inspoil = 0;
+ my $ret = '';
+ parse $input, sub {
+ my($raw, $tag, @arg) = @_;
+ if($tag eq 'spoiler_start') {
+ $inspoil = 1;
+ } elsif($tag eq 'spoiler_end') {
+ $inspoil = 0;
+ } else {
+ $ret .= $raw if !$inspoil && $tag !~ /_(start|end)$/;
+ }
+ 1;
+ };
+ $ret;
+}
+
+
1;
diff --git a/lib/VNDB/Func.pm b/lib/VNDB/Func.pm
index e46df5e2..7aa3d5c1 100644
--- a/lib/VNDB/Func.pm
+++ b/lib/VNDB/Func.pm
@@ -9,7 +9,7 @@ use POSIX 'strftime', 'ceil', 'floor';
use JSON::XS;
use VNDBUtil;
use VNDB::BBCode;
-our @EXPORT = (@VNDBUtil::EXPORT, 'bb2html', qw|
+our @EXPORT = (@VNDBUtil::EXPORT, 'bb2html', 'bb2text', qw|
clearfloat cssicon tagscore mt minage fil_parse fil_serialize parenttags
childtags charspoil imgpath imgurl
fmtvote fmtmedia fmtvnlen fmtage fmtdatestr fmtdate fmtuser fmtrating fmtspoil
diff --git a/lib/VNDB/Handler/Chars.pm b/lib/VNDB/Handler/Chars.pm
index d412aae9..9824a7d9 100644
--- a/lib/VNDB/Handler/Chars.pm
+++ b/lib/VNDB/Handler/Chars.pm
@@ -31,7 +31,7 @@ sub page {
my $metadata = {
'og:title' => $r->{name},
- 'og:description' => $r->{desc},
+ 'og:description' => bb2text $r->{desc},
'og:image' => $r->{image} && imgurl(ch => $r->{image}),
};
diff --git a/lib/VNDB/Handler/Producers.pm b/lib/VNDB/Handler/Producers.pm
index 42c4e7f0..a4070467 100644
--- a/lib/VNDB/Handler/Producers.pm
+++ b/lib/VNDB/Handler/Producers.pm
@@ -52,7 +52,7 @@ sub page {
my $metadata = {
'og:title' => $p->{name},
- 'og:description' => $p->{desc},
+ 'og:description' => bb2text $p->{desc},
};
$self->htmlHeader(title => $p->{name}, noindex => $rev, metadata => $metadata);
diff --git a/lib/VNDB/Handler/Releases.pm b/lib/VNDB/Handler/Releases.pm
index 19fa0678..3181566e 100644
--- a/lib/VNDB/Handler/Releases.pm
+++ b/lib/VNDB/Handler/Releases.pm
@@ -30,7 +30,7 @@ sub page {
my $metadata = {
'og:title' => $r->{title},
- 'og:description' => $r->{notes},
+ 'og:description' => bb2text $r->{notes},
};
$self->htmlHeader(title => $r->{title}, noindex => $rev, metadata => $metadata);
diff --git a/lib/VNDB/Handler/Staff.pm b/lib/VNDB/Handler/Staff.pm
index ca2f9842..4d583b68 100644
--- a/lib/VNDB/Handler/Staff.pm
+++ b/lib/VNDB/Handler/Staff.pm
@@ -29,7 +29,7 @@ sub page {
my $metadata = {
'og:title' => $s->{name},
- 'og:description' => $s->{desc},
+ 'og:description' => bb2text $s->{desc},
};
$self->htmlHeader(title => $s->{name}, noindex => $rev, metadata => $metadata);
diff --git a/lib/VNDB/Handler/VNPage.pm b/lib/VNDB/Handler/VNPage.pm
index 2ebb42e6..0d22f256 100644
--- a/lib/VNDB/Handler/VNPage.pm
+++ b/lib/VNDB/Handler/VNPage.pm
@@ -344,7 +344,7 @@ sub page {
my $metadata = {
'og:title' => $v->{title},
- 'og:description' => $v->{desc},
+ 'og:description' => bb2text $v->{desc},
};
if($v->{image} && !$v->{img_nsfw}) {
@@ -881,10 +881,7 @@ sub _release_icons {
}
# Notes column
- # TODO: The notes text should to through a bb2html() to strip the tags. But
- # showing HTML inside a 'title' attribute won't work, and bb2html() doesn't
- # have a plain text output option.
- _release_icon 'notes', $rel->{notes}, 'notes' if $rel->{notes};
+ _release_icon 'notes', bb2text($rel->{notes}), 'notes' if $rel->{notes};
}