From ce3f2cc1c462d6ff2c6e9b7978908256dd5931c3 Mon Sep 17 00:00:00 2001 From: Romain de Laage Date: Mon, 21 Nov 2022 16:48:07 +0100 Subject: [PATCH] Fixes --- config.yaml | 2 +- content/posts/example1/index.md | 4 +-- themes/poc/layouts/_default/single.html | 3 +-- themes/poc/layouts/partials/head.html | 2 +- themes/poc/static/favicon.png | Bin 0 -> 2949 bytes themes/poc/static/fedicomment.js | 32 ++++++++++++++++++------ themes/poc/static/main.css | 1 + 7 files changed, 30 insertions(+), 14 deletions(-) create mode 100644 themes/poc/static/favicon.png diff --git a/config.yaml b/config.yaml index 8a5a769..b94f926 100644 --- a/config.yaml +++ b/config.yaml @@ -1,6 +1,6 @@ baseURL: 'http://example.org/' languageCode: 'en-us' -title: 'My New Hugo Site' +title: 'Fedicomment, a comment system relying on the Fediverse' theme: 'poc' params: mastodonurl: https://framapiaf.org diff --git a/content/posts/example1/index.md b/content/posts/example1/index.md index 5726b89..c6ae096 100644 --- a/content/posts/example1/index.md +++ b/content/posts/example1/index.md @@ -4,6 +4,4 @@ date: 2022-11-21 postid: 109357906602593256 --- -# Example 1 - -test +Click on the button below, this will automatically load comments and counters from the fediverse. diff --git a/themes/poc/layouts/_default/single.html b/themes/poc/layouts/_default/single.html index 6800d59..4dc61cc 100644 --- a/themes/poc/layouts/_default/single.html +++ b/themes/poc/layouts/_default/single.html @@ -1,8 +1,7 @@ {{ define "main" }}
-

{{ if .Params.Title }}

+{{ if .Params.Title }}

{{ .Params.Title }}

{{ end }} {{ .Content }} -{{ end }}
{{ if .Params.postid }} {{ partial "fedicomment.html" . }} diff --git a/themes/poc/layouts/partials/head.html b/themes/poc/layouts/partials/head.html index 386f19e..0459023 100644 --- a/themes/poc/layouts/partials/head.html +++ b/themes/poc/layouts/partials/head.html @@ -3,5 +3,5 @@ - + diff --git a/themes/poc/static/favicon.png b/themes/poc/static/favicon.png new file mode 100644 index 0000000000000000000000000000000000000000..eebf0680b1ee4b8ff74bed0fad5f7adaad5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mXp`G=sOI)t`o^OO0P(?r zNpO|U2QBq3f)9Kyb^{H>_pD{j3-kd1spwDw6^@)Bplj zUt1LJ1G={ST)Z_FxIUmh?+&*b;Kq1{QP5|ph5LZ9{AO^gEMVmQy0rkt!q|n)K(Q_) zWmpBv$1bA}lxYf#oBUsT3*_74)>>dGOL?7enMrQB1qv%gxfPcK;Kul6+6T-~$^lUL ziBzoUxLg*v4NyLS0vBHqEKn>jENBXfu^kq;49hqL#VSSG3IAU$F#pD+JOKY4`+xxr z&k6>n-eXbE%|2-SlA^ygwD6O9Xs=Z*1pokDof9dE v-~$`)_E}d_2tZNF|MppM8{jrTG0J}ckWhE8OMq!900000NkvXXu0mjfeX?nZ literal 0 HcmV?d00001 diff --git a/themes/poc/static/fedicomment.js b/themes/poc/static/fedicomment.js index 557dce8..f9d55a0 100644 --- a/themes/poc/static/fedicomment.js +++ b/themes/poc/static/fedicomment.js @@ -1,5 +1,4 @@ class Fedicomment { - enableButton; container; postod; mastodonurl; @@ -14,22 +13,34 @@ class Fedicomment { this.postid = this.container.dataset.postid; if (typeof this.postid != "string") { console.error("Fedicomment: expected postid"); + + let errorContainer = document.createElement("div"); + errorContainer.innerHTML = "Failed to initialize Fedicomment (see the console for details)"; + errorContainer.classList.add("fedicomment-alert", "fedicomment-error"); + this.container.replaceChildren(errorContainer); + return; } this.mastodonurl = this.container.dataset.mastodonurl; if (typeof this.mastodonurl != "string") { console.error("Fedicomment: expected mastodonurl"); + + let errorContainer = document.createElement("div"); + errorContainer.innerHTML = "Failed to initialize Fedicomment (see the console for details)"; + errorContainer.classList.add("fedicomment-alert", "fedicomment-error"); + this.container.replaceChildren(errorContainer); + return; } - this.enableButton = document.createElement("button"); - this.enableButton.innerHTML = "Enable Fedicomment"; - this.enableButton.onclick = function() { + let enableButton = document.createElement("button"); + enableButton.innerHTML = "Enable Fedicomment"; + enableButton.id = "fedicomment-button"; + enableButton.onclick = function() { fedicomment.enable(); } - - this.container.replaceChildren(this.enableButton); + this.container.replaceChildren(enableButton); console.log("Fedicomment successfully initialized"); } @@ -68,7 +79,14 @@ class Fedicomment { throw "Mastodon instance failed"; } }) - .catch((error) => console.error("Fedicomment: failed to fetch comments:", error)); + .catch((error) => { + let errorContainer = document.createElement("div"); + errorContainer.innerHTML = "Failed to fetch comments (see the console for details)"; + errorContainer.classList.add("fedicomment-alert", "fedicomment-error"); + this.container.replaceChildren(errorContainer); + + console.error("Fedicomment: failed to fetch comments:", error) + }); console.log("Fedicomment: Successfully got comments and reactions"); } diff --git a/themes/poc/static/main.css b/themes/poc/static/main.css index f85cf6e..89bf38f 100644 --- a/themes/poc/static/main.css +++ b/themes/poc/static/main.css @@ -1,6 +1,7 @@ * { margin: 0; box-sizing: border-box; + font-family: sans-serif; } body {