Skip to content
This repository has been archived by the owner on Mar 7, 2023. It is now read-only.

Commit

Permalink
mastodon compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
pfefferle committed May 13, 2017
1 parent fc4a160 commit 85abf07
Show file tree
Hide file tree
Showing 7 changed files with 115 additions and 23 deletions.
3 changes: 0 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,3 @@ indent_size = 4
[{.jshintrc,*.json,*.yml}]
indent_style = space
indent_size = 2

[{*.txt,wp-config-sample.php}]
end_of_line = crlf
32 changes: 26 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,42 @@
**Tags:** social network, ostatus, federated, bundle, mastodon, gnu, social, gnu-social, status-net
**Requires at least:** 4.5
**Tested up to:** 4.7.4
**Stable tag:** 2.1.0
**Stable tag:** 2.2.0

A bundle of plugins that turn your blog into your private federated social network.

## Description ##

OStatus for Wordpress turns your blog into a federated social network. This means you can share and talk to everyone using the OStatus protocol, including users of Status.net/Identi.ca and Wordpress.com

The Plugin is compatible to Mastodon, gnu.social and Status.NET.
OStatus for Wordpress turns your blog into a federated social network. This means you can share and talk to everyone using the OStatus protocol, including users of Status.net/Identi.ca, gnu.social, Friendica and Mastodon.

