From 753a2d8c6b69ae86e5968b9672992b7b60341067 Mon Sep 17 00:00:00 2001 From: Yorhel Date: Thu, 6 Aug 2009 11:39:32 +0200 Subject: Added OpenSearch plugin + autodetection --- lib/VNDB/Handler/Misc.pm | 22 +++++++++++++++++++++- lib/VNDB/Util/LayoutHTML.pm | 1 + 2 files changed, 22 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/VNDB/Handler/Misc.pm b/lib/VNDB/Handler/Misc.pm index a2d346d8..ceae11ce 100644 --- a/lib/VNDB/Handler/Misc.pm +++ b/lib/VNDB/Handler/Misc.pm @@ -4,7 +4,7 @@ package VNDB::Handler::Misc; use strict; use warnings; -use YAWF ':html'; +use YAWF ':html', ':xml'; use VNDB::Func; @@ -15,6 +15,7 @@ YAWF::register( qr{nospam}, \&nospam, qr{([vrp])([1-9]\d*)/(lock|hide)}, \&itemmod, qr{we-dont-like-ie6}, \&ie6message, + qr{opensearch\.xml}, \&opensearch, # redirects for old URLs qr{(.*[^/]+)/+}, sub { $_[0]->resRedirect("/$_[1]", 'perm') }, @@ -372,5 +373,24 @@ sub ie6message { } +sub opensearch { + my $self = shift; + $self->resHeader('Content-Type' => 'application/opensearchdescription+xml'); + xml; + tag 'OpenSearchDescription', + xmlns => 'http://a9.com/-/spec/opensearch/1.1/', 'xmlns:moz' => 'http://www.mozilla.org/2006/browser/search/'; + tag 'ShortName', 'VNDB'; + tag 'LongName', 'VNDB.org visual novel search'; + tag 'Description', 'Search visual vovels on VNDB.org'; + tag 'Image', width => 16, height => 16, type => 'image/x-icon', $self->{url}.'/favicon.ico' + if -s "$VNDB::ROOT/www/favicon.ico"; + tag 'Url', type => 'text/html', method => 'get', template => $self->{url}.'/v/all?q={searchTerms}', undef; + tag 'Url', type => 'application/opensearchdescription+xml', rel => 'self', template => $self->{url}.'/opensearch.xml', undef; + tag 'Query', role => 'example', searchTerms => 'Tsukihime', undef; + tag 'moz:SearchForm', $self->{url}.'/v/all'; + end; +} + + 1; diff --git a/lib/VNDB/Util/LayoutHTML.pm b/lib/VNDB/Util/LayoutHTML.pm index 2cf3fc40..b5813330 100644 --- a/lib/VNDB/Util/LayoutHTML.pm +++ b/lib/VNDB/Util/LayoutHTML.pm @@ -21,6 +21,7 @@ sub htmlHeader { # %options->{ title, js, noindex, search } 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'; + Link rel => 'search', type => 'application/opensearchdescription+xml', title => 'VNDB VN Search', href => $self->{url}.'/opensearch.xml'; if($o{js}) { script type => 'text/javascript', src => $self->{url_static}.'/f/forms.js?'.$self->{version}; end; } -- cgit v1.2.3