diff --git a/assets/mastodon.css b/assets/mastodon.css index 6bcdc95..77910b1 100644 --- a/assets/mastodon.css +++ b/assets/mastodon.css @@ -86,8 +86,9 @@ } .account__header__tabs__buttons .button { margin: 0 8px; - color: #fff; + border: 1px solid; border-radius: 4px; + color: #fff; padding: 0px 16px; height: 36px; line-height: 36px; diff --git a/fediembedi-client.php b/fediembedi-client.php index 7c3f26c..d551839 100644 --- a/fediembedi-client.php +++ b/fediembedi-client.php @@ -76,7 +76,7 @@ class FediClient $response = $this->_get('/api/v1/accounts/verify_credentials', null, $headers); - if(property_exists($response, 'id')){ + if(isset($response->id)){ $this->setStatic($response->id); } @@ -138,14 +138,28 @@ class FediClient return $response; } - public function getVideos($account_id, $is_channel) { - + public function getVideos($account_id, $is_channel, $count, $nsfw = false) { + //https://docs.joinpeertube.org/api-rest-reference.html#tag/Video $headers = array(); + $query = http_build_query(array( + //'categoryOneOf' => $categoryID, + 'count' => $count, + //'filter' => $filter, + //'languageOneOf' => $lang, + //'licenceOneOf' => $licence, + 'nsfw' => $nsfw, + //'skipCount' => $skipCount, + //'sort' => $sort, + //'start' => $offset, + //'tagsAllOf' => $tagsAllOf,//videos where all tags are present + //'tagsOneOf' => $tags + )); + if(!is_null($is_channel)){ - $response = $this->_get("/api/v1/video-channels/{$account_id}/videos", null, $headers); + $response = $this->_get("/api/v1/video-channels/{$account_id}/videos?{$query}", null, $headers); } else { - $response = $this->_get("/api/v1/accounts/{$account_id}/videos", null, $headers); + $response = $this->_get("/api/v1/accounts/{$account_id}/videos?{$query}", null, $headers); } return $response; diff --git a/fediembedi-peertube-widget.php b/fediembedi-peertube-widget.php index 5801662..2ee3dac 100644 --- a/fediembedi-peertube-widget.php +++ b/fediembedi-peertube-widget.php @@ -37,7 +37,8 @@ class FediEmbedi_PeerTube extends WP_Widget { //widget options $show_header = (!empty($instance['show_header'])) ? $instance['show_header'] : null; - $number = isset( $instance['number'] ) ? absint( $instance['number'] ) : 5; + $count = isset( $instance['number'] ) ? absint( $instance['number'] ) : 5; + $nsfw = isset( $instance['nsfw'] ) ? $instance['nsfw'] : null; $height = isset( $instance['height'] ) ? esc_attr( $instance['height'] ) : '100%'; echo $args['before_widget']; @@ -46,13 +47,14 @@ class FediEmbedi_PeerTube extends WP_Widget { }; //getVideos from remote instance - $status = $client->getVideos($actor, $is_channel); + $status = $client->getVideos($actor, $is_channel, $count, $nsfw); + if(WP_DEBUG_DISPLAY === true): echo '
PeerTube
'; var_dump($status); echo '
'; endif; if(!is_null($is_channel)){ $account = $status->data[0]->channel; } else { $account = $status->data[0]->account; } - + include(plugin_dir_path(__FILE__) . 'templates/peertube.tpl.php' ); echo $args['after_widget']; @@ -79,6 +81,7 @@ class FediEmbedi_PeerTube extends WP_Widget { $exclude_replies = (!empty($instance['exclude_replies'])) ? $instance['exclude_replies'] : NULL; $exclude_reblogs = (!empty($instance['exclude_reblogs'])) ? $instance['exclude_reblogs'] : NULL; $number = isset( $instance['number'] ) ? absint( $instance['number'] ) : 5; + $nsfw = isset( $instance['nsfw'] ) ? $instance['nsfw'] : false; $height = isset( $instance['height'] ) ? esc_attr( $instance['height'] ) : ''; ?> @@ -98,6 +101,17 @@ class FediEmbedi_PeerTube extends WP_Widget {

+ +

+

-

-

-

@@ -126,6 +129,17 @@ class FediEmbedi_PeerTube extends WP_Widget {

+ +

+

Mastodon
'; var_dump($client->getStatus($atts)); echo '
'; endif; $show_header = $atts['show_header']; - $account = $status[0]->account; - ob_start(); - include(plugin_dir_path(__FILE__) . 'templates/pixelfed.tpl.php' ); - return ob_get_clean(); + if($account = $status[0]->account){ + ob_start(); + include(plugin_dir_path(__FILE__) . 'templates/pixelfed.tpl.php' ); + return ob_get_clean(); + } else { + return; + } } public function peertube_shortcode($atts){ @@ -224,7 +227,7 @@ class FediConfig $client = new \FediClient($atts['instance']); //getVideos from remote instance - $status = $client->getVideos($atts['actor'], $atts['is_channel']); + $status = $client->getVideos($atts['actor'], $atts['is_channel'], $atts['limit'], $atts['nsfw'] ); if(!is_null($atts['is_channel'])){ $account = $status->data[0]->channel; } else { diff --git a/readme.md b/readme.md index 502a78e..1b8779f 100644 --- a/readme.md +++ b/readme.md @@ -53,6 +53,15 @@ and redirected to your site with a secure token. Similar to how you would connec ## Changelog +### 0.11.0 +* Feature: PeerTube widget NSFW option. +* Fix: PeerTube number of posts to display. +* Fix: connection issues. +* Fix: Template issues. + +### 0.10.5 +* Bug fix: Template issues. + ### 0.10.4 * Bug fix: Embed included in post edit screen, causing post save issues. diff --git a/readme.txt b/readme.txt index 412ca6d..ae07c43 100644 --- a/readme.txt +++ b/readme.txt @@ -64,7 +64,16 @@ and redirected to your site with a secure token. Similar to how you would connec == Changelog == -= 0.10.3 = += 0.11.0 = +* Feature: PeerTube widget NSFW option. +* Fix: PeerTube number of posts to display. +* Fix: connection issues. +* Fix: Template issues. + += 0.10.5 = +* Bug fix: Template issues. + += 0.10.4 = * Bug fix: Embed included in post edit screen, causing post save issues = 0.10.3 = diff --git a/templates/mastodon.tpl.php b/templates/mastodon.tpl.php index 5fde702..5d1410d 100644 --- a/templates/mastodon.tpl.php +++ b/templates/mastodon.tpl.php @@ -1,5 +1,5 @@ -
+
>
@@ -112,3 +112,4 @@
+ -
+
>
@@ -51,3 +51,4 @@
+ -
+
>
@@ -37,25 +37,27 @@
media_attachments[0]->preview_url) && $statut->media_attachments[0]->type === 'image'): ?> + $attachment = $statut->media_attachments[0]; + if (!empty($attachment->preview_url) && $attachment->type === 'image'): ?>
-
+
media_attachments[0]->type === 'video'): - echo "
+