mirror of
https://git.feneas.org/mediaformat/fediembedi
synced 2025-02-02 04:07:08 +01:00
Renamed class and constants names
Reorganized file structure
This commit is contained in:
parent
3bd36afe83
commit
74c6fd0a31
301
assets/peertube.css
Normal file
301
assets/peertube.css
Normal file
@ -0,0 +1,301 @@
|
||||
/* .scrollable {
|
||||
contain: strict;
|
||||
} */
|
||||
.scrollable {
|
||||
overflow-y: scroll;
|
||||
overflow-x: hidden;
|
||||
flex: 1 1 auto;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
will-change: transform;
|
||||
}
|
||||
|
||||
.status {
|
||||
padding: 8px 10px 8px 68px;
|
||||
position: relative;
|
||||
min-height: 54px;
|
||||
border-bottom: 1px solid #c0cdd9;
|
||||
cursor: default;
|
||||
opacity: 1;
|
||||
-webkit-animation: fade .15s linear;
|
||||
animation: fade .15s linear;
|
||||
}
|
||||
.status__prepend {
|
||||
margin-left: 68px;
|
||||
color: #444b5d;
|
||||
padding: 8px 0 2px;
|
||||
font-size: 14px;
|
||||
position: relative;
|
||||
}
|
||||
.status__prepend-icon-wrapper {
|
||||
left: -26px;
|
||||
position: absolute;
|
||||
}
|
||||
.fa-fw {
|
||||
width: 1.28571429em;
|
||||
text-align: center;
|
||||
}
|
||||
.fa {
|
||||
display: inline-block;
|
||||
|
||||
}
|
||||
.account__header {
|
||||
overflow: hidden;
|
||||
}
|
||||
.account__header__image {
|
||||
overflow: hidden;
|
||||
height: 145px;
|
||||
position: relative;
|
||||
background: #e6ebf0;
|
||||
}
|
||||
.account__header__info {
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
left: 10px;
|
||||
}
|
||||
.account__header__image img {
|
||||
object-fit: cover;
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
}
|
||||
.account__header__bar {
|
||||
position: relative;
|
||||
background: #fff;
|
||||
padding: 5px;
|
||||
border-bottom: 1px solid #b3c3d1;
|
||||
}
|
||||
.account__header__tabs {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
padding: 7px 5px;
|
||||
margin-top: -55px;
|
||||
}
|
||||
.account__header__bar .avatar {
|
||||
display: block;
|
||||
flex: 0 0 auto;
|
||||
width: 94px;
|
||||
margin-left: -2px;
|
||||
}
|
||||
.account__header__tabs .spacer {
|
||||
flex: 1 1 auto;
|
||||
}
|
||||
.account__header__tabs__buttons .button {
|
||||
margin: 0 8px;
|
||||
color: #fff;
|
||||
border-radius: 4px;
|
||||
padding: 0px 16px;
|
||||
height: 36px;
|
||||
line-height: 36px;
|
||||
}
|
||||
.account__header__tabs__name {
|
||||
padding: 5px;
|
||||
}
|
||||
.account__header__tabs__name h1 {
|
||||
font-size: 16px;
|
||||
line-height: 24px;
|
||||
color: #000;
|
||||
font-weight: 500;
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.account__header__tabs__name h1 small {
|
||||
display: block;
|
||||
font-size: 14px;
|
||||
color: #282c37;
|
||||
font-weight: 400;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.account__header__extra {
|
||||
margin-top: 4px;
|
||||
}
|
||||
.account__header__bio {
|
||||
overflow: hidden;
|
||||
margin: 0 -5px;
|
||||
}
|
||||
.account__header__bio .account__header__content {
|
||||
padding: 20px 15px 5px;
|
||||
color: #000;
|
||||
}
|
||||
.account__header__content {
|
||||
color: #282c37;
|
||||
font-size: 14px;
|
||||
font-weight: 400;
|
||||
overflow: hidden;
|
||||
word-break: normal;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
.account__display-name,
|
||||
.detailed-status__application,
|
||||
.detailed-status__datetime,
|
||||
.detailed-status__display-name,
|
||||
.status__display-name,
|
||||
.status__relative-time {
|
||||
text-decoration: none;
|
||||
}
|
||||
.status__display-name {
|
||||
color: #444b5d;
|
||||
}
|
||||
.status__expand {
|
||||
width: 68px;
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
height: 100%;
|
||||
cursor: pointer;
|
||||
}
|
||||
.status__info {
|
||||
font-size: 15px;
|
||||
}
|
||||
.status__info .status__display-name {
|
||||
display: block;
|
||||
max-width: 100%;
|
||||
padding-right: 25px;
|
||||
}
|
||||
.status__avatar {
|
||||
height: 48px;
|
||||
left: 10px;
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
width: 48px;
|
||||
}
|
||||
.account__avatar {
|
||||
border-radius: 4px;
|
||||
background: transparent no-repeat;
|
||||
background-position: 50%;
|
||||
background-clip: padding-box;
|
||||
position: relative;
|
||||
}
|
||||
.account__avatar-overlay {
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
background-size: 48px 48px;
|
||||
}
|
||||
.account__avatar-overlay-base {
|
||||
border-radius: 4px;
|
||||
background: transparent no-repeat;
|
||||
background-position: 50%;
|
||||
background-clip: padding-box;
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
background-size: 36px 36px;
|
||||
}
|
||||
.account__avatar-overlay-overlay {
|
||||
border-radius: 4px;
|
||||
background: transparent no-repeat;
|
||||
background-position: 50%;
|
||||
background-clip: padding-box;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
background-size: 24px 24px;
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
z-index: 1;
|
||||
}
|
||||
.display-name {
|
||||
display: block;
|
||||
max-width: 100%;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.display-name__account {
|
||||
font-size: 14px;
|
||||
}
|
||||
.account__display-name strong, .status__display-name strong {
|
||||
color: #000;
|
||||
}
|
||||
.display-name__html {
|
||||
font-weight: 500;
|
||||
}
|
||||
.notification__relative_time, .status__relative-time {
|
||||
color: #444b5d;
|
||||
float: right;
|
||||
font-size: 14px;
|
||||
}
|
||||
.status-card.compact {
|
||||
border-color: #ccd7e0;
|
||||
}
|
||||
.status-card {
|
||||
display: flex;
|
||||
font-size: 14px;
|
||||
border: 1px solid #c0cdd9;
|
||||
border-radius: 4px;
|
||||
color: #444b5d;
|
||||
margin-top: 14px;
|
||||
text-decoration: none;
|
||||
overflow: hidden;
|
||||
cursor: pointer;
|
||||
}
|
||||
.status-card.compact .status-card__image {
|
||||
flex: 0 0 60px;
|
||||
}
|
||||
.status-card__image {
|
||||
flex: 0 0 100px;
|
||||
background: #c0cdd9;
|
||||
position: relative;
|
||||
}
|
||||
.status-card__image-image {
|
||||
border-radius: 4px 0 0 4px;
|
||||
display: block;
|
||||
margin: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
background-size: cover;
|
||||
background-position: 50%;
|
||||
}
|
||||
.status-card.compact .status-card__content {
|
||||
padding: 10px 8px 8px;
|
||||
}
|
||||
.status-card__content {
|
||||
flex: 1 1 auto;
|
||||
overflow: hidden;
|
||||
padding: 14px 14px 14px 8px;
|
||||
}
|
||||
.status-card__title {
|
||||
display: block;
|
||||
font-weight: 500;
|
||||
margin-bottom: 5px;
|
||||
color: #282c37;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
text-decoration: none;
|
||||
}
|
||||
.status-card__description {
|
||||
color: #282c37;
|
||||
}
|
||||
.status-card__host {
|
||||
display: block;
|
||||
margin-top: 5px;
|
||||
font-size: 13px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.status__content summary {
|
||||
background: #eee;
|
||||
border-radius: 5px;
|
||||
padding: 2px 8px;
|
||||
cursor: pointer;
|
||||
display: inline-block;
|
||||
}
|
||||
.status__content .media-gallery__item{
|
||||
margin: 1em 0;
|
||||
}
|
||||
i.fa-retweet {
|
||||
background-image: url('../img/retoot.svg');
|
||||
background-position: 0 0;
|
||||
height: 19px;
|
||||
vertical-align: middle;
|
||||
width: 22px;
|
||||
color: #ccc;
|
||||
opacity: .75;
|
||||
z-index: 10;
|
||||
position: relative;
|
||||
}
|
@ -3,7 +3,7 @@
|
||||
* The Client class contains all the methods to
|
||||
* connect to your fediverse instance
|
||||
*/
|
||||
class Client
|
||||
class FediClient
|
||||
{
|
||||
private $instance_url;
|
||||
private $access_token;
|
||||
@ -48,6 +48,26 @@ class Client
|
||||
return $this->instance_url.'/oauth/authorize?'.$params;
|
||||
}
|
||||
|
||||
public function register_client($redirect_uri, $scopes = 'read') {
|
||||
|
||||
$response = $this->_get('/api/v1/oauth-clients/local');
|
||||
|
||||
if (!isset($response->client_id)){
|
||||
return "ERROR";
|
||||
}
|
||||
|
||||
$this->app = $response;
|
||||
|
||||
$params = http_build_query(array(
|
||||
'scope' => $scopes,
|
||||
'client_id' =>$this->app->client_id,
|
||||
'client_secret' =>$this->app->client_secret
|
||||
));
|
||||
|
||||
$access_token = $this->_post('/api/v1/oauth-clients/local');
|
||||
// return $this->instance_url.'/users/token?'.$params;
|
||||
}
|
||||
|
||||
public function verify_credentials($access_token){
|
||||
|
||||
$headers = array(
|
||||
@ -76,6 +96,16 @@ class Client
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function get_user_token($client_id, $client_secret) {
|
||||
|
||||
$response = $this->_post('/oauth/token',array(
|
||||
'client_id' => $client_id,
|
||||
'client_secret' => $client_secret,
|
||||
));
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function get_client_id() {
|
||||
return $this->app->client_id;
|
||||
}
|
||||
@ -108,6 +138,44 @@ class Client
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function getVideos($media = 'false', $pinned = 'false', $replies = 'false', $max_id = null, $since_id = null, $min_id = null, $limit = 10, $reblogs = 'false') {
|
||||
|
||||
$headers = array(
|
||||
'Authorization'=> 'Bearer '.$this->access_token
|
||||
);
|
||||
|
||||
$account_id = self::$acct_id;
|
||||
|
||||
// $query = http_build_query(array(
|
||||
// 'only_media' => $media,
|
||||
// 'pinned' => $pinned,
|
||||
// 'exclude_replies' => $replies,
|
||||
// 'max_id' => $max_id,
|
||||
// 'since_id' => $since_id,
|
||||
// 'min_id' => $min_id,
|
||||
// 'limit' => $limit,
|
||||
// 'exclude_reblogs' => $reblogs
|
||||
// ));
|
||||
|
||||
$response = $this->_get("/api/v1/accounts/{$account_id}/videos", null, $headers);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function getTimelineHome() {
|
||||
|
||||
$headers = array(
|
||||
'Authorization'=> 'Bearer '.$this->access_token
|
||||
);
|
||||
|
||||
$account_id = self::$acct_id;
|
||||
|
||||
$response = $this->_get("/api/v1/accounts/{$account_id}/lists", null, $headers);
|
||||
//$response = $this->_get("/api/v1/timelines/home?limit=20", null, $headers);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function getAccount() {
|
||||
|
||||
$headers = array(
|
||||
|
@ -1,6 +1,5 @@
|
||||
<?php
|
||||
define("ACCOUNT_CONNECTED",isset($account) && $account !== null);
|
||||
define("ADVANCED_VIEW",false);
|
||||
define("FEDI_CONNECTED",isset($account) && $account !== null);
|
||||
?>
|
||||
|
||||
|
||||
@ -11,11 +10,11 @@ define("ADVANCED_VIEW",false);
|
||||
<br>
|
||||
<form method="POST">
|
||||
<?php wp_nonce_field( 'fediembedi-configuration' ); ?>
|
||||
<div style="display:<?php echo !ACCOUNT_CONNECTED ? "block":"none"?>">
|
||||
<input type="text" class="widefat instance_url" id="instance" name="instance" size="80" value="<?php esc_attr_e( $instance ); ?>" list="mInstances">
|
||||
<select class="widefat instance_type" id="instance_type" name="instance_type" value="<?php esc_attr_e( $instance_type ); ?>">
|
||||
<option value="Mastodon">Mastodon/Pleroma</option>
|
||||
<option value="Pixelfed">Pixelfed</option>
|
||||
<div style="display:<?php echo !FEDI_CONNECTED ? "block":"none"?>">
|
||||
<input type="text" class="widefat instance_url" id="instance" name="instance" size="80" value="<?php esc_url_raw( $instance, 'https' ); ?>" list="mInstances">
|
||||
<select class="widefat instance_type" id="instance_type" name="instance_type" value="<?php sanitize_key( $instance_type ); ?>">
|
||||
<option value="mastodon">Mastodon/Pleroma</option>
|
||||
<option value="pixelfed">Pixelfed</option>
|
||||
</select>
|
||||
<input class="button button-primary" type="submit" value="<?php esc_attr_e( 'Connect to your instance', 'fediembedi' ); ?>" name="save" id="save">
|
||||
<br><small><?php _e( 'The currently supported software are Mastodon, Pleroma, Pixelfed.', 'fediembedi' ); ?></small><br>
|
||||
@ -23,11 +22,11 @@ define("ADVANCED_VIEW",false);
|
||||
<p><span class="mastodon"></span> Visit <a href="https://joinmastodon.org/" rel="noreferrer noopener" target="_blank" class="">joinmastodon.org</a> to find an instance.</p>
|
||||
<p><span class="pixelfed"></span> Visit <a href="https://pixelfed.org/join" rel="noreferrer noopener" target="_blank" class="">pixelfed.org/join</a> to find an instance.</p>
|
||||
</div>
|
||||
<div style="display:<?php echo ACCOUNT_CONNECTED ? "block" : "none"?>">
|
||||
<div style="display:<?php echo FEDI_CONNECTED ? "block" : "none"?>">
|
||||
<div class="account">
|
||||
<a href="<?php echo $account->url ?>" target="_blank"><img class="m-avatar" src="<?php echo $account->avatar ?>"></a>
|
||||
<div class="details">
|
||||
<?php if(ACCOUNT_CONNECTED): ?>
|
||||
<?php if(FEDI_CONNECTED): ?>
|
||||
<div class="connected"><?php esc_html_e( 'Connected as', 'fediembedi' ); ?> <?php echo $account->username ?></div>
|
||||
<a class="link" href="<?php echo $account->url ?>" target="_blank"><?php echo $account->url ?></a>
|
||||
|
||||
|
@ -31,7 +31,7 @@ class WP_Widget_fediembedi extends WP_Widget {
|
||||
//fedi instance
|
||||
$fedi_instance = get_option('fediembedi-instance');
|
||||
$access_token = get_option('fediembedi-token');
|
||||
$client = new \Client($fedi_instance, $access_token);
|
||||
$client = new \FediClient($fedi_instance, $access_token);
|
||||
$cred = $client->verify_credentials($access_token);
|
||||
//$profile = $client->getAccount();
|
||||
|
||||
@ -44,23 +44,35 @@ class WP_Widget_fediembedi extends WP_Widget {
|
||||
$number = isset( $instance['number'] ) ? absint( $instance['number'] ) : 5;
|
||||
$height = isset( $instance['height'] ) ? esc_attr( $instance['height'] ) : '100%';
|
||||
|
||||
//getStatus from remote instance
|
||||
$status = $client->getStatus($only_media, $pinned, $exclude_replies, null, null, null, $number, $exclude_reblogs);
|
||||
//Instance type (Matodon / Pixelfed / PeerTube)
|
||||
$instance_type = get_option('fediembedi-instance-type');
|
||||
|
||||
//if(WP_DEBUG_DISPLAY === true): echo '<details><summary>'. $instance_type .'</summary><pre>'; var_dump($status); echo '</pre></details>'; endif;
|
||||
|
||||
echo $args['before_widget'];
|
||||
if ( $title ) {
|
||||
echo $args['before_title'] . $title . $args['after_title'];
|
||||
};
|
||||
switch ($instance_type) {
|
||||
case 'Mastodon':
|
||||
include(plugin_dir_path(__FILE__) . 'mastodon/fediembedi-mastodon.tpl.php' );
|
||||
//getStatus from remote instance
|
||||
$status = $client->getStatus($only_media, $pinned, $exclude_replies, null, null, null, $number, $exclude_reblogs);
|
||||
include(plugin_dir_path(__FILE__) . 'templates/mastodon.tpl.php' );
|
||||
break;
|
||||
case 'Pixelfed':
|
||||
include(plugin_dir_path(__FILE__) . 'pixelfed/fediembedi-pixelfed.tpl.php' );
|
||||
//getStatus from remote instance
|
||||
$status = $client->getStatus($only_media, $pinned, $exclude_replies, null, null, null, $number, $exclude_reblogs);
|
||||
//$status = $client->getTimelineHome();
|
||||
include(plugin_dir_path(__FILE__) . 'templates/pixelfed.tpl.php' );
|
||||
break;
|
||||
case 'PeerTube':
|
||||
//getVideos from remote instance
|
||||
$status = $client->getVideos();
|
||||
if(WP_DEBUG_DISPLAY === true): echo '<details><summary>'. $instance_type .'</summary><pre>'; var_dump($status); echo '</pre></details>'; endif;
|
||||
include(plugin_dir_path(__FILE__) . 'templates/peertube.tpl.php' );
|
||||
break;
|
||||
default:
|
||||
include(plugin_dir_path(__FILE__) . 'mastodon/fediembedi-mastodon.tpl.php' );
|
||||
include(plugin_dir_path(__FILE__) . 'templates/mastodon.tpl.php' );
|
||||
break;
|
||||
}
|
||||
echo $args['after_widget'];
|
||||
@ -156,7 +168,7 @@ class WP_Widget_fediembedi extends WP_Widget {
|
||||
<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>Default: 100%</small>
|
||||
<small><?php _e( 'Default: 100%', 'fediembedi' ); ?></small>
|
||||
</label>
|
||||
</p>
|
||||
<?php
|
||||
|
@ -4,7 +4,7 @@
|
||||
* Plugin URI: https://git.feneas.org/mediaformat/fediembedi
|
||||
* Github Plugin URI: https://github.com/mediaformat/fediembedi
|
||||
* Description: A widget to show your Mastodon profile timeline
|
||||
* Version: 0.7.1
|
||||
* Version: 0.7.2
|
||||
* Author: mediaformat
|
||||
* Author URI: https://mediaformat.org
|
||||
* License: GPLv3
|
||||
@ -51,7 +51,7 @@ class FediConfig
|
||||
update_option('fediembedi-token', 'nada');
|
||||
|
||||
$instance = get_option('fediembedi-instance');
|
||||
$client = new \Client($instance);
|
||||
$client = new \FediClient($instance);
|
||||
$token = $client->get_bearer_token($client_id, $client_secret, $code, get_admin_url());
|
||||
//$instance_info = $client->getInstance();
|
||||
|
||||
@ -104,15 +104,15 @@ class FediConfig
|
||||
$instance_type = get_option('fediembedi-instance-type');
|
||||
switch ($instance_type) {
|
||||
case 'Mastodon':
|
||||
wp_enqueue_style( 'mastodon', plugin_dir_url( __FILE__ ) . 'mastodon/mastodon.css', array(), filemtime(plugin_dir_path( __FILE__ ) . 'mastodon/mastodon.css') );
|
||||
wp_enqueue_style( 'mastodon', plugin_dir_url( __FILE__ ) . 'assets/mastodon.css', array(), filemtime(plugin_dir_path( __FILE__ ) . 'assets/mastodon.css') );
|
||||
break;
|
||||
case 'Pixelfed':
|
||||
wp_enqueue_style( 'bootstrap', plugin_dir_url( __FILE__ ) . 'bootstrap/css/bootstrap.min.css', array(), filemtime(plugin_dir_path( __FILE__ ) . 'bootstrap/css/bootstrap.min.css') );
|
||||
wp_enqueue_style( 'pixelfed', plugin_dir_url( __FILE__ ) . 'pixelfed/pixelfed.css', array(), filemtime(plugin_dir_path( __FILE__ ) . 'pixelfed/pixelfed.css') );
|
||||
wp_enqueue_style( 'bootstrap', plugin_dir_url( __FILE__ ) . 'assets/bootstrap/css/bootstrap.min.css', array(), '4.4.1' );
|
||||
wp_enqueue_style( 'pixelfed', plugin_dir_url( __FILE__ ) . 'assets/pixelfed.css', array(), filemtime(plugin_dir_path( __FILE__ ) . 'pixelfed/pixelfed.css') );
|
||||
//https://css-tricks.com/lozad-js-performant-lazy-loading-images/ lazyloading for background images
|
||||
break;
|
||||
default:
|
||||
wp_enqueue_style( 'fediembedi', plugin_dir_url( __FILE__ ) . 'mastodon/mastodon.css', array(), filemtime(plugin_dir_path( __FILE__ ) . 'mastodon/mastodon.css') );
|
||||
wp_enqueue_style( 'fediembedi', plugin_dir_url( __FILE__ ) . 'assets/mastodon.css', array(), filemtime(plugin_dir_path( __FILE__ ) . 'assets/mastodon.css') );
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -164,9 +164,21 @@ class FediConfig
|
||||
$instance_type = esc_attr($_POST['instance_type']);
|
||||
//TODO switch($instance_type) case() return $scopes
|
||||
|
||||
$client = new \Client($instance);
|
||||
$client = new \FediClient($instance);
|
||||
$redirect_url = get_admin_url();
|
||||
$auth_url = $client->register_app($redirect_url);
|
||||
|
||||
$instance_type = get_option('fediembedi-instance-type');
|
||||
switch ($instance_type) {
|
||||
case 'Mastodon':
|
||||
$auth_url = $client->register_app($redirect_url);
|
||||
break;
|
||||
case 'Pixelfed':
|
||||
$auth_url = $client->register_app($redirect_url);
|
||||
break;
|
||||
case 'PeerTube':
|
||||
$auth_url = $client->register_client($redirect_url, 'user');
|
||||
break;
|
||||
}
|
||||
//$auth_url = $client->register_app($redirect_url, $scopes);
|
||||
|
||||
if ($auth_url == "ERROR") {
|
||||
@ -230,7 +242,7 @@ class FediConfig
|
||||
$instance_type = get_option('fediembedi-instance-type');
|
||||
|
||||
if (!empty($token)) {
|
||||
$client = new \Client($instance);
|
||||
$client = new \FediClient($instance);
|
||||
$account = $client->verify_credentials($token);
|
||||
}
|
||||
|
||||
|
1
img/peertube.svg
Normal file
1
img/peertube.svg
Normal file
@ -0,0 +1 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?><svg height="682.68799" viewBox="2799 -911 512 682.688" width="512" xmlns="http://www.w3.org/2000/svg"><g stroke-width="32"><path d="m2799-911v341.344l256-170.656" fill="#211f20"/><path d="m2799-569.656v341.344l256-170.656" fill="#737373"/><path d="m3055-740.344v341.344l256-170.656" fill="#f1680d"/></g></svg>
|
After Width: | Height: | Size: 364 B |
@ -1,6 +1,6 @@
|
||||
# FediEmbedi
|
||||
|
||||
>TLDR; Display your Fediverse timeline in a widget
|
||||
>Display your Fediverse timeline in a widget
|
||||
|
||||
FediEmbedi will display your Mastodon, Pleroma, or Pixelfed timeline in a widget, with various display options.
|
||||
|
||||
@ -87,4 +87,4 @@ and redirected to your site with a secure token. Similar to how you would connec
|
||||
The client connection code is based on [Mastodon Autopost](https://wordpress.org/plugins/autopost-to-mastodon/).
|
||||
|
||||
### FediEmbedi
|
||||
The name FediEmbedi was contributed by [@liaizon@wake.st](https://social.wake.st/@liaizon)
|
||||
The name FediEmbedi was contributed by [wake.st](https://wake.st/@liaizon)
|
||||
|
@ -89,8 +89,8 @@ and redirected to your site with a secure token. Similar to how you would connec
|
||||
|
||||
== Credits ==
|
||||
|
||||
= Mastodon Autopost =
|
||||
* Mastodon Autopost
|
||||
The client connection code is based on [Mastodon Autopost](https://wordpress.org/plugins/autopost-to-mastodon/).
|
||||
|
||||
= FediEmbedi =
|
||||
The name FediEmbedi was contributed by [@liaizon@wake.st](https://social.wake.st/@liaizon).
|
||||
* FediEmbedi
|
||||
The name FediEmbedi was contributed by [wake.st](https://wake.st/).
|
||||
|
12
style.css
12
style.css
@ -206,7 +206,7 @@ html > body .liberapay-btn{
|
||||
vertical-align: middle;
|
||||
}
|
||||
.mastodon {
|
||||
background: url('img/mastodon.svg') no-repeat 3px 4px;
|
||||
background: url('img/mastodon.svg') no-repeat 1px 4px;
|
||||
background-size: 28px;
|
||||
border: none;
|
||||
color: transparent;
|
||||
@ -215,6 +215,16 @@ html > body .liberapay-btn{
|
||||
width: 36px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.peertube {
|
||||
background: url('img/peertube.svg') no-repeat 7px 4px;
|
||||
background-size: 24px;
|
||||
border: none;
|
||||
color: transparent;
|
||||
display: inline-block;
|
||||
height: 36px;
|
||||
width: 36px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.instance_url {
|
||||
max-width: 500px;
|
||||
}
|
||||
|
105
templates/fediembedi-peertube.tpl.php
Normal file
105
templates/fediembedi-peertube.tpl.php
Normal file
@ -0,0 +1,105 @@
|
||||
<!-- mastodon -->
|
||||
<div class="scrollable" style="height: <?php echo $height; ?>;">
|
||||
<div role="feed">
|
||||
<?php if($show_header): ?>
|
||||
<div class="account-timeline__header">
|
||||
<div class="account__header">
|
||||
<div class="account__header__image">
|
||||
<div class="account__header__info"></div>
|
||||
<?php if ($status[0]->account->header): echo "<img src=" . $status[0]->account->header . " loading='lazy'>"; endif; ?>
|
||||
</div>
|
||||
<div class="account__header__bar">
|
||||
<div class="account__header__tabs">
|
||||
<a href="<?php echo $status[0]->account->url; ?>" class="avatar" rel="noreferrer noopener" target="_blank">
|
||||
<div class="account__avatar" style="width:90px; height: 90px; background-image: url('<?php echo $status[0]->account->avatar; ?>'); background-size: cover;"></div>
|
||||
</a>
|
||||
<div class="spacer"></div>
|
||||
<div class="account__header__tabs__buttons">
|
||||
<a href="<?php echo $status[0]->account->url; ?>" rel="noreferrer noopener" class="button logo-button"><?php _e('Follow', 'fediembedi')</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="account__header__tabs__name">
|
||||
<h1>
|
||||
<span><?php echo $status[0]->account->display_name; ?></span>
|
||||
<small><a href="" target="_blank" rel="noreferrer noopener"><?php echo $status[0]->account->url; ?></a></small>
|
||||
</h1>
|
||||
</div>
|
||||
<div class="account__header__extra">
|
||||
<div class="account__header__bio">
|
||||
<div class="account__header__content">
|
||||
<?php echo $status[0]->account->note; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php foreach ($status as $statut) { ?>
|
||||
<article>
|
||||
<div tabindex="-1">
|
||||
<div class="status__wrapper status__wrapper-public focusable" tabindex="0">
|
||||
<div class="status__prepend">
|
||||
<?php
|
||||
if(!is_null($statut->reblog)): ?>
|
||||
<div class="status__prepend-icon-wrapper"><i role="img" class="fa fa-retweet status__prepend-icon fa-fw"></i></div>
|
||||
</div><?php
|
||||
else: echo '</div>';
|
||||
endif; ?>
|
||||
|
||||
<div class="status status-public">
|
||||
<div class="status__info">
|
||||
<a href="<?php if(is_null($statut->reblog)): echo $statut->url; else: echo $statut->reblog->url; endif; ?>" class="status__relative-time" target="_blank" rel="noopener">
|
||||
<time datetime="<?php echo $statut->created_at; ?>"><?php
|
||||
printf( _x( '%1$s ago', '%2$s = human-readable time difference', 'fediembedi' ),
|
||||
human_time_diff(
|
||||
wp_date("U", strtotime($statut->created_at))
|
||||
)
|
||||
);
|
||||
?></time>
|
||||
</a>
|
||||
<a href="<?php if(is_null($statut->reblog)): echo $statut->account->url; else: echo $statut->reblog->account->url; endif; ?>" class="status__display-name" rel="noopener noreferrer" target="_blank">
|
||||
<div class="status__avatar">
|
||||
<div class="account__avatar" style="background-image: url(<?php if(is_null($statut->reblog)): echo $statut->account->avatar; else: echo $statut->reblog->account->avatar; endif; ?>); background-size: 40px; width: 40px; height: 40px;"></div>
|
||||
</div>
|
||||
<span class="display-name"><?php if(is_null($statut->reblog)): echo $statut->account->display_name; else: echo $statut->reblog->account->display_name; endif; ?></span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="status__content"><?php
|
||||
if(!is_null($statut->reblog)):
|
||||
$statut = $statut->reblog;
|
||||
endif;
|
||||
if(empty($statut->spoiler_text)):
|
||||
echo $statut->content;
|
||||
if(!is_null($statut->card)): ?>
|
||||
<a href="<?php echo $statut->card->url; ?>" class="status-card compact" target="_blank" rel="noopener noreferrer">
|
||||
<div class="status-card__image"><div class="status-card__image-image" style="background-image: url(<?php echo $statut->card->image; ?>);"></div></div>
|
||||
<div class="status-card__content">
|
||||
<strong class="status-card__title" title="<?php echo $statut->card->title; ?>"><?php echo htmlentities($statut->card->title); ?></strong>
|
||||
<p class="status-card__description"><?php echo wp_trim_words(htmlentities($statut->card->description)); ?></p>
|
||||
<span class="status-card__host"><?php echo $statut->card->url; ?></span>
|
||||
</div>
|
||||
</a>
|
||||
<?php
|
||||
endif;
|
||||
else: echo '<details><summary>' . $statut->spoiler_text . '</summary>'. $statut->content . '</details>';
|
||||
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;
|
||||
}
|
||||
endif;
|
||||
?></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
Loading…
x
Reference in New Issue
Block a user