Merge branch 'release/v0.11.0'

This commit is contained in:
Django Doucet 2020-10-27 23:35:53 -04:00
commit 6be91f1c1c
9 changed files with 103 additions and 48 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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 '<details><summary>PeerTube</summary><pre>'; var_dump($status); echo '</pre></details>'; 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 {
</label>
</p>
<p>
<label>
<input
type="checkbox"
<?php checked( $instance[ 'channel' ], '1' ); ?>
id="<?php echo $this->get_field_id( 'channel' ); ?>"
name="<?php echo $this->get_field_name('channel'); ?>"
value="1"
/><?php _e( 'This account is a Channel (not a user)', 'fediembedi' ); ?>
</label>
</p>
<p>
<label>
<input
type="checkbox"
@ -106,17 +120,6 @@ class FediEmbedi_PeerTube extends WP_Widget {
name="<?php echo $this->get_field_name('show_header'); ?>"
value="1"
/><?php _e( 'Show header', 'fediembedi' ); ?>
</label>
</p>
<p>
<label>
<input
type="checkbox"
<?php checked( $instance[ 'channel' ], '1' ); ?>
id="<?php echo $this->get_field_id( 'channel' ); ?>"
name="<?php echo $this->get_field_name('channel'); ?>"
value="1"
/><?php _e( 'Is this account a Channel?', 'fediembedi' ); ?>
</label>
</p>
<p>
@ -126,6 +129,17 @@ class FediEmbedi_PeerTube extends WP_Widget {
</label>
</p>
<p>
<label>
<input
type="checkbox"
<?php checked( $instance[ 'nsfw' ], '0' ); ?>
id="<?php echo $this->get_field_id( 'nsfw' ); ?>"
name="<?php echo $this->get_field_name('nsfw'); ?>"
value="0"
/><?php _e( 'Show NSFW videos?', 'fediembedi' ); ?>
</label>
</p>
<p>
<label for="<?php echo $this->get_field_id( 'height' ); ?>"><?php _e( 'Widget height:' ); ?><br>
<input class="" id="<?php echo $this->get_field_id( 'height' ); ?>" name="<?php echo $this->get_field_name( 'height' ); ?>" type="text" value="<?php echo $height; ?>" placeholder="500px" size="5" />
<small><?php _e( 'Default: 100%', 'fediembedi' ); ?></small>
@ -157,6 +171,7 @@ class FediEmbedi_PeerTube extends WP_Widget {
$instance['exclude_replies'] = $new_instance['exclude_replies'];
$instance['exclude_reblogs'] = $new_instance['exclude_reblogs'];
$instance['number'] = (int) $new_instance['number'];
$instance['nsfw'] = $new_instance['nsfw'];
$instance['height'] = sanitize_text_field( $new_instance['height'] );
return $instance;
}

View File

@ -2,15 +2,15 @@
/**
* Plugin Name: FediEmbedi
* Plugin URI: https://git.feneas.org/mediaformat/fediembedi
* GitLab Plugin URI: https://git.feneas.org/mediaformat/fediembedi
* Description: Widgets and shortcodes to show your Fediverse profile timeline
* Version: 0.10.4
* Version: 0.11.0
* Author: mediaformat
* Author URI: https://mediaformat.org
* License: GPLv3
* License URI: https://www.gnu.org/licenses/gpl-3.0.en.html
* Text Domain: fediembedi
* Domain Path: /languages
* Github Plugin URI: https://github.com/mediaformat/fediembedi
*/
namespace FediEmbedi;
require_once 'fediembedi-client.php';
@ -104,13 +104,13 @@ class FediConfig
} else {
switch ($instance_type) {
case 'mastodon':
update_option('fediembedi-mastodon-client-id', '');
update_option('fediembedi-mastodon-client-secret', '');
update_option('fediembedi-mastodon-client-id', $client_id);//
update_option('fediembedi-mastodon-client-secret', $client_secret);//
update_option('fediembedi-mastodon-token', $token->access_token);
break;
case 'pixelfed':
update_option('fediembedi-pixelfed-client-id', '');
update_option('fediembedi-pixelfed-client-secret', '');
update_option('fediembedi-pixelfed-client-id', $client_id);//
update_option('fediembedi-pixelfed-client-secret', $client_secret);//
update_option('fediembedi-pixelfed-token', $token->access_token);
break;
}
@ -205,10 +205,13 @@ class FediConfig
$status = $client->getStatus($atts['only_media'], $atts['pinned'], $atts['exclude_replies'], null, null, null, $atts['limit'], $atts['exclude_reblogs']);
//if(WP_DEBUG_DISPLAY === true): echo '<details><summary>Mastodon</summary><pre>'; var_dump($client->getStatus($atts)); echo '</pre></details>'; 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 {

View File

@ -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.

View File

@ -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 =

View File

@ -1,5 +1,5 @@
<!-- mastodon -->
<div class="scrollable" style="height: <?php echo $height; ?>;">
<div class="scrollable fediembedi-mastodon" <?php if (!empty($height)) : echo 'style="height: $height;"'; endif; ?>>
<div role="feed">
<?php if($show_header): ?>
<div class="account-timeline__header">
@ -95,13 +95,13 @@
endif;
if(!empty($statut->media_attachments)):
foreach ($statut->media_attachments as $attachment) {
if (!empty($attachment->preview_url) && $attachment->type === 'image'):
echo "<img src='" . $attachment->preview_url . "' class='media-gallery__item' alt='" . $attachment->description . "' loading='lazy'>";
elseif($attachment->type === 'video'):
echo "<video src=" . $attachment->url . " controls poster='" . $attachment->preview_url . "' class='media-gallery__item' alt=" . $attachment->description . ">";
elseif($attachment->type === 'audio'):
echo "<audio src=" . $attachment->url . " controls poster='" . $attachment->preview_url . "' class='media-gallery__item' alt=" . $attachment->description . ">";
endif;
if (!empty($attachment->preview_url) && $attachment->type === 'image'): ?>
<img src="<?php echo $attachment->preview_url; ?>" class="media-gallery__item" alt="<?php echo $attachment->description; ?>" loading="lazy">
<?php elseif($attachment->type === 'video'): ?>
<video src="<?php echo $attachment->url; ?>" controls poster="<?php echo $attachment->preview_url; ?>" class='media-gallery__item' alt="<?php echo $attachment->description; ?>">
<?php elseif($attachment->type === 'audio'): ?>
<audio src="<?php echo $attachment->url; ?>" controls poster="<?php echo $attachment->preview_url; ?>" class='media-gallery__item' alt="<?php echo $attachment->description; ?>">
<?php endif;
}
endif;
?></div>
@ -112,3 +112,4 @@
<?php } ?>
</div>
</div>
<?php

View File

@ -1,5 +1,5 @@
<!-- peertube -->
<div class="scrollable" style="height: <?php echo $height; ?>;">
<div class="scrollable fediembedi-peertube" <?php if (!empty($height)) : echo 'style="height: $height;"'; endif; ?>>
<div role="feed">
<?php if($show_header): ?>
<div class="peertube-timeline__header">
@ -51,3 +51,4 @@
</div>
</div>
</div>
<?php

View File

@ -1,5 +1,5 @@
<!-- pixelfed -->
<div class="scrollable" style="height: <?php echo $height; ?>;">
<div class="scrollable fediembedi-pixelfed" <?php if (!empty($height)) : echo 'style="height: $height;"'; endif; ?>>
<div role="feed" class="embed-card pixelfed">
<div class="pixelfed-inner card status-card-embed card-md-rounded-0 border">
<?php if($show_header): ?>
@ -37,25 +37,27 @@
<div class="pixelfed-images row mt-4 mb-1 px-1">
<?php foreach ($status as $statut) { ?>
<article class="col-4 mt-2 px-0"><?php
if (!empty($statut->media_attachments[0]->preview_url) && $statut->media_attachments[0]->type === 'image'): ?>
$attachment = $statut->media_attachments[0];
if (!empty($attachment->preview_url) && $attachment->type === 'image'): ?>
<a href="<?php echo $statut->url; ?>" class="card info-overlay card-md-border-0 px-1 shadow-none" target="_blank" rel="noopener">
<div class="square">
<div style='background-image: url(<?php echo $statut->media_attachments[0]->preview_url; ?>);' class='square-content' alt='<?php $statut->media_attachments[0]->description; ?>'></div>
<div style='background-image: url(<?php echo $attachment->preview_url; ?>);' class='square-content' alt='<?php $attachment->description; ?>'></div>
<div class="info-text-overlay"></div>
</div>
</a><?php
elseif($statut->media_attachments[0]->type === 'video'):
echo "<video src=" . $attachment->url . " controls poster='" . $statut->media_attachments[0]->preview_url . "' class='media-gallery__item' alt=" . $statut->media_attachments[0]->description . ">";
endif; ?>
elseif($attachment->type === 'video'): ?>
<video src="<?php echo $attachment->url; ?>" controls poster="<?php echo $attachment->preview_url; ?>" class='media-gallery__item' alt="<?php echo $attachment->description; ?>">
<?php endif; ?>
</article>
<?php } ?>
</div>
</div>
<div class="pixelfed-footer card-footer bg-white">
<div class="text-center mb-0">
<a href="<?php echo $status[0]->account->url; ?>" class="font-weight-bold" target="_blank" rel="noreferrer noopener"><?php _e('View More Posts', 'fediembedi'); ?></a>
<a href="<?php echo $account->url; ?>" class="font-weight-bold" target="_blank" rel="noreferrer noopener"><?php _e('View More Posts', 'fediembedi'); ?></a>
</div>
</div>
</div>
</div>
</div>
<?php