further improvements, make more portable
This commit is contained in:
@@ -7,8 +7,9 @@
|
||||
<div id="comments"></div>
|
||||
<div class="clear"></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>
|
||||
|
||||
<script>var MastodonTootId="{{ .Params.toot }}"</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",
|
||||
type: "get",
|
||||
data: {
|
||||
search : RelPermalink
|
||||
search : "https://fsfe.org/news/2019/news-20190326-01.html"
|
||||
},
|
||||
success: function(data) {
|
||||
var stats = data.stats;
|
||||
|
||||
@@ -8,6 +8,12 @@ $search = isset($_GET['search']) ? $_GET['search'] : '';
|
||||
/* cache files */
|
||||
$dbt = "cache-toots.json";
|
||||
|
||||
/* Exit if search empty */
|
||||
if (empty($search)) {
|
||||
out("No proper search given");
|
||||
die();
|
||||
}
|
||||
|
||||
/* MISC FUNCTIONS */
|
||||
function out($data) {
|
||||
error_log("[getcomments.php] " . print_r($data, TRUE));
|
||||
@@ -47,6 +53,7 @@ if (!empty($toots['0']['id'])) {
|
||||
} else {
|
||||
/* if cached toots do not exist, start from oldest toot */
|
||||
$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 */
|
||||
// if multiple exist, take the oldest one (highest array position)
|
||||
$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'];
|
||||
// TODO: graceful exit if no toot exists
|
||||
|
||||
|
||||
$id = "102955148581768112"; // TODO test
|
||||
/* Extract comments and stats from toot */
|
||||
$result = ['comments' => [], 'stats' => ['reblogs' => 0, 'favs' => 0, 'replies' => 0, 'url' => '', 'root' => 0]];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user