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 0000000..eebf068 Binary files /dev/null and b/themes/poc/static/favicon.png differ 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 {