summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/VNDB/Handler/Chars.pm8
-rw-r--r--lib/VNDB/Handler/Misc.pm16
-rw-r--r--lib/VNDB/Handler/Producers.pm7
-rw-r--r--lib/VNDB/Handler/Releases.pm7
-rw-r--r--lib/VNDB/Handler/Staff.pm7
-rw-r--r--lib/VNDB/Handler/VNPage.pm13
-rw-r--r--lib/VNDB/Util/LayoutHTML.pm22
7 files changed, 70 insertions, 10 deletions
diff --git a/lib/VNDB/Handler/Chars.pm b/lib/VNDB/Handler/Chars.pm
index 392bf446..5caf677e 100644
--- a/lib/VNDB/Handler/Chars.pm
+++ b/lib/VNDB/Handler/Chars.pm
@@ -28,7 +28,13 @@ sub page {
)->[0];
return $self->resNotFound if !$r->{id};
- $self->htmlHeader(title => $r->{name}, noindex => $rev);
+ my $metadata = {
+ 'og:title' => $r->{name},
+ 'og:description' => $r->{desc},
+ 'og:image' => $r->{image} && imgurl(ch => $r->{image}),
+ };
+
+ $self->htmlHeader(title => $r->{name}, noindex => $rev, metadata => $metadata);
$self->htmlMainTabs(c => $r);
return if $self->htmlHiddenMessage('c', $r);
diff --git a/lib/VNDB/Handler/Misc.pm b/lib/VNDB/Handler/Misc.pm
index 9cdbf4e2..6bda8091 100644
--- a/lib/VNDB/Handler/Misc.pm
+++ b/lib/VNDB/Handler/Misc.pm
@@ -35,12 +35,22 @@ TUWF::register(
sub homepage {
my $self = shift;
- $self->htmlHeader(title => 'The Visual Novel Database', feeds => [ keys %{$self->{atom_feeds}} ]);
+
+ my $title = 'The Visual Novel Database';
+ my $desc = 'VNDB.org strives to be a comprehensive database for information about visual novels.';
+
+ my $metadata = {
+ 'og:type' => 'website',
+ 'og:title' => $title,
+ 'og:description' => $desc,
+ };
+
+ $self->htmlHeader(title => $title, feeds => [ keys %{$self->{atom_feeds}} ], metadata => $metadata);
div class => 'mainbox';
- h1 'The Visual Novel Database';
+ h1 $title;
p class => 'description';
- txt 'VNDB.org strives to be a comprehensive database for information about visual novels.';
+ txt $desc;
br;
txt 'This website is built as a wiki, meaning that anyone can freely add'
.' and contribute information to the database, allowing us to create the'
diff --git a/lib/VNDB/Handler/Producers.pm b/lib/VNDB/Handler/Producers.pm
index bde7a07d..42c4e7f0 100644
--- a/lib/VNDB/Handler/Producers.pm
+++ b/lib/VNDB/Handler/Producers.pm
@@ -50,7 +50,12 @@ sub page {
)->[0];
return $self->resNotFound if !$p->{id};
- $self->htmlHeader(title => $p->{name}, noindex => $rev);
+ my $metadata = {
+ 'og:title' => $p->{name},
+ 'og:description' => $p->{desc},
+ };
+
+ $self->htmlHeader(title => $p->{name}, noindex => $rev, metadata => $metadata);
$self->htmlMainTabs(p => $p);
return if $self->htmlHiddenMessage('p', $p);
diff --git a/lib/VNDB/Handler/Releases.pm b/lib/VNDB/Handler/Releases.pm
index 31026efe..19fa0678 100644
--- a/lib/VNDB/Handler/Releases.pm
+++ b/lib/VNDB/Handler/Releases.pm
@@ -28,7 +28,12 @@ sub page {
)->[0];
return $self->resNotFound if !$r->{id};
- $self->htmlHeader(title => $r->{title}, noindex => $rev);
+ my $metadata = {
+ 'og:title' => $r->{title},
+ 'og:description' => $r->{notes},
+ };
+
+ $self->htmlHeader(title => $r->{title}, noindex => $rev, metadata => $metadata);
$self->htmlMainTabs('r', $r);
return if $self->htmlHiddenMessage('r', $r);
diff --git a/lib/VNDB/Handler/Staff.pm b/lib/VNDB/Handler/Staff.pm
index 378bbd91..ca2f9842 100644
--- a/lib/VNDB/Handler/Staff.pm
+++ b/lib/VNDB/Handler/Staff.pm
@@ -27,7 +27,12 @@ sub page {
)->[0];
return $self->resNotFound if !$s->{id};
- $self->htmlHeader(title => $s->{name}, noindex => $rev);
+ my $metadata = {
+ 'og:title' => $s->{name},
+ 'og:description' => $s->{desc},
+ };
+
+ $self->htmlHeader(title => $s->{name}, noindex => $rev, metadata => $metadata);
$self->htmlMainTabs('s', $s) if $id;
return if $self->htmlHiddenMessage('s', $s);
diff --git a/lib/VNDB/Handler/VNPage.pm b/lib/VNDB/Handler/VNPage.pm
index 5f8f8f3a..4cdcb166 100644
--- a/lib/VNDB/Handler/VNPage.pm
+++ b/lib/VNDB/Handler/VNPage.pm
@@ -341,7 +341,18 @@ sub page {
my $r = $self->dbReleaseGet(vid => $vid, what => 'producers platforms', results => 200);
- $self->htmlHeader(title => $v->{title}, noindex => $rev);
+ my $metadata = {
+ 'og:title' => $v->{title},
+ 'og:description' => $v->{desc},
+ };
+
+ if($v->{image} && !$v->{img_nsfw}) {
+ $metadata->{'og:image'} = imgurl(cv => $v->{image});
+ } elsif(my ($ss) = grep !$_->{nsfw}, @{$v->{screenshots}}) {
+ $metadata->{'og:image'} = imgurl(st => $ss->{id});
+ }
+
+ $self->htmlHeader(title => $v->{title}, noindex => $rev, metadata => $metadata);
$self->htmlMainTabs('v', $v);
return if $self->htmlHiddenMessage('v', $v);
diff --git a/lib/VNDB/Util/LayoutHTML.pm b/lib/VNDB/Util/LayoutHTML.pm
index 46afea5e..a970546c 100644
--- a/lib/VNDB/Util/LayoutHTML.pm
+++ b/lib/VNDB/Util/LayoutHTML.pm
@@ -11,7 +11,7 @@ use VNDB::Func;
our @EXPORT = qw|htmlHeader htmlFooter|;
-sub htmlHeader { # %options->{ title, noindex, search, feeds, svg }
+sub htmlHeader { # %options->{ title, noindex, search, feeds, svg, metadata }
my($self, %o) = @_;
my $skin = $self->reqGet('skin') || $self->authPref('skin') || $self->{skin_default};
$skin = $self->{skin_default} if !$self->{skins}{$skin} || !-d "$VNDB::ROOT/static/s/$skin";
@@ -19,7 +19,7 @@ sub htmlHeader { # %options->{ title, noindex, search, feeds, svg }
# heading
lit '<!DOCTYPE HTML>';
tag 'html', lang => 'en';
- head;
+ head prefix => 'og: http://ogp.me/ns#';
title $o{title};
Link rel => 'shortcut icon', href => '/favicon.ico', type => 'image/x-icon';
Link rel => 'stylesheet', href => $self->{url_static}.'/s/'.$skin.'/style.css?'.$self->{version}, type => 'text/css', media => 'all';
@@ -30,6 +30,24 @@ sub htmlHeader { # %options->{ title, noindex, search, feeds, svg }
}
Link rel => 'alternate', type => 'application/atom+xml', href => "/feeds/$_.atom", title => $self->{atom_feeds}{$_}[1]
for ($o{feeds} ? @{$o{feeds}} : ());
+
+ if(exists $o{metadata}) {
+ # Required fields as per http://op.me/#metadata: og:title, og:type, og:image, og:url
+ if(exists $o{metadata}{'og:title'}) {
+ $o{metadata}{'og:site_name'} = 'The Visual Novel Database';
+ $o{metadata}{'og:type'} ||= 'object';
+ $o{metadata}{'og:image'} ||= $self->{placeholder_img};
+ $o{metadata}{'og:url'} ||= $self->reqURI();
+ }
+
+ for my $k (keys %{$o{metadata}}) {
+ next unless $o{metadata}{$k};
+ $o{metadata}{$k} =~ s/\R/ /g;
+
+ meta property => "$k", content => $o{metadata}->{$k}, undef;
+ }
+ }
+
meta name => 'robots', content => 'noindex, follow', undef if $o{noindex};
end;
body;