From 0f9374a08228965c207e0d77fd5adc701a3b461b Mon Sep 17 00:00:00 2001 From: "M. Taylor Saotome-Westlake" Date: Sun, 12 Apr 2020 22:29:02 -0700 Subject: [PATCH] recent comments! --- theme/static/js/recent_comments.js | 36 ++++++++++++++++++++++++++++++ theme/templates/article.html | 1 + theme/templates/base.html | 6 +++++ 3 files changed, 43 insertions(+) create mode 100644 theme/static/js/recent_comments.js diff --git a/theme/static/js/recent_comments.js b/theme/static/js/recent_comments.js new file mode 100644 index 0000000..18ee006 --- /dev/null +++ b/theme/static/js/recent_comments.js @@ -0,0 +1,36 @@ + +function getRecentComments() { + let container = document.querySelector("#recent-comments-container"); + console.log(container); + + let request = new XMLHttpRequest(); + request.open('GET', 'http://unremediatedgender.space/isso/latest?limit=5', true); + + request.onload = function() { + if (this.status >= 200 && this.status < 400) { + let comments = JSON.parse(this.response); + console.log(comments); + for (let comment of comments.reverse()) { + let p = document.createElement('p'); + let a = document.createElement('a'); + let text = document.createTextNode(`${comment.author} on ${comment.uri}`); + a.appendChild(text); + a.href = `${comment.uri}#isso-${comment.id}`; + p.appendChild(a); + container.appendChild(p); + } + } else { + container.textContent = "(could not load recent comments)" + } + }; + + request.onerror = function() { + "(could not load recent comments)" + }; + + request.send(); +} + +document.addEventListener("DOMContentLoaded", function() { + getRecentComments(); +}); diff --git a/theme/templates/article.html b/theme/templates/article.html index fd28b3c..9829434 100644 --- a/theme/templates/article.html +++ b/theme/templates/article.html @@ -37,6 +37,7 @@ data-isso-reply-to-self="true" data-isso-require-author="true" data-isso-require-email="true" + data-isso-feed="true" {# TODO: why doesn't the feed link work?! #} src="//unremediatedgender.space/isso/js/embed.min.js">
diff --git a/theme/templates/base.html b/theme/templates/base.html index 1f607d3..2f1e761 100644 --- a/theme/templates/base.html +++ b/theme/templates/base.html @@ -11,6 +11,7 @@ + {% block scripts %} {% endblock %} @@ -98,6 +99,11 @@ {% endfor %} + + -- 2.17.1