Add OpenSearch
This commit is contained in:
parent
ed22304e4a
commit
ea95760c46
4 changed files with 40 additions and 0 deletions
|
@ -182,6 +182,12 @@ class Routing
|
|||
'Search:action',
|
||||
'SearchAction'
|
||||
);
|
||||
$r->add(
|
||||
$r::GET,
|
||||
'/opensearch.xml',
|
||||
'Misc:opensearch',
|
||||
'OpenSearch'
|
||||
);
|
||||
}
|
||||
// юзеры
|
||||
if ($userRules->viewUsers) {
|
||||
|
|
|
@ -342,6 +342,7 @@ abstract class Page extends Model
|
|||
'href' => $this->canonical,
|
||||
]);
|
||||
}
|
||||
|
||||
if ($this->robots) {
|
||||
$this->pageHeader('robots', 'meta', 11000, [
|
||||
'name' => 'robots',
|
||||
|
@ -349,6 +350,15 @@ abstract class Page extends Model
|
|||
]);
|
||||
}
|
||||
|
||||
if (1 === $this->user->g_search) {
|
||||
$this->pageHeader('opensearch', 'link', 0, [
|
||||
'rel' => 'search',
|
||||
'type' => 'application/opensearchdescription+xml',
|
||||
'href' => $this->c->Router->link('OpenSearch'),
|
||||
'title' => $this->fTitle,
|
||||
]);
|
||||
}
|
||||
|
||||
\uasort($this->pageHeaders, function (array $a, array $b) {
|
||||
if ($a['weight'] === $b['weight']) {
|
||||
return 0;
|
||||
|
|
|
@ -17,6 +17,22 @@ use function \ForkBB\__;
|
|||
|
||||
class Misc extends Page
|
||||
{
|
||||
public function opensearch(): Page
|
||||
{
|
||||
$this->nameTpl = "opensearch";
|
||||
$this->onlinePos = null;
|
||||
$this->onlineDetail = null;
|
||||
$this->imageLink = \preg_replace('%^(.*://(?:[^/]++)).*$%', '$1', $this->c->BASE_URL) . '/favicon.ico'; // ???? костыль O_o
|
||||
$this->searchLink = \strtr(
|
||||
$this->c->Router->link('Search', ['keywords' => 'SEARCHTERMS']),
|
||||
['SEARCHTERMS' => '{searchTerms}']
|
||||
);
|
||||
|
||||
$this->header('Content-type', 'application/xml; charset=utf-8');
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Пометка раздела прочитанным
|
||||
*/
|
||||
|
|
8
app/templates/opensearch.forkbb.php
Normal file
8
app/templates/opensearch.forkbb.php
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
|
||||
<ShortName>{{ $p->fTitle }}</ShortName>
|
||||
<Description>{{ $p->fTitle }}</Description>
|
||||
<InputEncoding>UTF-8</InputEncoding>
|
||||
<Image width="16" height="16" type="image/x-icon">{{ $p->imageLink }}</Image>
|
||||
<Url type="text/html" method="get" template="{{ $p->searchLink }}"/>
|
||||
</OpenSearchDescription>
|
Loading…
Add table
Reference in a new issue