From db2bb224c18d25e6c8d1e99364422dc2411b21de Mon Sep 17 00:00:00 2001 From: Django Doucet Date: Tue, 20 Oct 2020 22:55:07 -0400 Subject: [PATCH 1/5] Fix count on peertube widget, add nsfw option --- fediembedi-client.php | 22 ++++++++++++++++++---- fediembedi-peertube-widget.php | 20 +++++++++++++++++--- fediembedi.php | 23 +++++++++++++---------- readme.md | 3 +++ readme.txt | 5 ++++- templates/mastodon.tpl.php | 16 ++++++++-------- templates/peertube.tpl.php | 2 +- templates/pixelfed.tpl.php | 13 +++++++------ 8 files changed, 71 insertions(+), 33 deletions(-) diff --git a/fediembedi-client.php b/fediembedi-client.php index 7c3f26c..e6c5a35 100644 --- a/fediembedi-client.php +++ b/fediembedi-client.php @@ -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..c8be9d1 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'] : false; $height = isset( $instance['height'] ) ? esc_attr( $instance['height'] ) : '100%'; echo $args['before_widget']; @@ -46,13 +47,13 @@ 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(!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 +80,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'] ) : ''; ?> @@ -126,6 +128,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..abd37d9 100644 --- a/readme.md +++ b/readme.md @@ -53,6 +53,9 @@ and redirected to your site with a secure token. Similar to how you would connec ## Changelog +### 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..d61fdd7 100644 --- a/readme.txt +++ b/readme.txt @@ -64,7 +64,10 @@ and redirected to your site with a secure token. Similar to how you would connec == Changelog == -= 0.10.3 = += 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..8114d66 100644 --- a/templates/mastodon.tpl.php +++ b/templates/mastodon.tpl.php @@ -1,5 +1,5 @@ -
+
>
diff --git a/templates/peertube.tpl.php b/templates/peertube.tpl.php index 199e682..d1b7c0e 100644 --- a/templates/peertube.tpl.php +++ b/templates/peertube.tpl.php @@ -1,5 +1,5 @@ -
+
>
diff --git a/templates/pixelfed.tpl.php b/templates/pixelfed.tpl.php index 770b273..508c1db 100644 --- a/templates/pixelfed.tpl.php +++ b/templates/pixelfed.tpl.php @@ -1,5 +1,5 @@ -
+
>
@@ -37,15 +37,16 @@
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 "
@@ -53,7 +54,7 @@
From fe58f3c73f6f8fe9886cad0daa449b5a5bae790b Mon Sep 17 00:00:00 2001 From: Django Doucet Date: Thu, 22 Oct 2020 08:54:25 -0400 Subject: [PATCH 2/5] fix templates --- fediembedi.php | 2 +- templates/mastodon.tpl.php | 3 ++- templates/peertube.tpl.php | 3 ++- templates/pixelfed.tpl.php | 5 +++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/fediembedi.php b/fediembedi.php index 5f82df8..8fda3bb 100644 --- a/fediembedi.php +++ b/fediembedi.php @@ -3,7 +3,7 @@ * Plugin Name: FediEmbedi * Plugin URI: https://git.feneas.org/mediaformat/fediembedi * Description: Widgets and shortcodes to show your Fediverse profile timeline - * Version: 0.10.5 + * Version: 0.10.6 * Author: mediaformat * Author URI: https://mediaformat.org * License: GPLv3 diff --git a/templates/mastodon.tpl.php b/templates/mastodon.tpl.php index 8114d66..9f1ff7e 100644 --- a/templates/mastodon.tpl.php +++ b/templates/mastodon.tpl.php @@ -1,5 +1,5 @@ -
> +
>
+ -
> +
>
@@ -51,3 +51,4 @@
+ -
> +
>
@@ -47,7 +47,7 @@ type === 'video'): ?>
@@ -60,3 +60,4 @@
+ Date: Fri, 23 Oct 2020 14:10:01 -0400 Subject: [PATCH 3/5] templates fixes --- fediembedi.php | 2 +- templates/mastodon.tpl.php | 2 +- templates/peertube.tpl.php | 2 +- templates/pixelfed.tpl.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fediembedi.php b/fediembedi.php index 8fda3bb..c65cb1c 100644 --- a/fediembedi.php +++ b/fediembedi.php @@ -3,7 +3,7 @@ * Plugin Name: FediEmbedi * Plugin URI: https://git.feneas.org/mediaformat/fediembedi * Description: Widgets and shortcodes to show your Fediverse profile timeline - * Version: 0.10.6 + * Version: 0.10.7 * Author: mediaformat * Author URI: https://mediaformat.org * License: GPLv3 diff --git a/templates/mastodon.tpl.php b/templates/mastodon.tpl.php index 9f1ff7e..6101436 100644 --- a/templates/mastodon.tpl.php +++ b/templates/mastodon.tpl.php @@ -1,5 +1,5 @@ -
> +
>