From 24ab2fc5f214a091900e1ae044dcc7df6698ec1d Mon Sep 17 00:00:00 2001 From: trotFunky Date: Thu, 1 Aug 2024 22:42:07 +0100 Subject: [PATCH 1/4] vote_chart: Remove hash part of the URL Now that the truths have anchor links, a user could select one and send the link directly to the truth, or refresh the page to there. However, the local part of the URL would be used by the script to fetch the voting data, which fail as it isn't expected by the server and is, anyway, malformed. Remove the local hash from the URL before requesting the voting data. --- static_files/vote_chart.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/static_files/vote_chart.js b/static_files/vote_chart.js index f82b977..306a01d 100644 --- a/static_files/vote_chart.js +++ b/static_files/vote_chart.js @@ -1,7 +1,9 @@ const limit_ratio = 1.3 const colors = ['#b6b8fc', '#b6f4fc', '#fcb6cc', '#e0fcb6', '#fcdcb6', '#b6fcc8', '#f0b6fc'] async function main() { - const vote_response = await fetch(document.URL+"/votes"); + let current_url = new URL(document.URL) + current_url.hash = '' // Strip the local part of the URL, for example if we select a Truth + const vote_response = await fetch(current_url.toString()+"/votes"); if (!vote_response.ok) { return; } From 322d37ce48d52c3d0c3475a893b3507fc767bf69 Mon Sep 17 00:00:00 2001 From: trotFunky Date: Thu, 1 Aug 2024 22:43:25 +0100 Subject: [PATCH 2/4] templates: Remove the extra / in the anchor link Anchor links do not need an additional / to work : the # can be added directly at the end of the previous URL. Remove it from the existing anchor tags in the truths. --- templates/tags/filtered_truths.html.tera | 2 +- templates/weeks/truth.html.tera | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/tags/filtered_truths.html.tera b/templates/tags/filtered_truths.html.tera index ad2ffb9..cb94d54 100644 --- a/templates/tags/filtered_truths.html.tera +++ b/templates/tags/filtered_truths.html.tera @@ -21,7 +21,7 @@ {% for truth in truths %} {% endfor %} diff --git a/templates/weeks/truth.html.tera b/templates/weeks/truth.html.tera index 5a420e6..5eaa580 100644 --- a/templates/weeks/truth.html.tera +++ b/templates/weeks/truth.html.tera @@ -5,7 +5,7 @@ {%- endif -%}
-

Vérité {{ truth.number }}

+

Vérité {{ truth.number }}

{{ truth.rendered_text | safe }}


From 4d5a423c784424986528cba4e6d373046332f2e4 Mon Sep 17 00:00:00 2001 From: trotFunky Date: Thu, 1 Aug 2024 22:45:40 +0100 Subject: [PATCH 3/4] template: Add anchor link to the editable truths For some reason I did not add the anchor links to the editable truths for the admin users. Add them so that the admin can benefit as well. --- templates/weeks/editable_truth.tera | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/weeks/editable_truth.tera b/templates/weeks/editable_truth.tera index 3c2c968..f546128 100644 --- a/templates/weeks/editable_truth.tera +++ b/templates/weeks/editable_truth.tera @@ -1,5 +1,5 @@
-

Vérité {{ truth.number }}

+

Vérité {{ truth.number }}

{{ truth.rendered_text | safe }}

{% for tag in truth.tags %} From 76de321d4155fb7b2e3104cdb5c51c119f73dc0f Mon Sep 17 00:00:00 2001 From: trotFunky Date: Thu, 1 Aug 2024 22:49:41 +0100 Subject: [PATCH 4/4] templates: Don't show the tagging form if no tags If there are no tags but the form is still shown, the admin could ask to add an empty tag returning an error 422 unprocessable entity. Remove if there are no tags available --- Cargo.lock | 2 +- Cargo.toml | 2 +- templates/weeks/editable_truth.tera | 26 ++++++++++++++------------ 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 58f9b72..b3eece5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -578,7 +578,7 @@ checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" [[package]] name = "fabula_votes_server" -version = "1.4.0" +version = "1.4.1" dependencies = [ "argon2", "blake2", diff --git a/Cargo.toml b/Cargo.toml index ec70a8c..298d596 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ name = "fabula_votes_server" license = "MPL-2.0" readme = "README.md" authors = ["trotFunky"] -version = "1.4.0" +version = "1.4.1" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/templates/weeks/editable_truth.tera b/templates/weeks/editable_truth.tera index f546128..8d75882 100644 --- a/templates/weeks/editable_truth.tera +++ b/templates/weeks/editable_truth.tera @@ -15,16 +15,18 @@
{% include "weeks/truth_editor" %}
-
- - -
+ {% if tags | length > 0 and tags | length > truth.tags | length %} +
+ + +
+ {% endif %}