Commit 05775eaa authored by swentel's avatar swentel

Issue #3178724: add example note config + allow description

parent 1033af97
......@@ -49,7 +49,8 @@ outbox activities will be send then.
5. On admin/config/services/activitypub/activitypub-type you get an overview
of all ActivityPub Type configuration entities. Three are enabled (and locked)
when enabling this module, which are the 'Accept', 'Delete' and 'Inbox reply'
types.
types. A few examples are also installed which have basic configuration but
are not enabled yet since this depends on your own setup.
6. Create your own configuration
- Select 'Type plugin', only dynamic types is currently available
- Select the content type which you want to map
......
......@@ -3,6 +3,7 @@ status: true
dependencies: { }
id: accept
label: Accept
description: 'Sends the "Accept" request when a (remote) user wants to follow a local user.'
locked: true
plugin:
id: activitypub_static_types
......
......@@ -3,6 +3,7 @@ status: true
dependencies: { }
id: delete
label: Delete
description: 'Sends the "Delete" request for a local activity.'
locked: true
plugin:
id: activitypub_static_types
......
......@@ -3,6 +3,7 @@ status: true
dependencies: { }
id: inbox_reply
label: Inbox reply
description: "Handles an incoming \"Create\" request which has a reply value. \r\nIf you allow creating comments, it can create a comment on a node."
locked: true
plugin:
id: activitypub_static_types
......
langcode: en
status: false
dependencies: { }
id: note
label: Note
description: "Example to create a \"Note\" and send it to your followers.\r\nEdit the configuration to enable and configure the content type and mapping of fields."
locked: false
plugin:
id: activitypub_dynamic_types
configuration:
target_entity_type_id: node
target_bundle: ''
activity: Create
object: Note
field_mapping:
-
property: published
field_name: created
-
property: name
field_name: title
-
property: content
field_name: body
-
property: summary
field_name: ''
-
property: object
field_name: ''
-
property: inReplyTo
field_name: ''
-
property: attachment
field_name: ''
......@@ -9,6 +9,9 @@ activitypub.activitypub_type.*:
label:
type: label
label: Label
description:
type: text
label: Description
uuid:
type: string
locked:
......
......@@ -43,6 +43,7 @@ use Drupal\Core\Config\Entity\ConfigEntityInterface;
* config_export = {
* "id",
* "label",
* "description",
* "locked",
* "plugin"
* }
......@@ -64,6 +65,13 @@ class ActivityPubType extends ConfigEntityBase implements ActivityPubTypeInterfa
*/
protected $label;
/**
* The description.
*
* @var string
*/
protected $description;
/**
* The status.
*
......@@ -106,6 +114,13 @@ class ActivityPubType extends ConfigEntityBase implements ActivityPubTypeInterfa
*/
protected $widget;
/**
* {@inheritdoc}
*/
public function getDescription() {
return $this->description;
}
/**
* {@inheritdoc}
*/
......
......@@ -9,6 +9,13 @@ use Drupal\Core\Config\Entity\ConfigEntityInterface;
*/
interface ActivityPubTypeInterface extends ConfigEntityInterface {
/**
* Returns the description for this type.
*
* @return string
*/
public function getDescription();
/**
* Returns whether the entity is locked or not.
*
......
......@@ -15,9 +15,10 @@ class ActivityPubTypeListBuilder extends ConfigEntityListBuilder {
*/
public function buildHeader() {
$header['label'] = $this->t('Label');
$header['description'] = $this->t('Description');
$header['status'] = $this->t('Status');
$header['id'] = $this->t('Machine name');
$header['plugin_id'] = $this->t('Plugin');
$header['status'] = $this->t('Status');
return $header + parent::buildHeader();
}
......@@ -27,9 +28,10 @@ class ActivityPubTypeListBuilder extends ConfigEntityListBuilder {
public function buildRow(EntityInterface $entity) {
/** @var \Drupal\activitypub\Entity\ActivityPubTypeInterface $entity */
$row['label'] = $entity->label();
$row['description'] = ['data' => ['#markup' => nl2br($entity->getDescription())]];
$row['status'] = $entity->status() ? $this->t('Enabled') : $this->t('Disabled');
$row['id'] = $entity->id();
$row['plugin_id'] = $entity->getPlugin()['id'];
$row['status'] = $entity->status() ? $this->t('Enabled') : $this->t('Disabled');
return $row + parent::buildRow($entity);
}
......
......@@ -70,6 +70,12 @@ class ActivityPubTypeForm extends EntityForm {
'#disabled' => !$this->entity->isNew(),
];
$form['description'] = [
'#type' => 'textarea',
'#title' => $this->t('Description'),
'#default_value' => $this->entity->getDescription(),
];
$form['status'] = [
'#type' => 'checkbox',
'#title' => $this->t('Enabled'),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment