add HTTP link header to channel page, making it pluggable
This commit is contained in:
parent
90f759412b
commit
7b060dff68
@ -178,6 +178,25 @@ class Router {
|
||||
*/
|
||||
|
||||
if(\App::$module_loaded) {
|
||||
if (( \App::$module === 'channel' ) && argc() > 1) {
|
||||
\App::$channel_links = [
|
||||
[
|
||||
'rel' => 'lrdd',
|
||||
'type' => 'application/xrd+xml',
|
||||
'url' => z_root() . '/xrd?f=&uri=acct%3A' . argv(1) . '%40' . \App::get_hostname()
|
||||
],
|
||||
[
|
||||
'rel' => 'jrd',
|
||||
'type' => 'application/jrd+json',
|
||||
'url' => z_root() . '/.well-known/webfinger?f=&resource=acct%3A' . argv(1) . '%40' . \App::get_hostname()
|
||||
],
|
||||
];
|
||||
$x = [ 'channel_address' => argv(1), 'channel_links' => \App::$channel_links ];
|
||||
call_hooks('channel_links', $x );
|
||||
\App::$channel_links = $x['channel_links'];
|
||||
header('Link: ' . \App::get_channel_links());
|
||||
}
|
||||
|
||||
\App::$page['page_title'] = \App::$module;
|
||||
$placeholder = '';
|
||||
|
||||
|
18
boot.php
18
boot.php
@ -782,6 +782,10 @@ class App {
|
||||
public static $is_tablet = false;
|
||||
public static $comanche;
|
||||
|
||||
|
||||
public static $channel_links;
|
||||
|
||||
|
||||
public static $category;
|
||||
|
||||
// Allow themes to control internal parameters
|
||||
@ -929,6 +933,7 @@ class App {
|
||||
self::$module = 'home';
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* See if there is any page number information, and initialise
|
||||
* pagination
|
||||
@ -1026,6 +1031,19 @@ class App {
|
||||
return self::$path;
|
||||
}
|
||||
|
||||
public static function get_channel_links() {
|
||||
$s = '';
|
||||
$x = self::$channel_links;
|
||||
if($x && is_array($x) && count($x)) {
|
||||
foreach($x as $y) {
|
||||
if($s) {
|
||||
$s .= ',';
|
||||
}
|
||||
$s .= '<' . $y['url'] . '>;rel="' . $y['rel'] . '";type="' . $y['type'] . '"';
|
||||
}
|
||||
}
|
||||
return $s;
|
||||
}
|
||||
public static function set_account($acct) {
|
||||
self::$account = $acct;
|
||||
}
|
||||
|
@ -91,6 +91,9 @@ Hooks allow plugins/addons to "hook into" the code at many points and alter the
|
||||
[zrl=[baseurl]/help/hook/channel_remove]channel_remove[/zrl]
|
||||
Called when removing a channel
|
||||
|
||||
[zrl=[baseurl]/help/hook/channel_links]channel_links[/zrl]
|
||||
Called when generating the Link: HTTP header for a channel
|
||||
|
||||
[zrl=[baseurl]/help/hook/channel_settings]channel_settings[/zrl]
|
||||
Called when displaying the channel settings page
|
||||
|
||||
|
Reference in New Issue
Block a user