further improvements, make more portable
This commit is contained in:
@@ -33,6 +33,11 @@ extensions = [ "hardLineBreak" ]
|
|||||||
Mastodon = "mastodon.social/@mxmehl"
|
Mastodon = "mastodon.social/@mxmehl"
|
||||||
Diaspora = "diasp.eu/u/mxmehl"
|
Diaspora = "diasp.eu/u/mxmehl"
|
||||||
|
|
||||||
|
[params.mastodoncomments]
|
||||||
|
user = "https://mastodon.social/users/mxmehl"
|
||||||
|
regex = '/\/?blog\/\d\d\d\d\/.+$/'
|
||||||
|
contact = "/contact/"
|
||||||
|
|
||||||
## Main Menu
|
## Main Menu
|
||||||
[[menu.main]]
|
[[menu.main]]
|
||||||
name = "start"
|
name = "start"
|
||||||
|
|||||||
@@ -7,8 +7,9 @@
|
|||||||
<div id="comments"></div>
|
<div id="comments"></div>
|
||||||
<div class="clear"></div>
|
<div class="clear"></div>
|
||||||
<div id="reference"></div>
|
<div id="reference"></div>
|
||||||
<!--<p class="reference"><a href="https://mastodon.social/users/bjoern/statuses/{{ .Params.toot }}">Join the discussion on Mastodon!</a></p>-->
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>var MastodonTootId="{{ .Params.toot }}"</script>
|
|
||||||
<script>var RelPermalink="{{ .RelPermalink }}"</script>
|
<script>var RelPermalink="{{ .RelPermalink }}"</script>
|
||||||
|
<script>var MastodonUser="{{ .Site.Params.mastodoncomments.user }}"</script>
|
||||||
|
<script>var BlogRegex="{{ .Site.Params.mastodoncomments.regex }}"</script>
|
||||||
|
<script>var CommentsContact="{{ .Site.Params.mastodoncomments.contact }}"</script>
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ $(document).ready(function() {
|
|||||||
url: "/comments/getcomments.php",
|
url: "/comments/getcomments.php",
|
||||||
type: "get",
|
type: "get",
|
||||||
data: {
|
data: {
|
||||||
search : RelPermalink
|
search : "https://fsfe.org/news/2019/news-20190326-01.html"
|
||||||
},
|
},
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
var stats = data.stats;
|
var stats = data.stats;
|
||||||
|
|||||||
@@ -8,6 +8,12 @@ $search = isset($_GET['search']) ? $_GET['search'] : '';
|
|||||||
/* cache files */
|
/* cache files */
|
||||||
$dbt = "cache-toots.json";
|
$dbt = "cache-toots.json";
|
||||||
|
|
||||||
|
/* Exit if search empty */
|
||||||
|
if (empty($search)) {
|
||||||
|
out("No proper search given");
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
|
||||||
/* MISC FUNCTIONS */
|
/* MISC FUNCTIONS */
|
||||||
function out($data) {
|
function out($data) {
|
||||||
error_log("[getcomments.php] " . print_r($data, TRUE));
|
error_log("[getcomments.php] " . print_r($data, TRUE));
|
||||||
@@ -47,6 +53,7 @@ if (!empty($toots['0']['id'])) {
|
|||||||
} else {
|
} else {
|
||||||
/* if cached toots do not exist, start from oldest toot */
|
/* if cached toots do not exist, start from oldest toot */
|
||||||
$min_id = "0";
|
$min_id = "0";
|
||||||
|
$min_id_cached = "0";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -92,11 +99,12 @@ if ($min_id !== $min_id_cached) {
|
|||||||
/* check if URL from $search exists in $toots */
|
/* check if URL from $search exists in $toots */
|
||||||
// if multiple exist, take the oldest one (highest array position)
|
// if multiple exist, take the oldest one (highest array position)
|
||||||
$id = array_keys(array_column($toots, 'url'), strtolower($search));
|
$id = array_keys(array_column($toots, 'url'), strtolower($search));
|
||||||
|
if (empty($id)) {
|
||||||
|
out("Blog URL \"$search\" has not been found");
|
||||||
|
die();
|
||||||
|
}
|
||||||
$id = $toots[end($id)]['id'];
|
$id = $toots[end($id)]['id'];
|
||||||
// TODO: graceful exit if no toot exists
|
|
||||||
|
|
||||||
|
|
||||||
$id = "102955148581768112"; // TODO test
|
|
||||||
/* Extract comments and stats from toot */
|
/* Extract comments and stats from toot */
|
||||||
$result = ['comments' => [], 'stats' => ['reblogs' => 0, 'favs' => 0, 'replies' => 0, 'url' => '', 'root' => 0]];
|
$result = ['comments' => [], 'stats' => ['reblogs' => 0, 'favs' => 0, 'replies' => 0, 'url' => '', 'root' => 0]];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user