Moved followers list to user-menu

This commit is contained in:
Matthias Pfefferle 2019-08-21 10:38:43 +02:00
parent b6b0743b3f
commit 2e91ce11de
9 changed files with 144 additions and 101 deletions

View file

@ -4,7 +4,7 @@
**Tags:** OStatus, fediverse, activitypub, activitystream **Tags:** OStatus, fediverse, activitypub, activitystream
**Requires at least:** 4.7 **Requires at least:** 4.7
**Tested up to:** 5.2.2 **Tested up to:** 5.2.2
**Stable tag:** 0.7.3 **Stable tag:** 0.8.0
**Requires PHP:** 5.6 **Requires PHP:** 5.6
**License:** MIT **License:** MIT
**License URI:** http://opensource.org/licenses/MIT **License URI:** http://opensource.org/licenses/MIT
@ -84,6 +84,10 @@ Where 'blog' is the path to the subdirectory at which your blog resides.
Project maintained on GitHub at [pfefferle/wordpress-activitypub](https://github.com/pfefferle/wordpress-activitypub). Project maintained on GitHub at [pfefferle/wordpress-activitypub](https://github.com/pfefferle/wordpress-activitypub).
### 0.8.0 ###
* Moved followers list to user-menu
### 0.7.4 ### ### 0.7.4 ###
* added admin_email to metadata, to be able to "Manage your instance" on https://fediverse.network/manage/ * added admin_email to metadata, to be able to "Manage your instance" on https://fediverse.network/manage/

View file

@ -3,7 +3,7 @@
* Plugin Name: ActivityPub * Plugin Name: ActivityPub
* Plugin URI: https://github.com/pfefferle/wordpress-activitypub/ * Plugin URI: https://github.com/pfefferle/wordpress-activitypub/
* Description: The ActivityPub protocol is a decentralized social networking protocol based upon the ActivityStreams 2.0 data format. * Description: The ActivityPub protocol is a decentralized social networking protocol based upon the ActivityStreams 2.0 data format.
* Version: 0.7.4 * Version: 0.8.0
* Author: Matthias Pfefferle * Author: Matthias Pfefferle
* Author URI: https://notiz.blog/ * Author URI: https://notiz.blog/
* License: MIT * License: MIT
@ -21,6 +21,7 @@ namespace Activitypub;
function init() { function init() {
defined( 'ACTIVITYPUB_HASHTAGS_REGEXP' ) || define( 'ACTIVITYPUB_HASHTAGS_REGEXP', '(?:(?<=\s)|^)#(\w*[A-Za-z_]+\w*)' ); defined( 'ACTIVITYPUB_HASHTAGS_REGEXP' ) || define( 'ACTIVITYPUB_HASHTAGS_REGEXP', '(?:(?<=\s)|^)#(\w*[A-Za-z_]+\w*)' );
require_once dirname( __FILE__ ) . '/includes/table/followers-list.php';
require_once dirname( __FILE__ ) . '/includes/class-signature.php'; require_once dirname( __FILE__ ) . '/includes/class-signature.php';
require_once dirname( __FILE__ ) . '/includes/class-activity.php'; require_once dirname( __FILE__ ) . '/includes/class-activity.php';
require_once dirname( __FILE__ ) . '/includes/db/class-followers.php'; require_once dirname( __FILE__ ) . '/includes/db/class-followers.php';

View file

@ -28,14 +28,25 @@ class Admin {
array( '\Activitypub\Admin', 'settings_page' ) array( '\Activitypub\Admin', 'settings_page' )
); );
add_action( 'load-' . $settings_page, array( '\Activitypub\Admin', 'add_help_tab' ) ); add_action( 'load-' . $settings_page, array( '\Activitypub\Admin', 'add_settings_help_tab' ) );
$followers_list_page = add_users_page( __( 'Followers', 'activitypub' ), __( 'Followers (Fediverse)', 'activitypub' ), 'read', 'activitypub-followers-list', array( '\Activitypub\Admin', 'followers_list_page' ) );
add_action( 'load-' . $followers_list_page, array( '\Activitypub\Admin', 'add_followers_list_help_tab' ) );
} }
/** /**
* Load settings page * Load settings page
*/ */
public static function settings_page() { public static function settings_page() {
load_template( dirname( __FILE__ ) . '/../templates/settings-page.php' ); load_template( dirname( __FILE__ ) . '/../templates/settings.php' );
}
/**
* Load user settings page
*/
public static function followers_list_page() {
load_template( dirname( __FILE__ ) . '/../templates/followers-list.php' );
} }
/** /**
@ -89,7 +100,7 @@ class Admin {
); );
} }
public static function add_help_tab() { public static function add_settings_help_tab() {
get_current_screen()->add_help_tab( get_current_screen()->add_help_tab(
array( array(
'id' => 'overview', 'id' => 'overview',
@ -109,6 +120,10 @@ class Admin {
); );
} }
public static function add_followers_list_help_tab() {
// todo
}
public static function add_fediverse_profile( $user ) { public static function add_fediverse_profile( $user ) {
?> ?>
<h2><?php esc_html_e( 'Fediverse', 'activitypub' ); ?></h2> <h2><?php esc_html_e( 'Fediverse', 'activitypub' ); ?></h2>

View file

@ -30,6 +30,12 @@ class Followers {
return $followers; return $followers;
} }
public static function count_followers( $author_id ) {
$followers = self::get_followers( $author_id );
return count( $followers );
}
public static function add_follower( $actor, $author_id ) { public static function add_follower( $actor, $author_id ) {
$followers = get_user_option( 'activitypub_followers', $author_id ); $followers = get_user_option( 'activitypub_followers', $author_id );

View file

@ -0,0 +1,36 @@
<?php
namespace Activitypub\Table;
if ( ! class_exists( '\WP_List_Table' ) ) {
require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
}
class Followers_List extends \WP_List_Table {
public function get_columns() {
return array(
'identifier' => __( 'Identifier', 'activitypub' ),
);
}
public function get_sortable_columns() {
return array();
}
public function prepare_items() {
$columns = $this->get_columns();
$hidden = array();
$this->process_action();
$this->_column_headers = array( $columns, $hidden, $this->get_sortable_columns() );
$this->items = array();
foreach ( \Activitypub\Db\Followers::get_followers( get_current_user_id() ) as $follower ) {
$this->items[]['identifier'] = esc_attr( $follower );
}
}
public function column_default( $item, $column_name ) {
return $item[ $column_name ];
}
}

View file

@ -2,9 +2,10 @@
# This file is distributed under the MIT. # This file is distributed under the MIT.
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: ActivityPub 0.7.2\n" "Project-Id-Version: ActivityPub 0.8.0\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/activitypub\n" "Report-Msgid-Bugs-To: "
"POT-Creation-Date: 2019-07-28 20:11:43+00:00\n" "https://wordpress.org/support/plugin/wordpress-activitypub\n"
"POT-Creation-Date: 2019-08-21 08:37:52+00:00\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n" "Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
@ -13,33 +14,41 @@ msgstr ""
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
"X-Generator: grunt-wp-i18n 1.0.3\n" "X-Generator: grunt-wp-i18n 1.0.3\n"
#: includes/class-admin.php:48 #: includes/class-admin.php:33
msgid "Followers"
msgstr ""
#: includes/class-admin.php:33 templates/followers-list.php:2
msgid "Followers (Fediverse)"
msgstr ""
#: includes/class-admin.php:59
msgid "Use summary or full content" msgid "Use summary or full content"
msgstr "" msgstr ""
#: includes/class-admin.php:60 #: includes/class-admin.php:71
msgid "The Activity-Object-Type" msgid "The Activity-Object-Type"
msgstr "" msgstr ""
#: includes/class-admin.php:72 templates/settings-page.php:33 #: includes/class-admin.php:83 templates/settings.php:33
msgid "Use the Shortlink instead of the permalink" msgid "Use the Shortlink instead of the permalink"
msgstr "" msgstr ""
#: includes/class-admin.php:79 #: includes/class-admin.php:90
msgid "" msgid ""
"Add hashtags in the content as native tags and replace the #tag with the " "Add hashtags in the content as native tags and replace the #tag with the "
"tag-link" "tag-link"
msgstr "" msgstr ""
#: includes/class-admin.php:86 #: includes/class-admin.php:97
msgid "Add all tags as hashtags at the end of each activity" msgid "Add all tags as hashtags at the end of each activity"
msgstr "" msgstr ""
#: includes/class-admin.php:96 #: includes/class-admin.php:107
msgid "Overview" msgid "Overview"
msgstr "" msgstr ""
#: includes/class-admin.php:98 #: includes/class-admin.php:109
msgid "" msgid ""
"ActivityPub is a decentralized social networking protocol based on the " "ActivityPub is a decentralized social networking protocol based on the "
"ActivityStreams 2.0 data format. ActivityPub is an official W3C recommended " "ActivityStreams 2.0 data format. ActivityPub is an official W3C recommended "
@ -49,33 +58,33 @@ msgid ""
"subscribing to content." "subscribing to content."
msgstr "" msgstr ""
#: includes/class-admin.php:103 #: includes/class-admin.php:114
msgid "For more information:" msgid "For more information:"
msgstr "" msgstr ""
#: includes/class-admin.php:104 #: includes/class-admin.php:115
msgid "<a href=\"https://activitypub.rocks/\">Test Suite</a>" msgid "<a href=\"https://activitypub.rocks/\">Test Suite</a>"
msgstr "" msgstr ""
#: includes/class-admin.php:105 #: includes/class-admin.php:116
msgid "<a href=\"https://www.w3.org/TR/activitypub/\">W3C Spec</a>" msgid "<a href=\"https://www.w3.org/TR/activitypub/\">W3C Spec</a>"
msgstr "" msgstr ""
#: includes/class-admin.php:106 #: includes/class-admin.php:117
msgid "" msgid ""
"<a href=\"https://github.com/pfefferle/wordpress-activitypub/issues\">Give " "<a href=\"https://github.com/pfefferle/wordpress-activitypub/issues\">Give "
"us feedback</a>" "us feedback</a>"
msgstr "" msgstr ""
#: includes/class-admin.php:108 #: includes/class-admin.php:119
msgid "<a href=\"https://notiz.blog/donate\">Donate</a>" msgid "<a href=\"https://notiz.blog/donate\">Donate</a>"
msgstr "" msgstr ""
#: includes/class-admin.php:114 #: includes/class-admin.php:129
msgid "Fediverse" msgid "Fediverse"
msgstr "" msgstr ""
#: includes/db/class-followers.php:47 #: includes/db/class-followers.php:53
msgid "Unknown Actor schema" msgid "Unknown Actor schema"
msgstr "" msgstr ""
@ -106,7 +115,7 @@ msgstr ""
#: includes/rest/class-followers.php:46 includes/rest/class-followers.php:49 #: includes/rest/class-followers.php:46 includes/rest/class-followers.php:49
#: includes/rest/class-following.php:46 includes/rest/class-following.php:49 #: includes/rest/class-following.php:46 includes/rest/class-following.php:49
#: includes/rest/class-outbox.php:47 includes/rest/class-outbox.php:50 #: includes/rest/class-outbox.php:45 includes/rest/class-outbox.php:48
#: includes/rest/class-webfinger.php:61 #: includes/rest/class-webfinger.php:61
msgid "User not found" msgid "User not found"
msgstr "" msgstr ""
@ -132,11 +141,19 @@ msgstr ""
msgid "Resource host does not match blog host" msgid "Resource host does not match blog host"
msgstr "" msgstr ""
#: includes/table/followers-list.php:11
msgid "Identifier"
msgstr ""
#: templates/followers-list.php:4
msgid "You currently have %s followers."
msgstr ""
#: templates/json-author.php:48 #: templates/json-author.php:48
msgid "Blog" msgid "Blog"
msgstr "" msgstr ""
#: templates/json-author.php:58 templates/settings-page.php:71 #: templates/json-author.php:58
msgid "Profile" msgid "Profile"
msgstr "" msgstr ""
@ -144,114 +161,94 @@ msgstr ""
msgid "Website" msgid "Website"
msgstr "" msgstr ""
#: templates/settings-page.php:2 #: templates/settings.php:2
msgid "ActivityPub Settings" msgid "ActivityPub Settings"
msgstr "" msgstr ""
#: templates/settings-page.php:4 #: templates/settings.php:4
msgid "" msgid ""
"ActivityPub turns your blog into a federated social network. This means you " "ActivityPub turns your blog into a federated social network. This means you "
"can share and talk to everyone using the ActivityPub protocol, including " "can share and talk to everyone using the ActivityPub protocol, including "
"users of Friendica, Pleroma and Mastodon." "users of Friendica, Pleroma and Mastodon."
msgstr "" msgstr ""
#: templates/settings-page.php:9 #: templates/settings.php:9
msgid "Activities" msgid "Activities"
msgstr "" msgstr ""
#: templates/settings-page.php:11 #: templates/settings.php:11
msgid "All activity related settings." msgid "All activity related settings."
msgstr "" msgstr ""
#: templates/settings-page.php:17 #: templates/settings.php:17
msgid "Post-Content" msgid "Post-Content"
msgstr "" msgstr ""
#: templates/settings-page.php:21 #: templates/settings.php:21
msgid "Excerpt" msgid "Excerpt"
msgstr "" msgstr ""
#: templates/settings-page.php:21 #: templates/settings.php:21
msgid "A content summary, shortened to 400 characters and without markup." msgid "A content summary, shortened to 400 characters and without markup."
msgstr "" msgstr ""
#: templates/settings-page.php:24 #: templates/settings.php:24
msgid "Content (default)" msgid "Content (default)"
msgstr "" msgstr ""
#: templates/settings-page.php:24 #: templates/settings.php:24
msgid "The full content." msgid "The full content."
msgstr "" msgstr ""
#: templates/settings-page.php:30 #: templates/settings.php:30
msgid "Backlink" msgid "Backlink"
msgstr "" msgstr ""
#: templates/settings-page.php:39 #: templates/settings.php:39
msgid "Activity-Object-Type" msgid "Activity-Object-Type"
msgstr "" msgstr ""
#: templates/settings-page.php:43 #: templates/settings.php:43
msgid "Note (default)" msgid "Note (default)"
msgstr "" msgstr ""
#: templates/settings-page.php:43 #: templates/settings.php:43
msgid "Should work with most platforms." msgid "Should work with most platforms."
msgstr "" msgstr ""
#: templates/settings-page.php:46 #: templates/settings.php:46
msgid "Article" msgid "Article"
msgstr "" msgstr ""
#: templates/settings-page.php:46 #: templates/settings.php:46
msgid "" msgid ""
"The presentation of the \"Article\" might change on different platforms. " "The presentation of the \"Article\" might change on different platforms. "
"Mastodon for example shows the \"Article\" type as a simple link." "Mastodon for example shows the \"Article\" type as a simple link."
msgstr "" msgstr ""
#: templates/settings-page.php:49 #: templates/settings.php:49
msgid "WordPress Post-Format" msgid "WordPress Post-Format"
msgstr "" msgstr ""
#: templates/settings-page.php:49 #: templates/settings.php:49
msgid "Maps the WordPress Post-Format to the ActivityPub Object Type." msgid "Maps the WordPress Post-Format to the ActivityPub Object Type."
msgstr "" msgstr ""
#: templates/settings-page.php:55 #: templates/settings.php:55
msgid "Hashtags" msgid "Hashtags"
msgstr "" msgstr ""
#: templates/settings-page.php:59 #: templates/settings.php:59
msgid "" msgid ""
"Add hashtags in the content as native tags and replace the " "Add hashtags in the content as native tags and replace the "
"<code>#tag</code> with the tag-link." "<code>#tag</code> with the tag-link."
msgstr "" msgstr ""
#: templates/settings-page.php:62 #: templates/settings.php:62
msgid "Add all tags as hashtags to the end of each activity." msgid "Add all tags as hashtags to the end of each activity."
msgstr "" msgstr ""
#: templates/settings-page.php:73 #: templates/settings.php:77
msgid "All profile related settings."
msgstr ""
#: templates/settings-page.php:79
msgid "Followers"
msgstr ""
#: templates/settings-page.php:81
msgid "All follower related settings."
msgstr ""
#: templates/settings-page.php:87
msgid "List of followers"
msgstr ""
#: templates/settings-page.php:97
msgid "No followers yet"
msgstr ""
#: templates/settings-page.php:112
msgid "" msgid ""
"If you like this plugin, what about a small <a " "If you like this plugin, what about a small <a "
"href=\"https://notiz.blog/donate\">donation</a>?" "href=\"https://notiz.blog/donate\">donation</a>?"

View file

@ -4,7 +4,7 @@ Donate link: https://notiz.blog/donate/
Tags: OStatus, fediverse, activitypub, activitystream Tags: OStatus, fediverse, activitypub, activitystream
Requires at least: 4.7 Requires at least: 4.7
Tested up to: 5.2.2 Tested up to: 5.2.2
Stable tag: 0.7.3 Stable tag: 0.8.0
Requires PHP: 5.6 Requires PHP: 5.6
License: MIT License: MIT
License URI: http://opensource.org/licenses/MIT License URI: http://opensource.org/licenses/MIT
@ -84,6 +84,10 @@ Where 'blog' is the path to the subdirectory at which your blog resides.
Project maintained on GitHub at [pfefferle/wordpress-activitypub](https://github.com/pfefferle/wordpress-activitypub). Project maintained on GitHub at [pfefferle/wordpress-activitypub](https://github.com/pfefferle/wordpress-activitypub).
= 0.8.0 =
* Moved followers list to user-menu
= 0.7.4 = = 0.7.4 =
* added admin_email to metadata, to be able to "Manage your instance" on https://fediverse.network/manage/ * added admin_email to metadata, to be able to "Manage your instance" on https://fediverse.network/manage/

View file

@ -0,0 +1,15 @@
<div class="wrap">
<h1><?php esc_html_e( 'Followers (Fediverse)', 'activitypub' ); ?></h1>
<p><?php printf( __( 'You currently have %s followers.', 'activitypub' ), esc_attr( \Activitypub\Db\Followers::count_followers( get_current_user_id() ) ) ); ?></p>
<?php $token_table = new \Activitypub\Table\Followers_List(); ?>
<form method="get">
<input type="hidden" name="page" value="indieauth_user_token" />
<?php
$token_table->prepare_items();
$token_table->display();
?>
</form>
</div>

View file

@ -68,41 +68,6 @@
<?php do_settings_fields( 'activitypub', 'activity' ); ?> <?php do_settings_fields( 'activitypub', 'activity' ); ?>
<h2><?php esc_html_e( 'Profile', 'activitypub' ); ?></h2>
<p><?php esc_html_e( 'All profile related settings.', 'activitypub' ); ?></p>
<?php \Activitypub\get_identifier_settings( get_current_user_id() ); ?>
<?php do_settings_fields( 'activitypub', 'profile' ); ?>
<h2><?php esc_html_e( 'Followers', 'activitypub' ); ?></h2>
<p><?php esc_html_e( 'All follower related settings.', 'activitypub' ); ?></p>
<table class="form-table">
<tbody>
<tr>
<th scope="row">
<label><?php esc_html_e( 'List of followers', 'activitypub' ); ?></label>
</th>
<td>
<?php if ( \Activitypub\Db\Followers::get_followers( get_current_user_id() ) ) { ?>
<ul>
<?php foreach ( \Activitypub\Db\Followers::get_followers( get_current_user_id() ) as $follower ) { ?>
<li><?php echo esc_attr( $follower ); ?></li>
<?php } ?>
</ul>
<?php } else { ?>
<p><?php esc_html_e( 'No followers yet', 'activitypub' ); ?></p>
<?php } ?>
</td>
</tr>
</tbody>
</table>
<?php do_settings_fields( 'activitypub', 'followers' ); ?>
<?php do_settings_sections( 'activitypub' ); ?> <?php do_settings_sections( 'activitypub' ); ?>
<?php submit_button(); ?> <?php submit_button(); ?>