diff options
| -rw-r--r-- | haunt/static/image/default-icon.png | bin | 0 -> 2034 bytes | |||
| -rw-r--r-- | haunt/static/js/webmention.js | 28 |
2 files changed, 22 insertions, 6 deletions
diff --git a/haunt/static/image/default-icon.png b/haunt/static/image/default-icon.png Binary files differnew file mode 100644 index 0000000..ffd12bf --- /dev/null +++ b/haunt/static/image/default-icon.png diff --git a/haunt/static/js/webmention.js b/haunt/static/js/webmention.js index 7793d7f..2267da8 100644 --- a/haunt/static/js/webmention.js +++ b/haunt/static/js/webmention.js @@ -74,7 +74,7 @@ function makeComment(comment) { "class": "u-photo", "src": comment.url.startsWith("https://lobste.rs/") ? "/static/image/lobsters.png" - : comment.author.photo + : comment.author.photo || "/static/image/default-icon.png" }); let authorName = element("a", { @@ -100,16 +100,32 @@ function makeComment(comment) { let contentContainer = element("div", { "class": "e-content p-name comment-content", }); - contentContainer.textContent = comment.hasOwnProperty("content") - ? comment.content.text - : "[No Text Provided]"; + + if (comment.hasOwnProperty("content")) { + contentContainer.textContent = comment.content.text; + } else { + let em = element("em", {}); + if (comment.hasOwnProperty("wm-property")) { + if ("repost-of" === comment["wm-property"]) { + em.textContent = "Reposted this!"; + } else if ("like-of" === comment["wm-property"]) { + em.textContent = "Favorited this!"; + } else { + em.textContent = "No text provided :("; + } + } else { + em.textContent = "No text provided :("; + } + contentContainer.appendChild(em); + } // Create the metaline section. + let pubTime = comment.published || comment["wm-received"]; let time = element("time", { "class": "dt-published", - "datetime": comment.published + "datetime": pubTime, }); - time.textContent = (new Date(comment.published)).toString(); + time.textContent = (new Date(pubTime)).toString(); let linkBack = element("a", { "class": "u-url", |