diff options
| author | Jakob L. Kreuze <zerodaysfordays@sdf.org> | 2020-07-27 16:51:04 -0400 |
|---|---|---|
| committer | Jakob L. Kreuze <zerodaysfordays@sdf.org> | 2020-07-27 16:53:31 -0400 |
| commit | 14e694641a6656744429a9fc826003329b6651fe (patch) | |
| tree | 795c7a3ae2420079dd22918a45ee78a41c152f95 | |
| parent | 8c9c6ea907eb19f913708aa9cd315d580bc7cbbd (diff) | |
[webmention.js] Handle missing information better.
| -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", |