Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
F
FediEmbedi
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
5
Issues
5
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MediaFormat
FediEmbedi
Commits
2a15545b
Commit
2a15545b
authored
Mar 10, 2020
by
MediaFormat
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'release/v0.10.0'
parents
f98980d9
66c2d1f2
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
124 additions
and
20 deletions
+124
-20
assets/mastodon.css
assets/mastodon.css
+3
-0
fediembedi.php
fediembedi.php
+93
-8
readme.md
readme.md
+8
-0
readme.txt
readme.txt
+10
-2
templates/pixelfed.tpl.php
templates/pixelfed.tpl.php
+10
-10
No files found.
assets/mastodon.css
View file @
2a15545b
...
...
@@ -20,6 +20,9 @@
-webkit-animation
:
fade
.15s
linear
;
animation
:
fade
.15s
linear
;
}
.status
.status__content
p
{
font-family
:
inherit
;
}
.status__prepend
{
margin-left
:
68px
;
color
:
#444b5d
;
...
...
fediembedi.php
View file @
2a15545b
...
...
@@ -2,8 +2,8 @@
/**
* Plugin Name: FediEmbedi
* Plugin URI: https://git.feneas.org/mediaformat/fediembedi
* Description:
A widget
to show your Fediverse profile timeline
* Version: 0.
9.3
* Description:
Widgets and shortcodes
to show your Fediverse profile timeline
* Version: 0.
10.0
* Author: mediaformat
* Author URI: https://mediaformat.org
* License: GPLv3
...
...
@@ -21,6 +21,9 @@ class FediConfig
{
add_action
(
'plugins_loaded'
,
array
(
$this
,
'init'
));
add_action
(
'widgets_init'
,
array
(
$this
,
'fediembedi_widget'
));
add_shortcode
(
'mastodon'
,
array
(
$this
,
'mastodon_shortcode'
));
add_shortcode
(
'pixelfed'
,
array
(
$this
,
'pixelfed_shortcode'
));
add_shortcode
(
'peertube'
,
array
(
$this
,
'peertube_shortcode'
));
add_action
(
'admin_enqueue_scripts'
,
array
(
$this
,
'enqueue_scripts'
));
add_action
(
'wp_enqueue_scripts'
,
array
(
$this
,
'enqueue_styles'
));
add_action
(
'admin_menu'
,
array
(
$this
,
'configuration_page'
));
...
...
@@ -125,7 +128,6 @@ class FediConfig
$mastodon_token
=
get_option
(
'fediembedi-mastodon-token'
);
$pixelfed_token
=
get_option
(
'fediembedi-pixelfed-token'
);
}
/*
...
...
@@ -151,6 +153,89 @@ class FediConfig
register_widget
(
'FediEmbedi_PeerTube'
);
}
public
function
mastodon_shortcode
(
$atts
){
//fedi instance
$fedi_instance
=
get_option
(
'fediembedi-mastodon-instance'
);
$access_token
=
get_option
(
'fediembedi-mastodon-token'
);
$client
=
new
\FediClient
(
$fedi_instance
,
$access_token
);
$cred
=
$client
->
verify_credentials
(
$access_token
);
$atts
=
shortcode_atts
(
array
(
'only_media'
=>
false
,
'pinned'
=>
false
,
'exclude_replies'
=>
false
,
'max_id'
=>
null
,
'since_id'
=>
null
,
'min_id'
=>
null
,
'limit'
=>
5
,
'exclude_reblogs'
=>
false
,
'show_header'
=>
true
,
),
$atts
,
'mastodon'
);
//getStatus from remote instance
$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
;
include
(
plugin_dir_path
(
__FILE__
)
.
'templates/mastodon.tpl.php'
);
}
public
function
pixelfed_shortcode
(
$atts
){
//fedi instance
$fedi_instance
=
get_option
(
'fediembedi-pixelfed-instance'
);
$access_token
=
get_option
(
'fediembedi-pixelfed-token'
);
$client
=
new
\FediClient
(
$fedi_instance
,
$access_token
);
$cred
=
$client
->
verify_credentials
(
$access_token
);
$atts
=
shortcode_atts
(
array
(
'only_media'
=>
false
,
'pinned'
=>
false
,
'exclude_replies'
=>
false
,
'max_id'
=>
null
,
'since_id'
=>
null
,
'min_id'
=>
null
,
'limit'
=>
9
,
'exclude_reblogs'
=>
false
,
'show_header'
=>
true
,
),
$atts
,
'pixelfed'
);
//getStatus from remote instance
$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
;
include
(
plugin_dir_path
(
__FILE__
)
.
'templates/pixelfed.tpl.php'
);
}
public
function
peertube_shortcode
(
$atts
){
$atts
=
shortcode_atts
(
array
(
'instance'
=>
null
,
'actor'
=>
null
,
'is_channel'
=>
null
,
'limit'
=>
9
,
'show_header'
=>
true
,
),
$atts
,
'peertube'
);
$client
=
new
\FediClient
(
$atts
[
'instance'
]);
//getVideos from remote instance
$status
=
$client
->
getVideos
(
$atts
[
'actor'
],
$atts
[
'is_channel'
]);
if
(
!
is_null
(
$atts
[
'is_channel'
])){
$account
=
$status
->
data
[
0
]
->
channel
;
}
else
{
$account
=
$status
->
data
[
0
]
->
account
;
}
//if(WP_DEBUG_DISPLAY === true): echo '<details><summary>PeerTube</summary><pre>'; var_dump($status); echo '</pre></details>'; endif;
$show_header
=
$atts
[
'show_header'
];
include
(
plugin_dir_path
(
__FILE__
)
.
'templates/peertube.tpl.php'
);
}
/*
* convert_emoji
*/
public
function
convert_emoji
(
$string
,
$emojis
){
if
(
is_null
(
$emojis
)
||
!
is_array
(
$emojis
)){
return
$string
;
...
...
@@ -164,19 +249,19 @@ class FediConfig
public
function
enqueue_styles
(
$hook
)
{
if
(
is_active_widget
(
false
,
false
,
'mastodon'
)
||
is_active_widget
(
false
,
false
,
'pixelfed'
)
)
{
global
$post
;
if
(
is_active_widget
(
false
,
false
,
'mastodon'
)
||
is_active_widget
(
false
,
false
,
'pixelfed'
)
||
(
is_a
(
$post
,
'WP_Post'
)
&&
(
has_shortcode
(
$post
->
post_content
,
'mastodon'
)
||
has_shortcode
(
$post
->
post_content
,
'pixelfed'
)
)
)
)
{
wp_enqueue_script
(
'resize-sensor'
,
plugin_dir_url
(
__FILE__
)
.
'assets/ResizeSensor.js'
,
array
(),
'css-element-queries-1.2.2'
);
wp_enqueue_script
(
'element-queries'
,
plugin_dir_url
(
__FILE__
)
.
'assets/ElementQueries.js'
,
array
(
'resize-sensor'
),
'css-element-queries-1.2.2'
);
}
if
(
is_active_widget
(
false
,
false
,
'mastodon'
)
)
{
if
(
is_active_widget
(
false
,
false
,
'mastodon'
)
||
(
is_a
(
$post
,
'WP_Post'
)
&&
has_shortcode
(
$post
->
post_content
,
'mastodon'
)
)
)
{
wp_enqueue_style
(
'mastodon'
,
plugin_dir_url
(
__FILE__
)
.
'assets/mastodon.css'
,
array
(),
filemtime
(
plugin_dir_path
(
__FILE__
)
.
'assets/mastodon.css'
)
);
}
if
(
is_active_widget
(
false
,
false
,
'pixelfed'
)
)
{
if
(
is_active_widget
(
false
,
false
,
'pixelfed'
)
||
(
is_a
(
$post
,
'WP_Post'
)
&&
has_shortcode
(
$post
->
post_content
,
'pixelfed'
)
)
)
{
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__
)
.
'assets/pixelfed.css'
)
);
}
if
(
is_active_widget
(
false
,
false
,
'peertube'
)
)
{
if
(
is_active_widget
(
false
,
false
,
'peertube'
)
||
(
is_a
(
$post
,
'WP_Post'
)
&&
has_shortcode
(
$post
->
post_content
,
'peertube'
)
)
)
{
wp_enqueue_style
(
'peertube'
,
plugin_dir_url
(
__FILE__
)
.
'assets/peertube.css'
,
array
(),
filemtime
(
plugin_dir_path
(
__FILE__
)
.
'assets/mastodon.css'
)
);
}
}
...
...
readme.md
View file @
2a15545b
...
...
@@ -4,6 +4,11 @@
FediEmbedi will display your Mastodon, Pleroma, or Pixelfed timeline in a widget, with various display options.
### How to use shortcodes
*
`[mastodon exclude_reblogs="true"]`
*
`[pixelfed limit="6"]`
*
`[peertube instance="https://peertube.social" actor="channel_name" is_channel="true"]`
### Currently supported software
*
[
Mastodon
](
http://joinmastodon.org/
)
*
[
Pleroma
](
https://git.pleroma.social/pleroma
)
...
...
@@ -48,6 +53,9 @@ and redirected to your site with a secure token. Similar to how you would connec
## Changelog
### 0.10.0
*
Service shortcodes
### 0.9.0
*
Emoji support
...
...
readme.txt
View file @
2a15545b
=== Plugin Name ===
Contributors: dj_angola
Donate link: https://paypal.me/MediaFormat
Tags: mastodon, pixelfed, fediverse, activitypub, widget
Tags: mastodon, pixelfed, fediverse, activitypub, widget
, shortcode
Requires at least: 5.1
Tested up to: 5.3.2
Requires PHP: 7.2
...
...
@@ -15,7 +15,12 @@ Display your Fediverse timeline in a widget
> FediEmbedi is beta software.
FediEmbedi will display your Mastodon, Pleroma, or Pixelfed timeline in a widget, with various display options.
FediEmbedi will display your Mastodon, Pleroma, or Pixelfed timeline in a widget or with a shortcode, with various display options.
= How to use shortcodes =
* `[mastodon exclude_reblogs="true"]`
* `[pixelfed limit="6"]`
* `[peertube instance="https://peertube.social" actor="channel_name" is_channel="true"]`
= Currently supported software =
* [Mastodon](http://joinmastodon.org/)
...
...
@@ -59,6 +64,9 @@ and redirected to your site with a secure token. Similar to how you would connec
== Changelog ==
= 0.10.0 =
* Service shortcodes
= 0.9.0 =
* Emoji support
...
...
templates/pixelfed.tpl.php
View file @
2a15545b
...
...
@@ -17,21 +17,21 @@
<div
class=
"pixelfed-body card-body pb-1"
>
<div
class=
"pixelfed-meta d-flex justify-content-between align-items-center"
>
<div
class=
"text-center"
>
<
p
class=
"mb-0 font-weight-bold prettyCount"
>
<?php
echo
$account
->
statuses_count
;
?>
</p
>
<
p
class=
"mb-0 text-muted text-uppercase small font-weight-bold"
>
<?php
_e
(
'Posts'
,
'fediembedi'
);
?>
</p
>
<
div
class=
"mb-0 font-weight-bold prettyCount"
>
<?php
echo
$account
->
statuses_count
;
?>
</div
>
<
div
class=
"mb-0 text-muted text-uppercase small font-weight-bold"
>
<?php
_e
(
'Posts'
,
'fediembedi'
);
?>
</div
>
</div>
<div
class=
"text-center"
>
<
p
class=
"mb-0 font-weight-bold prettyCount"
>
<?php
echo
$account
->
followers_count
;
?>
</p
>
<
p
class=
"mb-0 text-muted text-uppercase small font-weight-bold"
>
<?php
_e
(
'Followers'
,
'fediembedi'
);
?>
</p
>
<
div
class=
"mb-0 font-weight-bold prettyCount"
>
<?php
echo
$account
->
followers_count
;
?>
</div
>
<
div
class=
"mb-0 text-muted text-uppercase small font-weight-bold"
>
<?php
_e
(
'Followers'
,
'fediembedi'
);
?>
</div
>
</div>
<div
class=
"text-center"
>
<
p
class=
"mb-0 font-weight-bold prettyCount"
>
<?php
echo
$account
->
following_count
;
?>
</p
>
<
p
class=
"mb-0 text-muted text-uppercase small font-weight-bold"
>
<?php
_e
(
'Following'
,
'fediembedi'
);
?>
</p
>
<
div
class=
"mb-0 font-weight-bold prettyCount"
>
<?php
echo
$account
->
following_count
;
?>
</div
>
<
div
class=
"mb-0 text-muted text-uppercase small font-weight-bold"
>
<?php
_e
(
'Following'
,
'fediembedi'
);
?>
</div
>
</div>
<div
class=
"text-center"
>
<
p
class=
"mb-0"
>
<
div
class=
"mb-0"
>
<a
href=
"
<?php
echo
$instance_url
.
'/i/intent/follow?user='
.
$account
->
acct
;
?>
"
class=
"pixelfed-follow btn btn-primary btn-sm py-1 px-4 text-uppercase font-weight-bold"
target=
"_blank"
>
<?php
_e
(
'Follow'
,
'fediembedi'
);
?>
</a>
</
p
>
</
div
>
</div>
</div>
<div
class=
"pixelfed-images row mt-4 mb-1 px-1"
>
...
...
@@ -52,9 +52,9 @@
</div>
</div>
<div
class=
"pixelfed-footer card-footer bg-white"
>
<
p
class=
"text-center mb-0"
>
<
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>
</
p
>
</
div
>
</div>
</div>
</div>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment