move opensearch to plugins

This commit is contained in:
zotlabs 2017-02-02 14:49:51 -08:00
parent e2ee565f05
commit 2daafe80a5
7 changed files with 44 additions and 43 deletions

View file

@ -159,6 +159,8 @@ class Apps {
if(array_key_exists('version',$ret))
$ret['version'] = str_replace(array('\'','"'),array(''','&dquot;'),$ret['version']);
if(array_key_exists('categories',$ret))
$ret['categories'] = str_replace(array('\'','"'),array(''','&dquot;'),$ret['categories']);
if(array_key_exists('requires',$ret)) {
$requires = explode(',',$ret['requires']);

View file

@ -1,24 +0,0 @@
<?php
namespace Zotlabs\Module;
class Opensearch extends \Zotlabs\Web\Controller {
function init() {
$tpl = get_markup_template('opensearch.tpl');
header("Content-type: application/opensearchdescription+xml");
$o = replace_macros($tpl, array(
'$baseurl' => z_root(),
'$nodename' => \App::get_hostname(),
));
echo $o;
killme();
}
}

View file

@ -802,6 +802,7 @@ class App {
public static $identities;
public static $css_sources = array();
public static $js_sources = array();
public static $linkrel = array();
public static $theme_info = array();
public static $is_sys = false;
public static $nav_sel;
@ -1164,6 +1165,11 @@ class App {
self::$meta->set('generator', Zotlabs\Lib\System::get_platform_name());
head_add_link(['rel' => 'shortcut icon', 'href' => head_get_icon()]);
$x = [ 'header' => '' ];
call_hooks('build_pagehead',$x);
/* put the head template at the beginning of page['htmlhead']
* since the code added by the modules frequently depends on it
* being first
@ -1176,11 +1182,12 @@ class App {
'$baseurl' => self::get_baseurl(),
'$local_channel' => local_channel(),
'$metas' => self::$meta->get(),
'$plugins' => $x['header'],
'$update_interval' => $interval,
'osearch' => sprintf( t('Search %1$s (%2$s)','opensearch'), Zotlabs\Lib\System::get_site_name(), t('$Projectname','opensearch')),
'$icon' => head_get_icon(),
'$head_css' => head_get_css(),
'$head_js' => head_get_js(),
'$linkrel' => head_get_links(),
'$js_strings' => js_strings(),
'$zid' => get_my_address(),
'$channel_id' => self::$profile['uid'],

View file

@ -76,6 +76,9 @@ Hooks allow plugins/addons to "hook into" the code at many points and alter the
[zrl=[baseurl]/help/hook/bb_translate_video]bb_translate_video[/zrl]
Called when extracting embedded services from bbcode video elements (rarely used)
[zrl=[baseurl]/help/hook/build_pagehead]build_pagehead[/zrl]
Called when creating the HTML page header
[zrl=[baseurl]/help/hook/change_channel]change_channel[/zrl]
Called when logging in to a channel (either during login or afterward through the channel manager)

View file

@ -556,21 +556,47 @@ function head_add_css($src, $media = 'screen') {
function head_remove_css($src, $media = 'screen') {
$index = array_search(array($src, $media), App::$css_sources);
if ($index !== false)
if($index !== false)
unset(App::$css_sources[$index]);
}
function head_get_css() {
$str = '';
$sources = App::$css_sources;
if (count($sources)) {
foreach ($sources as $source)
if(count($sources)) {
foreach($sources as $source)
$str .= format_css_if_exists($source);
}
return $str;
}
function head_add_link($arr) {
if($arr) {
App::$linkrel[] = $arr;
}
}
function head_get_links() {
$str = '';
$sources = App::$linkrel;
if(count($sources)) {
foreach($sources as $source) {
if(is_array($source) && count($source)) {
$str .= '<link';
foreach($source as $k => $v) {
$str .= ' ' . $k . '="' . $v . '"';
}
$str .= ' />' . "\r\n";
}
}
}
return $str;
}
function format_css_if_exists($source) {
$path_prefix = script_path() . '/';

View file

@ -5,8 +5,8 @@
{{$head_css}}
{{$js_strings}}
{{$head_js}}
<link rel="shortcut icon" href="{{$icon}}" />
<link rel="search" href="{{$baseurl}}/opensearch" type="application/opensearchdescription+xml" title="{{$osearch}}" />
{{$linkrel}}
{{$plugins}}
<link rel="EditURI" type="application/rsd+xml" href="{{$baseurl}}/rsd.xml" />
<script>
var updateInterval = {{$update_interval}};

View file

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
<ShortName>Hubzilla@{{$nodename}}</ShortName>
<Description>Search in Hubzilla@{{$nodename}}</Description>
<Contact>http://github.com/redmatrix/hubzilla/</Contact>
<Image height="16" width="16" type="image/png">{{$baseurl}}/images/hz-16.png</Image>
<Image height="64" width="64" type="image/png">{{$baseurl}}/images/hz-64.png</Image>
<Url type="text/html"
template="{{$baseurl}}/search?search={searchTerms}"/>
<Url type="application/opensearchdescription+xml"
rel="self"
template="{{$baseurl}}/opensearch" />
</OpenSearchDescription>