Browse Source

gts comments tweak

master
Jon Kelbie 5 months ago
parent
commit
86ff614fc9
  1. 1
      .gitignore
  2. 5
      config.toml
  3. 21
      layouts/partials/mastodon/mastodon.html
  4. 2
      themes/nipponalba/static/css/style.css

1
.gitignore

@ -1 +1,2 @@
public/
.env

5
config.toml

@ -55,6 +55,11 @@ keywords = ""
favicon = "images/"
pronouns = "he/him/his"
feedSections =["article","note","photo","response"]
[params.comment]
[params.comment.fediverse]
enable=true
host = "gts.kelbie.scot"
user = "jon"
[languages.en.Params]

21
layouts/partials/mastodon/mastodon.html

@ -1,17 +1,17 @@
{{ with .Params.comments }}
<div class="article-content">
<h2>Comments</h2>
<p>You can use your Mastodon account to reply to this <a class="button" href="https://{{ .host }}/@{{ .username }}/statuses/{{ .id }}">post</a>.</p>
<p><button class="button" id="replyButton" href="https://{{ .host }}/@{{ .username }}/statuses/{{ .id }}">Reply</button></p>
<p>You can use your Mastodon account to reply to this <a class="button" href="https://{{ .Site.Params.comment.fediverse.host }}/@{{ .Site.Params.comment.fediverse.user }}/statuses/{{ .Page.Params.comments.id }}">post</a>.</p>
<p><button class="button" id="replyButton" href="https://{{ .Site.Params.comment.fediverse.host }}/@{{ .Site.Params.comment.fediverse.user }}/statuses/{{ .Page.Params.comments.id }}">Reply</button></p>
<dialog id="toot-reply" class="mastodon" data-component="dialog">
<h3>Reply to {{ .username }}'s post</h3>
<h3>Reply to {{ .Site.Params.comment.fediverse.user }}'s post</h3>
<p>
With an account on the Fediverse or Mastodon, you can respond to this post.
Since Mastodon is decentralized, you can use your existing account hosted by another Mastodon server or compatible platform if you don't have an account on this one.
</p>
<p>Copy and paste this URL into the search field of your favourite Fediverse app or the web interface of your Mastodon server.</p>
<div class="copypaste">
<input type="text" readonly="" value="https://{{ .host }}/@{{ .username }}/statuses/{{ .id }}">
<input type="text" readonly="" value="https://{{ .Site.Params.comment.fediverse.host }}/@{{ .Site.Params.comment.fediverse.user }}/statuses/{{ .Page.Params.comments.id }}">
<button class="button" id="copyButton">Copy</button>
<button class="button" id="cancelButton">Close</button>
</div>
@ -27,7 +27,7 @@
});
document.getElementById('copyButton').addEventListener('click', () => {
navigator.clipboard.writeText('https://{{ .host }}/@{{ .username }}/statuses/{{ .id }}');
navigator.clipboard.writeText('https://{{ .Site.Params.comment.fediverse.host }}/@{{ .Site.Params.comment.fediverse.user }}/statuses/{{ .Page.Params.comments.id }}');
});
document.getElementById('cancelButton').addEventListener('click', () => {
@ -57,7 +57,10 @@
document.getElementById("load-comment").addEventListener("click", function() {
document.getElementById("load-comment").innerHTML = "Loading";
fetch('https://{{ .host }}/api/v1/statuses/{{ .id }}/context')
require('dotenv').config();
const key = process.env.API_KEY;
const headers = { 'Authorization': '${key}' }; // auth header with bearer token
fetch('https://{{ .Site.Params.comment.fediverse.host }}/api/v1/statuses/{{ .Page.Params.comments.id }}/context', { headers })
.then(function(response) {
return response.json();
})
@ -68,7 +71,7 @@
document.getElementById('mastodon-comments-list').innerHTML = "";
data['descendants'].forEach(function(reply) {
reply.account.display_name = escapeHtml(reply.account.display_name);
reply.account.reply_class = reply.in_reply_to_id == "{{ .id }}" ? "reply-original" : "reply-child";
reply.account.reply_class = reply.in_reply_to_id == "{{ .Page.Params.comments.id }}" ? "reply-original" : "reply-child";
reply.account.emojis.forEach(emoji => {
reply.account.display_name = reply.account.display_name.replace(`:${emoji.shortcode}:`,
`<img src="${escapeHtml(emoji.static_url)}" alt="Emoji ${emoji.shortcode}" height="20" width="20" />`);
@ -103,4 +106,4 @@
});
</script>
</div>
{{ end }}

2
themes/nipponalba/static/css/style.css

@ -1159,7 +1159,7 @@ hr{
padding:0;
}
#toggle_webmentions:checked + #webmentions_label, #toggle_comments:checked + #comments_label, #toggle_fediverse:checked + #fediverse_label{
#toggle_webmentions:checked - #webmentions_label, #toggle_comments:checked + #comments_label, #toggle_fediverse:checked + #fediverse_label{
font-weight: bold;
}

Loading…
Cancel
Save