[activitypub] Change pkgname; Add ACP page, federation switch
This commit is contained in:
parent
0e6541b7da
commit
2067f380b5
|
@ -1,12 +0,0 @@
|
||||||
spaccinc_activitypub_activitypub_webfinger:
|
|
||||||
path: /.well-known/webfinger
|
|
||||||
defaults: { _controller: spaccinc.activitypub.controller.activitypub:webfinger }
|
|
||||||
|
|
||||||
spaccinc_activitypub_activitypub_nodeinfo_known:
|
|
||||||
path: /.well-known/nodeinfo
|
|
||||||
defaults: { _controller: spaccinc.activitypub.controller.activitypub:nodeinfo_known }
|
|
||||||
|
|
||||||
spaccinc_activitypub_activitypub_activitypub:
|
|
||||||
path: /activitypub
|
|
||||||
defaults: { _controller: spaccinc.activitypub.controller.activitypub:activitypub }
|
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
services:
|
|
||||||
spaccinc.activitypub.controller.activitypub:
|
|
||||||
class: spaccinc\activitypub\controller\activitypub_controller
|
|
||||||
arguments:
|
|
||||||
- '@request'
|
|
||||||
- '@dbal.conn'
|
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace spaccincphpbb\activitypub\acp;
|
||||||
|
|
||||||
|
class activitypub_info
|
||||||
|
{
|
||||||
|
public function module()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'filename' => '\spaccincphpbb\activitypub\acp\activitypub_module',
|
||||||
|
'title' => 'ACP_SPACCINC_ACTIVITYPUB_TITLE',
|
||||||
|
'modes' => [
|
||||||
|
'settings' => [
|
||||||
|
'title' => 'ACP_SPACCINC_ACTIVITYPUB_TITLE',
|
||||||
|
'auth' => 'ext_spaccincphpbb/activitypub && acl_a_board',
|
||||||
|
'cat' => ['ACP_SPACCINC_ACTIVITYPUB_TITLE'],
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace spaccincphpbb\activitypub\acp;
|
||||||
|
|
||||||
|
class activitypub_module
|
||||||
|
{
|
||||||
|
public $page_title;
|
||||||
|
public $tpl_name;
|
||||||
|
public $u_action;
|
||||||
|
|
||||||
|
public function main($id, $mode)
|
||||||
|
{
|
||||||
|
global $phpbb_container;
|
||||||
|
|
||||||
|
$acp_controller = $phpbb_container->get('spaccincphpbb.activitypub.controller.acp');
|
||||||
|
$this->tpl_name = 'acp_spaccinc_activitypub_main';
|
||||||
|
$this->page_title = 'ACP_SPACCINC_ACTIVITYPUB_TITLE';
|
||||||
|
$acp_controller->set_page_url($this->u_action);
|
||||||
|
$acp_controller->display_options();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
{% include 'overall_header.html' %}
|
||||||
|
|
||||||
|
<h1>{{ lang('ACP_SPACCINC_ACTIVITYPUB_TITLE') }}</h1>
|
||||||
|
|
||||||
|
{% if S_ERROR %}
|
||||||
|
<div class="errorbox">
|
||||||
|
<h3>{{ lang('WARNING') }}</h3>
|
||||||
|
<p>{{ ERROR_MSG }}</p>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<form id="spaccincphpbb_activitypub_acp" name="spaccincphpbb_activitypub_acp" method="post" action="{{ U_ACTION }}">
|
||||||
|
|
||||||
|
<fieldset>
|
||||||
|
<legend>{{ lang('SETTINGS') }}</legend>
|
||||||
|
<dl>
|
||||||
|
<dt><label for="spaccincphpbb_activitypub_setfederation">{{ lang('ACP_SPACCINC_ACTIVITYPUB_SETFEDERATION') ~ lang('COLON') }}</label></dt>
|
||||||
|
<dd><label><input type="radio" class="radio" name="spaccincphpbb_activitypub_setfederation" value="1"{% if SPACCINCPHPBB_ACTIVITYPUB_SETFEDERATION %} checked="checked"{% endif %} /> {{ lang('YES') }}</label>
|
||||||
|
<label><input type="radio" class="radio" name="spaccincphpbb_activitypub_setfederation" value="0"{% if not SPACCINCPHPBB_ACTIVITYPUB_SETFEDERATION %} checked="checked"{% endif %} /> {{ lang('NO') }}</label></dd>
|
||||||
|
</dl>
|
||||||
|
<!--<dl>
|
||||||
|
<dt><label for="spaccincphpbb_activitypub_setdomain">{{ lang('ACP_SPACCINC_ACTIVITYPUB_SETDOMAIN') ~ lang('COLON') }}</label><br /><span>{{ lang('ACP_SPACCINC_ACTIVITYPUB_SETDOMAIN_INFO') }}</span></dt>
|
||||||
|
<dd><input name="spaccincphpbb_activitypub_setdomain" type="text" placeholder="TODO" value="TODO" disabled="TODO" /></dd>
|
||||||
|
</dl>-->
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<fieldset class="submit-buttons">
|
||||||
|
<input class="button1" type="submit" id="submit" name="submit" value="{{ lang('SUBMIT') }}" />
|
||||||
|
{{ S_FORM_TOKEN }}
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
|
{% include 'overall_footer.html' %}
|
6
phpBB/ext/spaccinc/activitypub/composer.json → phpBB/ext/spaccincphpbb/activitypub/composer.json
Executable file → Normal file
6
phpBB/ext/spaccinc/activitypub/composer.json → phpBB/ext/spaccincphpbb/activitypub/composer.json
Executable file → Normal file
|
@ -1,10 +1,10 @@
|
||||||
{
|
{
|
||||||
"name": "spaccinc/activitypub",
|
"name": "spaccincphpbb/activitypub",
|
||||||
"type": "phpbb-extension",
|
"type": "phpbb-extension",
|
||||||
"description": "ActivityPub for phpBB",
|
"description": "ActivityPub for phpBB",
|
||||||
"homepage": "https://gitlab.com/SpaccInc/SpaccCommunityPlatform",
|
"homepage": "https://gitlab.com/SpaccInc/SpaccCommunityPlatform",
|
||||||
"version": "0.0.1-dev",
|
"version": "0.0.2-dev",
|
||||||
"time": "2023-09-07",
|
"time": "2023-09-09",
|
||||||
"license": "[to be defined]",
|
"license": "[to be defined]",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
|
@ -0,0 +1,11 @@
|
||||||
|
spaccincphpbb_activitypub_activitypub_webfinger:
|
||||||
|
path: /.well-known/webfinger
|
||||||
|
defaults: { _controller: spaccincphpbb.activitypub.controller.activitypub:webfinger }
|
||||||
|
|
||||||
|
spaccincphpbb_activitypub_activitypub_nodeinfo_known:
|
||||||
|
path: /.well-known/nodeinfo
|
||||||
|
defaults: { _controller: spaccincphpbb.activitypub.controller.activitypub:nodeinfo_known }
|
||||||
|
|
||||||
|
spaccincphpbb_activitypub_activitypub_activitypub:
|
||||||
|
path: /activitypub
|
||||||
|
defaults: { _controller: spaccincphpbb.activitypub.controller.activitypub:activitypub }
|
|
@ -0,0 +1,17 @@
|
||||||
|
services:
|
||||||
|
spaccincphpbb.activitypub.controller.activitypub:
|
||||||
|
class: spaccincphpbb\activitypub\controller\activitypub_controller
|
||||||
|
arguments:
|
||||||
|
- '@config'
|
||||||
|
- '@request'
|
||||||
|
- '@dbal.conn'
|
||||||
|
|
||||||
|
spaccincphpbb.activitypub.controller.acp:
|
||||||
|
class: spaccincphpbb\activitypub\controller\acp_controller
|
||||||
|
arguments:
|
||||||
|
- '@config'
|
||||||
|
- '@language'
|
||||||
|
- '@log'
|
||||||
|
- '@request'
|
||||||
|
- '@template'
|
||||||
|
- '@user'
|
|
@ -0,0 +1,66 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace spaccincphpbb\activitypub\controller;
|
||||||
|
|
||||||
|
class acp_controller
|
||||||
|
{
|
||||||
|
protected $config;
|
||||||
|
protected $language;
|
||||||
|
protected $log;
|
||||||
|
protected $request;
|
||||||
|
protected $template;
|
||||||
|
protected $user;
|
||||||
|
protected $u_action;
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
\phpbb\config\config $config,
|
||||||
|
\phpbb\language\language $language,
|
||||||
|
\phpbb\log\log $log,
|
||||||
|
\phpbb\request\request $request,
|
||||||
|
\phpbb\template\template $template,
|
||||||
|
\phpbb\user $user,
|
||||||
|
){
|
||||||
|
$this->config = $config;
|
||||||
|
$this->language = $language;
|
||||||
|
$this->log = $log;
|
||||||
|
$this->request = $request;
|
||||||
|
$this->template = $template;
|
||||||
|
$this->user = $user;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function display_options()
|
||||||
|
{
|
||||||
|
$this->language->add_lang('common', 'spaccincphpbb/activitypub');
|
||||||
|
add_form_key('spaccincphpbb_activitypub_acp');
|
||||||
|
$errors = [];
|
||||||
|
|
||||||
|
if ($this->request->is_set_post('submit'))
|
||||||
|
{
|
||||||
|
if (!check_form_key('spaccincphpbb_activitypub_acp'))
|
||||||
|
{
|
||||||
|
$errors[] = $this->language->lang('FORM_INVALID');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($errors))
|
||||||
|
{
|
||||||
|
$this->config->set('spaccincphpbb_activitypub_setfederation', $this->request->variable('spaccincphpbb_activitypub_setfederation', 0));
|
||||||
|
$this->log->add('admin', $this->user->data['user_id'], $this->user->ip, 'LOG_ACP_SPACCINC_ACTIVITYPUB_SETTINGS');
|
||||||
|
trigger_error($this->language->lang('CONFIG_UPDATED') . adm_back_link($this->u_action));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$s_errors = !empty($errors);
|
||||||
|
|
||||||
|
$this->template->assign_vars([
|
||||||
|
'S_ERROR' => $s_errors,
|
||||||
|
'ERROR_MSG' => $s_errors ? implode('<br />', $errors) : '',
|
||||||
|
'U_ACTION' => $this->u_action,
|
||||||
|
'SPACCINCPHPBB_ACTIVITYPUB_SETFEDERATION' => (bool)$this->config['spaccincphpbb_activitypub_setfederation'],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function set_page_url($u_action)
|
||||||
|
{
|
||||||
|
$this->u_action = $u_action;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,16 +1,14 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace spaccinc\activitypub\controller;
|
namespace spaccincphpbb\activitypub\controller;
|
||||||
|
|
||||||
use ErrorException;
|
use ErrorException;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
class activitypub_controller
|
class activitypub_controller
|
||||||
{
|
{
|
||||||
/** @var \phpbb\request\request */
|
protected $config;
|
||||||
protected $request;
|
protected $request;
|
||||||
|
|
||||||
/** @var \phpbb\db\driver\driver_interface */
|
|
||||||
protected $db;
|
protected $db;
|
||||||
|
|
||||||
// Quick way to force any PHP warning to be an error that halts execution and makes nothing return,
|
// Quick way to force any PHP warning to be an error that halts execution and makes nothing return,
|
||||||
|
@ -24,9 +22,11 @@ class activitypub_controller
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
|
\phpbb\config\config $config,
|
||||||
\phpbb\request\request $request,
|
\phpbb\request\request $request,
|
||||||
\phpbb\db\driver\driver_interface $db,
|
\phpbb\db\driver\driver_interface $db,
|
||||||
){
|
){
|
||||||
|
$this->config = $config;
|
||||||
$this->request = $request;
|
$this->request = $request;
|
||||||
$this->db = $db;
|
$this->db = $db;
|
||||||
|
|
||||||
|
@ -45,19 +45,6 @@ class activitypub_controller
|
||||||
$this->server_addr = ((!empty($this->request->server('HTTPS')) && (strtolower($this->request->server('HTTPS')) == 'on' || $this->request->server('HTTPS') == '1')) ? 'https://' : 'http://') . $this->server_name;
|
$this->server_addr = ((!empty($this->request->server('HTTPS')) && (strtolower($this->request->server('HTTPS')) == 'on' || $this->request->server('HTTPS') == '1')) ? 'https://' : 'http://') . $this->server_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
//private function server_name()
|
|
||||||
//{
|
|
||||||
// // <https://area51.phpbb.com/docs/dev/3.3.x/request/request.html#server>
|
|
||||||
// //return strtolower(htmlspecialchars_decode($this->request->header('Host', $this->request->server('SERVER_NAME'))));
|
|
||||||
//}
|
|
||||||
|
|
||||||
//private function server_addr()
|
|
||||||
//{
|
|
||||||
// // <https://stackoverflow.com/a/56373183>
|
|
||||||
// $proto = (!empty($this->request->server('HTTPS')) && (strtolower($this->request->server('HTTPS')) == 'on' || $this->request->server('HTTPS') == '1')) ? 'https://' : 'http://';
|
|
||||||
// return $proto . $this->server_name;
|
|
||||||
//}
|
|
||||||
|
|
||||||
private function get_sql_row($sql)
|
private function get_sql_row($sql)
|
||||||
{
|
{
|
||||||
$result = $this->db->sql_query($sql);
|
$result = $this->db->sql_query($sql);
|
||||||
|
@ -68,6 +55,10 @@ class activitypub_controller
|
||||||
|
|
||||||
public function nodeinfo_known()
|
public function nodeinfo_known()
|
||||||
{
|
{
|
||||||
|
if (!$this->config['spaccincphpbb_activitypub_setfederation']) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
set_error_handler([$this, 'exception_error_handler']);
|
set_error_handler([$this, 'exception_error_handler']);
|
||||||
$server_addr = $this->server_addr;
|
$server_addr = $this->server_addr;
|
||||||
$response = new Response(json_encode([
|
$response = new Response(json_encode([
|
||||||
|
@ -83,6 +74,10 @@ class activitypub_controller
|
||||||
|
|
||||||
public function webfinger()
|
public function webfinger()
|
||||||
{
|
{
|
||||||
|
if (!$this->config['spaccincphpbb_activitypub_setfederation']) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
set_error_handler([$this, 'exception_error_handler']);
|
set_error_handler([$this, 'exception_error_handler']);
|
||||||
$server_name = $this->server_name;
|
$server_name = $this->server_name;
|
||||||
$server_addr = $this->server_addr;
|
$server_addr = $this->server_addr;
|
||||||
|
@ -135,6 +130,10 @@ class activitypub_controller
|
||||||
|
|
||||||
public function activitypub()
|
public function activitypub()
|
||||||
{
|
{
|
||||||
|
if (!$this->config['spaccincphpbb_activitypub_setfederation']) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
set_error_handler([$this, 'exception_error_handler']);
|
set_error_handler([$this, 'exception_error_handler']);
|
||||||
$server_addr = $this->server_addr;
|
$server_addr = $this->server_addr;
|
||||||
$uri_id = htmlspecialchars_decode($server_addr . $this->request->server('REQUEST_URI'));
|
$uri_id = htmlspecialchars_decode($server_addr . $this->request->server('REQUEST_URI'));
|
||||||
|
@ -157,7 +156,7 @@ class activitypub_controller
|
||||||
'version' => '2.0',
|
'version' => '2.0',
|
||||||
'software' => [
|
'software' => [
|
||||||
'name' => 'phpBB ActivityPub',
|
'name' => 'phpBB ActivityPub',
|
||||||
'version' => '0.0.1',
|
'version' => '0.0.1-dev',
|
||||||
],
|
],
|
||||||
'protocols' => [
|
'protocols' => [
|
||||||
'activitypub',
|
'activitypub',
|
|
@ -0,0 +1,15 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
if (!defined('IN_PHPBB'))
|
||||||
|
{
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($lang) || !is_array($lang))
|
||||||
|
{
|
||||||
|
$lang = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$lang = array_merge($lang, [
|
||||||
|
|
||||||
|
]);
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
if (!defined('IN_PHPBB'))
|
||||||
|
{
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($lang) || !is_array($lang))
|
||||||
|
{
|
||||||
|
$lang = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$lang = array_merge($lang, [
|
||||||
|
'ACP_SPACCINC_ACTIVITYPUB_TITLE' => 'ActivityPub for phpBB Module',
|
||||||
|
'ACP_SPACCINC_ACTIVITYPUB_SETFEDERATION' => 'Enable ActivityPub federation for this board',
|
||||||
|
'ACP_SPACCINC_ACTIVITYPUB_SETDOMAIN' => 'Full domain name to use for federation',
|
||||||
|
'ACP_SPACCINC_ACTIVITYPUB_SETDOMAIN_INFO' => 'The domain on which federation will be handled. NEVER change this after enabling federation, unless you know the implications.',
|
||||||
|
]);
|
|
@ -0,0 +1,37 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace spaccincphpbb\activitypub\migrations;
|
||||||
|
|
||||||
|
class install_acp_module extends \phpbb\db\migration\migration
|
||||||
|
{
|
||||||
|
public function effectively_installed()
|
||||||
|
{
|
||||||
|
return isset($this->config['spaccincphpbb_activitypub_setfederation']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function depends_on()
|
||||||
|
{
|
||||||
|
return ['\phpbb\db\migration\data\v320\v320'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update_data()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
['config.add', ['spaccincphpbb_activitypub_setfederation', 0]],
|
||||||
|
|
||||||
|
['module.add', [
|
||||||
|
'acp',
|
||||||
|
'ACP_CAT_DOT_MODS',
|
||||||
|
'ACP_SPACCINC_ACTIVITYPUB_TITLE'
|
||||||
|
]],
|
||||||
|
['module.add', [
|
||||||
|
'acp',
|
||||||
|
'ACP_SPACCINC_ACTIVITYPUB_TITLE',
|
||||||
|
[
|
||||||
|
'module_basename' => '\spaccincphpbb\activitypub\acp\activitypub_module',
|
||||||
|
'modes' => ['settings'],
|
||||||
|
],
|
||||||
|
]],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue