Commit a3b09615 authored by Thomas's avatar Thomas
Browse files

Fixes issue with peertube videos + add a donate tab

parent 2f791f29
......@@ -10,3 +10,17 @@
#mastodon_comments_help li{
list-style: square outside none;
}
.blockquote_mastodon_comments {
font-family: Georgia, serif;
font-size: 16px;
margin: 0.25em 0;
padding: 0.25em 40px;
line-height: 1.45;
position: relative;
color: #282c37;
border-left:5px solid #9baec8;
background:#d9e1e8;
}
<?php
/**
* Created by PhpStorm.
* User: Thomas
* Date: 02/10/2018
* Time: 18:55
*/
defined('ABSPATH') or die("No script kiddies please!");
global $active_tab;
?>
<h2 class="nav-tab-wrapper"><?php _e('Donate', $this->plugin_name);?></h2>
<p>
<p class="notice notice-success notice-large">
<?php _e('If you like my work you can contribute with a small donation. It will help me to pay server charges and everything related to the development.', $this->plugin_name);?>
</p>
<p style="text-align: center;"><strong> <?php _e('Thank you!', $this->plugin_name);?></strong></p>
<center><table class="widefat fixed" style="text-align: center;" cellspacing="0">
<tbody>
<tr>
<th style="text-align: center;">Paypal.me</th>
<th style="text-align: center;">Liberapay</th>
<th style="text-align: center;">Ko-Fi</th>
</tr>
<tr>
<td>
<p style="text-align: center;"><a href="https://www.paypal.me/Mastalab"><img src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif" alt="Donate" /></a></p>
</td>
<td>
<p style="text-align: center;">
<script src="https://liberapay.com/tom79/widgets/button.js"></script>
<noscript><a href="https://liberapay.com/tom79/donate"><img alt="Donate using Liberapay" src="https://liberapay.com/assets/widgets/donate.svg"></a></noscript>
<br/><br/><img src="https://img.shields.io/liberapay/patrons/tom79.svg?logo=liberapay" />
</p>
</td>
<td><center><script type='text/javascript' src='https://ko-fi.com/widgets/widget_2.js'></script><script type='text/javascript'>kofiwidget2.init('Support Me on Ko-fi', '#46b798', 'D1D4K0HZ');kofiwidget2.draw();</script></center></td>
</tr>
</tbody>
</table>
</center>
</p>
\ No newline at end of file
......@@ -14,15 +14,33 @@ $plugin_data = get_plugin_data( dirname(__FILE__)."/../../../mastodon_comments.p
<h3><?php printf(esc_html__(ucwords($plugin_data['Name']).' v%s', $this->plugin_name), $plugin_data['Version']);?></h3>
<p>
<p class="notice notice-info notice-large">
<?php echo esc_html__("This plugin will display comments from Mastodon Social Network related to the current URL.", $this->plugin_name);?>
<br/>
<?php echo esc_html__("Your instance must support full-text search", $this->plugin_name);?>
</p>
<p >
<?php echo esc_html__("How it works:", $this->plugin_name);?>
<p>
<p class="blockquote_mastodon_comments">
<?php echo esc_html__("How it works?", $this->plugin_name);?>
</p>
<ul id="mastodon_comments_help">
<li><?php echo esc_html__("You need to connect your account, the choice is really important. You should connect an account that published URLs", $this->plugin_name);?></li>
<li><?php echo esc_html__("If you get an error with the authorization code, you can first logout your account on your Mastodon instance.", $this->plugin_name);?></li>
<li><?php echo esc_html__("You need to connect your account, the choice is really important. You should connect an account that publishes URLs", $this->plugin_name);?></li>
<li><?php echo esc_html__("If you get an error with the authorization code, you can first logout your account on your Mastodon instance.", $this->plugin_name);?></li>
<li><?php echo esc_html__("Your Wordpress theme can use a different ID for comments section, you should enter the right one in the settings page", $this->plugin_name);?></li>
<li><?php echo esc_html__("For privacy purposes, only public toots will be displayed", $this->plugin_name);?></li>
</ul>
</p>
<p>
<p class="blockquote_mastodon_comments">
<?php echo esc_html__("Your instance does not support full-text search?", $this->plugin_name);?>
</p>
<ol>
<li><?php echo esc_html__("Create an account on an instance allowing full-text search", $this->plugin_name);?></li>
<li><?php echo esc_html__("With this account follow the main account publishing URLs (it will be easier to find toot)", $this->plugin_name);?></li>
<li><?php echo esc_html__("Use this second account on your Wordpress site", $this->plugin_name);?></li>
<li><?php echo esc_html__("Boost statuses of the main account with the plugin", $this->plugin_name);?></li>
<li><?php echo esc_html__("For older statuses, copy their URL from the main account and paste their URL in the search feature of the second account. You will be able to find and boost them.", $this->plugin_name);?></li>
</ol>
</p>
......@@ -18,6 +18,7 @@ global $active_tab;
<h2 class="nav-tab-wrapper">
<a href="?page=<?php echo $this->plugin_name;?>" class="nav-tab <?php echo $active_tab == 'settings' ? 'nav-tab-active' : ''; ?>"><?php esc_attr_e('Settings', $this->plugin_name);?></a>
<a href="?page=<?php echo $this->plugin_name;?>&tab=help" class="nav-tab <?php echo $active_tab == 'help' ? 'nav-tab-active' : ''; ?>"><?php esc_attr_e('Help', $this->plugin_name);?></a>
<a href="?page=<?php echo $this->plugin_name;?>&tab=donate" class="nav-tab <?php echo $active_tab == 'donate' ? 'nav-tab-active' : ''; ?>"><?php esc_attr_e('Donate', $this->plugin_name);?></a>
</h2>
<div class="wrap">
......@@ -26,5 +27,7 @@ global $active_tab;
include_once('inc/settings.inc.php');
}elseif ($active_tab == "help") {
include_once('inc/help.inc.php');
}elseif ($active_tab == "donate") {
include_once('inc/donate.inc.php');
}?>
</div>
\ No newline at end of file
......@@ -116,7 +116,8 @@ class Mastodon_comments_Public {
@define('ROOTPATH', __DIR__);
require_once(ROOTPATH.'/../Class/Mastodon_api.php');
$MastodonAPI = new Mastodon_api();
$source = isset($_GET['source']) ? $_GET['source'] : '#';
$source = str_replace("embed","watch",$source);
$searchResult = $MastodonAPI->get_content_curl($search);
$resultArray = $searchResult['html']['data'];
$result['stats']['replies'] = $searchResult['html']['total'];
......@@ -138,6 +139,7 @@ class Mastodon_comments_Public {
'reply_to' => null,
'root' => null,
];
$result['stats']['url'] = $source;
}
}
......
......@@ -101,25 +101,25 @@
);
if( params.peertube_comment) {
$(document).ready(function(){
var peertubeComment = jQuery('<div/>', {
id: 'mastodon_comments_peertube'
});
$("iframe").each(function() {
$(this).after($(peertubeComment));
var src= $(this).attr('src');
var regexPeertube = new RegExp('(https?:\\/\\/[\\da-z\\.-]+\\.[a-z\\.]{2,10})\\/videos\\/embed\\/(\\w{8}-\\w{4}-\\w{4}-\\w{4}-\\w{12})$');
var result = src.split(regexPeertube);
if( result.length === 4){
var urlPeertube = result[1] + "/api/v1/videos/" + result[2] + "/comment-threads";
var peertubeComment = jQuery('<div/>');
$(this).after($(peertubeComment));
jQuery.get(
params.ajaxurl,
{
'action': 'mastodon_comments_getcomment_peertube',
'search': urlPeertube,
'source': src,
'mastodon_comments_nonce': params.mastodon_comments_nonce
},
function(data){
var targeted_element = $(peertubeComment);
if( typeof data.stats === "undefined")
return;
var stats = data.stats;
......@@ -145,9 +145,9 @@
comment += "<div class='toot'>" + value.toot + "</div>";
comment += "</div>";
element.append(comment);
$(targeted_element).prepend(element);
$(peertubeComment).prepend(element);
});
$(targeted_element).prepend(element);
$(peertubeComment).prepend(element);
}
);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment