diff options
| author | Jakob L. Kreuze | 2020-01-11 13:39:11 -0500 |
|---|---|---|
| committer | Jakob L. Kreuze | 2020-01-11 13:39:11 -0500 |
| commit | 801534d78a424be1e36c56f190d22fdece04a9b7 (patch) | |
| tree | c03b72cb2ed592c2425f537e90228c7ec960eda7 /haunt/static/js | |
| parent | 947bdb343180b20aa85eb529764a68a73fdcff9a (diff) | |
Fix IndieWeb primitives.
Diffstat (limited to 'haunt/static/js')
| -rw-r--r-- | haunt/static/js/webmention.js | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/haunt/static/js/webmention.js b/haunt/static/js/webmention.js index d1bb8e8..1c18c6d 100644 --- a/haunt/static/js/webmention.js +++ b/haunt/static/js/webmention.js @@ -18,20 +18,17 @@ */ function buildApiUri() { - const snip = /https?:\/\/.*?\//.exec(window.location.href); - const page = window.location.href.substring(snip[0].length); - - // TODO: Build up from aliases, etc. - const aliases = [page]; - - return Array.concat( - ["https://webmention.io/api/mentions.jf2?"], - aliases.flatMap((alias) => { - const ref = "jakob.space"; - return [ - `target[]=http://${ref}/${alias}`, - `target[]=https://${ref}/${alias}` - ]; + const ref = "jakob.space"; + const slug = /[^\/]*(?=\.html)/.exec(window.location.href); + const endpoints = [ + `http://${ref}/${slug}.html`, + `https://${ref}/${slug}.html`, + `http://${ref}/blog/${slug}.html`, + `https://${ref}/blog/${slug}.html`, + ]; + return ["https://webmention.io/api/mentions.jf2?"].concat( + endpoints.map((endpoint) => { + return `target[]=${endpoint}`; }).join("&") ).join(""); } @@ -75,7 +72,9 @@ function makeComment(comment) { // Create the h-card section. let avatar = element("img", { "class": "u-photo", - "src": comment.author.photo + "src": comment.url.startsWith("https://lobste.rs/") + ? "/static/image/lobsters.png" + : comment.author.photo }); let authorName = element("a", { @@ -101,7 +100,9 @@ function makeComment(comment) { let contentContainer = element("div", { "class": "e-content p-name comment-content", }); - contentContainer.textContent = comment.content.text; + contentContainer.textContent = comment.hasOwnProperty("content") + ? comment.content.text + : "[No Text Provided]"; // Create the metaline section. let time = element("time", { |