aboutsummaryrefslogtreecommitdiffstats
path: root/static/js/webmention.min.js
diff options
context:
space:
mode:
Diffstat (limited to 'static/js/webmention.min.js')
-rw-r--r--static/js/webmention.min.js196
1 files changed, 0 insertions, 196 deletions
diff --git a/static/js/webmention.min.js b/static/js/webmention.min.js
deleted file mode 100644
index 61f107d..0000000
--- a/static/js/webmention.min.js
+++ /dev/null
@@ -1,196 +0,0 @@
-// @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt
-!(function () {
- "use strict";
- window.i18next = window.i18next || {
- t: function t(e) {
- return e;
- },
- };
- let t = window.i18next.t.bind(window.i18next);
- function e(t, e) {
- return document.currentScript.getAttribute("data-" + t) || e;
- }
- let o = e("page-url", window.location.href.replace(/#.*$/, "")),
- n = e("add-urls", void 0),
- r = e("id", "webmentions"),
- s = e("wordcount"),
- l = e("max-webmentions", 30),
- i = e("prevent-spoofing") ? "wm-source" : "url",
- a = e("sort-by", "published"),
- u = e("sort-dir", "up"),
- p = e("comments-are-reactions", !1),
- c = {
- "in-reply-to": t("replied"),
- "like-of": t("liked"),
- "repost-of": t("reposted"),
- "bookmark-of": t("bookmarked"),
- "mention-of": t("mentioned"),
- rsvp: t("RSVPed"),
- "follow-of": t("followed"),
- },
- f = {
- "in-reply-to": "\uD83D\uDCAC",
- "like-of": "❤️",
- "repost-of": "\uD83D\uDD04",
- "bookmark-of": "⭐️",
- "mention-of": "\uD83D\uDCAC",
- rsvp: "\uD83D\uDCC5",
- "follow-of": "\uD83D\uDC1C",
- },
- m = {
- yes: "✅",
- no: "❌",
- interested: "\uD83D\uDCA1",
- maybe: "\uD83D\uDCAD",
- };
- function d(t) {
- return t.replace(
- /[&<>"]/g,
- (t) =>
- ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;" })[
- t
- ] || t,
- );
- }
- function h(e, o) {
- let n = d(e.author?.name || e.url.split("/")[2]),
- r = c[e["wm-property"]] || t("reacted");
- !o && e.content && e.content.text && (r += ": " + x(e));
- let s = "";
- s =
- e.author && e.author.photo
- ? `
- <img
- src="${d(e.author.photo)}"
- loading="lazy"
- decoding="async"
- alt="${n}"
- >
- `
- : `
- <img
- class="missing"
- src="data:image/webp;base64,UklGRkoCAABXRUJQVlA4TD4CAAAvP8APAIV0WduUOLr/m/iqY6SokDJSMD5xYX23SQizRsVdZmIj/f6goYUbiOj/BED7MOPReuBNT3vBesSzIex+SeqMFFkjebFmzH3S7POxDSJ1yaCbCmMnS2R46cRMPyQLw4GBK4esdK60pYwsZakecUCl5zsHv/5cPH08nx9/7i6rEEVCg2hR8VSd30PxMZpVoJZQO6Dixgg6X5oKFCmlVHIDmmMFShWumAXgCuyqVN8hHff/k+9fj8+ei7BVjpxBmZCUJv+6DhWGZwWvs+UoLHFCKsPYpfJtIcEXBTopEEsKwedZUv4ku1FZErKULLyQwFGgnmTs2vBD5qu44xwnG9uyjgrFOd+KRVlXyQfwQlauydaU6AVI7OjKXLUEqNtxJBmQegNDZgV7lxxqYMOMrDyC1NdAGbdiH9Ij0skjG+oTyfO0lmjdgvoH8iIgreuBMRYLSH+R3sAztXgL+XfS7E2bmfo6gnS0TrpnzHT7kL+skj7PgHuBwv/zpN8LDLQg7zfJZLBubMKnyeh6ZGyfDEfc2LYpnlUtG7JqsSHq1WoASbUS4KVaLwB8be5mfsGMDwBcm5VxbuxWxx3nkFanB6lYqsqSkOGkKicoDvXsneR7BkKU7DtaEuT7+pxBGVwx+9gVyqf2pVA9sC2CsmjZ1RJqEJHS4Tj/pCcS0JoyBYOsB91Xjh3OFfQPQhvCAYyeLJlaOoFp0XNNuD0BC8exr8uPx7D1JWkwFdZIXmD3MOPReuDNzHjBesSzIbQD"
- alt="${n}$"
- >
- `;
- let l = "";
- return (
- e.rsvp && m[e.rsvp] && (l = `<sub>${m[e.rsvp]}</sub>`),
- `
- <a
- class="reaction"
- rel="nofollow ugc"
- title="${n} ${r}"
- href="${e[i]}"
- >
- ${s}
- ${f[e["wm-property"]] || "\uD83D\uDCA5"}
- ${l}
- </a>
- `
- );
- }
- function g(t) {
- return t.substr(t.indexOf("//"));
- }
- function w(t) {
- let e = [],
- o = {};
- return (
- t.forEach(function (t) {
- let n = g(t.url);
- o[n] || (e.push(t), (o[n] = !0));
- }),
- e
- );
- }
- function x(t) {
- let e = d(t.content.text);
- if (s) {
- let o = e.replace(/\s+/g, " ").split(" ", s + 1);
- o.length > s &&
- ((o[s - 1] += "&hellip;"), (e = (o = o.slice(0, s)).join(" ")));
- }
- return e;
- }
- window.addEventListener("load", async function () {
- let e = document.getElementById(r);
- if (!e) return;
- let s = [g(o)];
- n &&
- n.split("|").forEach(function (t) {
- s.push(g(t));
- });
- let c = `https://webmention.io/api/mentions.jf2?per-page=${l}&sort-by=${a}&sort-dir=${u}`;
- s.forEach(function (t) {
- c += `&target[]=${encodeURIComponent("http:" + t)}&target[]=${encodeURIComponent("https:" + t)}`;
- });
- let f = {};
- try {
- let m = await window.fetch(c);
- m.status >= 200 && m.status < 300
- ? (f = await m.json())
- : (console.error("Could not parse response"),
- Error(m.statusText));
- } catch (y) {
- console.error("Request failed", y);
- }
- let b = [],
- k = [];
- p && (b = k);
- let B = {
- "in-reply-to": b,
- "like-of": k,
- "repost-of": k,
- "bookmark-of": k,
- "follow-of": k,
- "mention-of": b,
- rsvp: b,
- };
- f.children.forEach(function (t) {
- let e = B[t["wm-property"]];
- e && e.push(t);
- });
- let S = "";
- b.length > 0 &&
- b !== k &&
- (S = (function e(o) {
- let n = `<h2>${t("Responses")}</h2>`,
- r = o
- .map((e) => {
- let o = h(e, !0),
- n = d(e.url.split("/")[2]);
- e.author && e.author.name && (n = d(e.author.name));
- let r = `<a class="source" rel="nofollow ugc" href="${e[i]}">${n}</a>`,
- s = "name",
- l = `(${t("mention")})`;
- e.name
- ? ((s = "name"), (l = d(e.name)))
- : e.content &&
- e.content.text &&
- ((s = "text"), (l = x(e)));
- let a = `<span class="${s}">${l}</span>`;
- return `<li>${o} ${r} ${a}</li>`;
- })
- .join("");
- return `
- ${n}
- <ul class="comments">${r}</ul>
- `;
- })(w(b)));
- let D = "";
- k.length > 0 &&
- (D = (function e(o) {
- let n = `<h2>${t("Reactions")}</h2>`,
- r = o.map((t) => h(t)).join("");
- return `
- ${n}
- <ul class="reacts">${r}</ul>
- `;
- })(w(k)));
- let $ = `${S}${D}`;
- ($.trim() || ($ = '<p class="wm-empty">暂无 Webmention 回应。</p>'),
- (e.innerHTML = $));
- });
-})(); // @license-end