For more information about OStatus visit the [OStatus Community Group](https://www.w3.org/community/ostatus/)

This plugin bundles a few other plugins it requires to work, theses are installed automatically unless you have them already installed.

The plugin requires:
Compatibility:

* Mastodon
* [x] Follow blog
* [ ] Follow GNU.social
* [x] Share blog-posts
* [ ] Share GNU.social-posts
* [x] Share GNU.social-comments
* [ ] Share blog-comments
* Mastodon
* [x] Follow blog
* [ ] Follow Mastodon
* [x] Share blog-posts
* [ ] Share Mastodon-posts
* [x] Share Mastodon-comments
* [ ] Share blog-comments
* Friendica
* not tested yet

Plugin requirements:

* the `PubSubHubBub`-plugin: http://wordpress.org/plugins/pubsubhubbub/
* the `host-meta`-plugin: http://wordpress.org/plugins/host-meta/
* the `webfinger`-plugin: http://wordpress.org/plugins/webfinger/
* the `WebFinger`-plugin: http://wordpress.org/plugins/webfinger/
* the `Salmon`-plugin: http://wordpress.org/plugins/salmon/
* the `ActivityStream extension`-plugin: http://wordpress.org/plugins/activitystream-extension/

Expand All @@ -38,6 +55,9 @@ yes please!

## Changelog ##

### 2.2.0 ###
* better compatibility with mastodon

### 2.1.0 ###
* some small tweaks
* added header image support
Expand Down
28 changes: 28 additions & 0 deletions includes/functions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
/**
* check if user has an account (WebFinger)
*
* @param int $user_id
*
* @return boolean
*/
function ostatus_has_acct( $user_id ) {
return (boolean) ostatus_get_acct( $user_id );
}

/**
* Returns the user account (WebFinger)
*
* @param int $user_id
*
* @return string the account or the email
*/
function ostatus_get_acct( $user_id ) {
$user = get_user_by( 'id', $user_id );

if ( $user ) {
return $user->user_login . '@' . parse_url( home_url(), PHP_URL_HOST );
} else {
return '';
}
}
27 changes: 20 additions & 7 deletions ostatus-for-wordpress.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* Author URI: http://notiz.blog/
* License: MIT
* License URI: http://opensource.org/licenses/MIT
* Version: 2.1.0
* Version: 2.2.0
* Text Domain: ostatus-for-wordpress
* Domain Path: /languages
*/
Expand All @@ -26,11 +26,15 @@ class Ostatus {
* Initialize the plugin, registering WordPress hooks.
*/
public static function init() {
require_once dirname( __FILE__ ) . '/includes/functions.php';

add_filter( 'webfinger_user_data', array( 'Ostatus', 'webfinger' ), 10, 3 );
add_filter( 'host_meta', array( 'Ostatus', 'host_meta' ) );

add_action( 'atom_ns', array( 'Ostatus', 'atom_add_poco_namespace' ) );
add_action( 'atom_ns', array( 'Ostatus', 'atom_add_namespaces' ) );
add_action( 'atom_head', array( 'Ostatus', 'atom_add_global_author' ) );
add_action( 'atom_author', array( 'Ostatus', 'atom_add_entry_author' ) );

add_feed( 'ostatus', array( 'Ostatus', 'do_feed_ostatus' ) );
add_action( 'do_feed_ostatus', array( 'Ostatus', 'do_feed_ostatus' ), 10, 1 );

Expand Down Expand Up @@ -108,11 +112,11 @@ public static function pubsubhubbub_feed_urls( $feeds, $post_id ) {
/**
* Added PortableContacts namespace
*/
public static function atom_add_poco_namespace() {
public static function atom_add_namespaces() {
if ( is_author() && is_feed( 'ostatus' ) ) {
echo 'xmlns:poco="http://portablecontacts.net/spec/1.0"' . PHP_EOL;
echo 'xmlns:media="http://purl.org/syndication/atommedia"' . PHP_EOL;
echo 'xmlns:ostatus="http://ostatus.org/schema/1.0"' . PHP_EOL;
echo 'xmlns:poco="http://portablecontacts.net/spec/1.0/"' . PHP_EOL;
echo 'xmlns:media="http://purl.org/syndication/atommedia/"' . PHP_EOL;
echo 'xmlns:ostatus="http://ostatus.org/schema/1.0/"' . PHP_EOL;
}
}

Expand All @@ -121,7 +125,16 @@ public static function atom_add_poco_namespace() {
*/
public static function atom_add_global_author() {
if ( is_author() && is_feed( 'ostatus' ) ) {
load_template( dirname( __FILE__ ) . '/templates/atom-author.php' );
load_template( dirname( __FILE__ ) . '/templates/feed-ostatus-author.php' );
}
}

/**
* Extend entry author of the OStatus Atom feed
*/
public static function atom_add_entry_author() {
if ( is_author() && is_feed( 'ostatus' ) ) {
load_template( dirname( __FILE__ ) . '/templates/feed-ostatus-entry-author.php' );
}
}

Expand Down
33 changes: 27 additions & 6 deletions readme.txt
Original file line number Diff line number Diff line change
@@ -1,27 +1,45 @@
=== OStatus ===
Contributors: pepijndevos, pfefferle
Donate link: http://14101978.de
Tags: social network, ostatus, federated, bundle, mastodon, gnu, social, gnu-social, status-net
Requires at least: 4.5
Tested up to: 4.7.4
Stable tag: 2.1.0
Stable tag: 2.2.0

A bundle of plugins that turn your blog into your private federated social network.

== Description ==

OStatus for Wordpress turns your blog into a federated social network. This means you can share and talk to everyone using the OStatus protocol, including users of Status.net/Identi.ca and Wordpress.com

The Plugin is compatible to Mastodon, gnu.social and Status.NET.
OStatus for Wordpress turns your blog into a federated social network. This means you can share and talk to everyone using the OStatus protocol, including users of Status.net/Identi.ca, gnu.social, Friendica and Mastodon.

For more information about OStatus visit the [OStatus Community Group](https://www.w3.org/community/ostatus/)

This plugin bundles a few other plugins it requires to work, theses are installed automatically unless you have them already installed.

The plugin requires:
Compatibility:

* Mastodon
* [x] Follow blog
* [ ] Follow GNU.social
* [x] Share blog-posts
* [ ] Share GNU.social-posts
* [x] Share GNU.social-comments
* [ ] Share blog-comments
* Mastodon
* [x] Follow blog
* [ ] Follow Mastodon
* [x] Share blog-posts
* [ ] Share Mastodon-posts
* [x] Share Mastodon-comments
* [ ] Share blog-comments
* Friendica
* not tested yet

Plugin requirements:

* the `PubSubHubBub`-plugin: http://wordpress.org/plugins/pubsubhubbub/
* the `host-meta`-plugin: http://wordpress.org/plugins/host-meta/
* the `webfinger`-plugin: http://wordpress.org/plugins/webfinger/
* the `WebFinger`-plugin: http://wordpress.org/plugins/webfinger/
* the `Salmon`-plugin: http://wordpress.org/plugins/salmon/
* the `ActivityStream extension`-plugin: http://wordpress.org/plugins/activitystream-extension/

Expand All @@ -38,6 +56,9 @@ yes please!

== Changelog ==

= 2.2.0 =
* better compatibility with mastodon

= 2.1.0 =
* some small tweaks
* added header image support
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
<author>
<activity:object-type>http://activitystrea.ms/schema/1.0/person</activity:object-type>
<name><?php the_author() ?></name>
<summary type="html"><?php echo esc_html( get_the_author_meta( 'description' ) ); ?></summary>
<uri><?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ), get_the_author_meta( 'user_nicename' ) ) ); ?></uri>
<email><?php echo esc_html( ostatus_get_acct( get_the_author_meta( 'ID' ) ) ); ?></email>
<link rel="alternate" type="text/html" href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ), get_the_author_meta( 'user_nicename' ) ) ); ?>" />
<link rel="avatar" media:width="120" media:height="120" href="<?php echo esc_url( get_avatar_url( get_the_author_meta( 'ID' ), array( 'size' => 120 ) ) ); ?>" />
<?php if ( has_header_image() ) { ?>
<link rel="header" href="<?php echo get_header_image(); ?>" />
<?php } ?>
<poco:preferredUsername><?php the_author_meta( 'login' ); ?></poco:preferredUsername>
<poco:displayName><?php the_author() ?></poco:displayName>
<poco:note><?php echo esc_html( get_the_author_meta( 'description' ) ); ?></poco:note>
<poco:note><?php echo wp_strip_all_tags( get_the_author_meta( 'description' ) ); ?></poco:note>
</author>
11 changes: 11 additions & 0 deletions templates/feed-ostatus-entry-author.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<summary type="html"><?php echo esc_html( get_the_author_meta( 'description' ) ); ?></summary>
<uri><?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ), get_the_author_meta( 'user_nicename' ) ) ); ?></uri>
<email><?php echo esc_html( ostatus_get_acct( get_the_author_meta( 'ID' ) ) ); ?></email>
<link rel="alternate" type="text/html" href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ), get_the_author_meta( 'user_nicename' ) ) ); ?>" />
<link rel="avatar" media:width="120" media:height="120" href="<?php echo esc_url( get_avatar_url( get_the_author_meta( 'ID' ), array( 'size' => 120 ) ) ); ?>" />
<?php if ( has_header_image() ) { ?>
<link rel="header" href="<?php echo get_header_image(); ?>" />
<?php } ?>
<poco:preferredUsername><?php the_author_meta( 'login' ); ?></poco:preferredUsername>
<poco:displayName><?php the_author() ?></poco:displayName>
<poco:note><?php echo wp_strip_all_tags( get_the_author_meta( 'description' ) ); ?></poco:note>

0 comments on commit 85abf07

Please sign in to comment.