Commit graph

42 commits

Author SHA1 Message Date
322d37ce48 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.
2024-08-01 22:43:25 +01:00
24ab2fc5f2 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.
2024-08-01 22:42:07 +01:00
19898e1b09 tag: Introduce tag system
Create a new table representing tags, composed of a name and color.
They can be used to tag truths and filter them later.
Tags display under the truths they correspond to and can be clicked
to access all truths matching this tag.

Introduce a new element in the top bar to allow navigating to the
tag list, which can be used to create and edit tags for the admin
and used to select a list of tags to filter against for everyone.

Update the database records of the truths to include the tag vector.
As the database query result is a multi-row result, it cannot be
parsed automatically so it needs to be skipped and retrieved
manually.
2024-08-01 21:55:47 +01:00
d79375365d style: Update top bar
Style the topbar to make it more useful in the future.
Style the login element to make the form vertical and
properly aligned, in order for it to fit well on both
desktop and mobile.

Small adjustment to the truth editor style to space it
out a little bit.
2024-08-01 20:23:18 +01:00
fb115e1bba README: Add forgotten frontend dependency
I only added the Rust dependencies to the README, but we do have one
for the Javascript run in the frontend.

Add Chart.js to the README.
2024-07-30 23:34:17 +01:00
198be70a99 week: Implement get_last_week
Previously, we only needed to get the last week number from the index, to
properly redirect to it.
However, we will need it in the future in other places.

Implement a function that centralizes this database operation.
2024-07-30 23:25:41 +01:00
f7efe0b66c style: Unify link behaviors, pad truth body
Pad the truths bodies a little bit inwards, to give more space.
Unify the link styling in one big messy pile of selectors, rather than
in multiple places.
2024-07-30 23:09:55 +01:00
072889173f week: Add week number to the DisplayTruth
In order to have all the relevant information for displaying a truth everywhere, add
its week number.
Fetch it during the week rendering and use it for the link back.
2024-07-29 22:54:13 +01:00
4e1e9facc6 tempaltes/truth: Add an anchor and link to each truth
Users might want to share specific truths, or it might be useful to link to them in the future.
Set the id of the h3 element for each truth to its number in the week and add an anchor link to
the full h3 element, to be able to click anywhere.

Update the stylesheet to hide the link color and decorations, add animation an hover color as
with the week navigation arrows.
2024-07-29 22:34:43 +01:00
1b4a934398 auth: Split off vote data from the user
Now that the application is going to have multiple pages, vote data makes no sense
to keep with the user.
The user struct will be used everywhere to check for authentication, which is not
the case for previous votes.

Create a new struct and function in src/vote.rs to retrieve existing votes and
use them in places where user.votes was used previously.
Remove vote-related code from src/auth.rs and the week number dependence that it
required.
2024-07-28 16:55:22 +01:00
1419bb6d51 tempates/base: Change language, update title
Now that we have the name of the world, we can show it in the title.

The base I used supposed an english language page, which is incorrect here.
Set language as French.
2024-07-28 16:55:22 +01:00
b1f37a4e4a templates: Make the index a class
The index is a full HTML page with some boilerplate that would be needed in all
pages deviating from the truth list, specifically the head and general structure.

Make the core structure a base template, rebuild the week index page inheriting
from it.
Change which template is used by the route accordingly.
2024-07-28 16:55:18 +01:00
afdac98dea templates: Move week-related includes to a folder
In preparation to adding a new page, move the week-related included files in a specific
sub-folder.
Change includes accordingly.
2024-07-27 22:41:06 +01:00
36b2e61e26 main: Serve static files from /static path
Static files served with FileServer have a low priority : all other possible routes
a this root will be checked first, before they get returned.
As we have a lot of routes at the root, they will be hit a lot before we get
to the static files.

Move the static files to a dedicated path to reduce those internal redirections,
update the paths in the HTML and add one for the favicon so it continues to work.
2024-07-27 21:47:26 +01:00
222acbb4f8 Rocket: Use fairings for routes of sub-files
Instead of adding all routes manually in the Launch function for Rocket,
implement fairings for all the different files that adds the routing to
the rocket in a self-contained manner.
2024-07-27 21:22:34 +01:00
120472354c auth: Remove auth bypass function
The authentication bypass function was mostly used for testing, before the
full flow was implemented.
Remove it now that it is no longer useful.
2024-07-27 21:08:24 +01:00
0c162d3b42 vote: Always display graph for the admin 2024-07-26 23:49:23 +01:00
c4e252dbc2 auth: Add a logout button
Add a logout button that clears the auth cookies, logging out the user.
It also tries to remove the auth token from the databse, but will ignore
any error during the database operation.

Do some include clean-ups as well.
2024-07-26 20:32:16 +01:00
36be6b51ae style: Update truth titles, change style of hr
Center the truth titles and add a border with the body, padding accordingly.
To no overload the page and maintain connection, make the hr dotted and match the color.
2024-07-26 19:52:02 +01:00
07d8cf42d7 vote: Properly take player and truth numbers into account
Fetch the amount of truths for the week and the player count to find the total possible votes.
Use this to remove the hardocded value in the check.
Update the check to fail if there was an error as well.

Now that the truth count is calculated, send it to the javascript to build the graph
labels automatically as well.
2024-07-26 19:25:41 +01:00
ba98c3be84 index: Remove the form if all votes were cast
Currently, if all votes are cast and the week is locked the selections are disabled but
the form and button still exist and might cause confusion.
Remove them if all votes are cast and we are not on the last week anymore.
2024-07-26 17:57:06 +01:00
4e1b13dc85 vote: Fix logic to hide graph if week is active
The goal is to not display the graph until the active week has been changed, but the logic
retuned early if it wasn't.

Simplify the query and check directly if the current week is the last one, if so do not
show the graph.
2024-07-26 11:30:12 +01:00
5ec38ee44f v1.2.0: Update production version
Main changes are the week handling, proper redirections, a bunch of fixes
and small adjustments, not displaying the graph until all votes and the
week changed.
2024-07-26 01:37:17 +01:00
a0b79a17ea Redirects: properly redirect to the current week
Previously, most redirects targeted the root of the application.
This was okay for the first part of development where only one week would be
active, but would be annoying when using multiple weeks.

Change those redirects to call week::week.

Change the login path to be dependant on the current week as well,
so it can be correctly redirected.
2024-07-26 01:08:47 +01:00
e08a46af3a week: Create new weeks and change active one
Implement a way for admins to introduce new weeks and set them as the last active one.
The last active week is the last one that is accessible to players, and will also prevent
the graph from being displayed.

Implement arrows for navigating between the weeks in the HTML.
2024-07-26 00:52:41 +01:00
635716c04b vote: Change graph display condition, don't fetch for admin
Now, the graph will only show when everyone has voted and the week is no longer
the last one active.
This is to minimize information gathering by looking during voting.

Don't fetch the vote data for the admin : it is not used, so no need to
query the database.

Update README with new TODOs and clean up main includes a bit.
2024-07-26 00:47:10 +01:00
f41f5142c9 styles: Minor reorganization
Properly split what is custom classes and regular HTML tags.
2024-07-26 00:41:05 +01:00
dfdd079ac4 templates/truth: Prevent changing vote if not last week
If the week is not active anymore, prevent changing any vote but allow adding missing ones.
2024-07-25 23:44:00 +01:00
207ce6c1d2 templates: Check vote against truth id, not number
I made a choice to only log confirmed votes : there is no blank vote in the database.
This means that when fetching a user's vote, if they have not voted for everyone
there will be votes missing.
As this is sent to the templating engine via a Vector, the ordering of the votes
will be incorrect : all existing votes will follow each other, and there will be
missing votes at the end.

Update the select logic in the truth template to account for that by checking
the truth_id directly, rather than via the index of the array. (O(N²)...)
Remove 'has_vote' as this is not useful anymore.
2024-07-25 23:30:02 +01:00
2b3dd28fed style: Fix edit box clipping the graph
It looks like the width of the element is calculated *inside* the padding, so the
outer width is really width+2*padding.
This leads to the edit box going outside of the truth column and clipping the graph.

Compute the width to take the padding into account.
2024-07-25 18:39:07 +01:00
f7e1218f21 truths: Change truth creation URL
As we will be able to create a new week, <week>/new to <week>/new_truth to
differentiate it from the week creation URL.
2024-07-25 16:54:19 +01:00
f74ed20e80 vote_chart: Add custom colors
I didn't like the default colors, so introduce a new set of them and
set them to the datasets.
Do it after the sort, otherwise the colors wouldn't stay consistent.
2024-07-24 18:11:37 +01:00
4c89a0783d vote_chart: Add title to the graph 2024-07-24 18:08:13 +01:00
d0843d600e vote_chart: Control the graph ratio switch
The media query used to switch the ratio of the graph would only fire when
switching from landscape to portrait, or the other way around.
This makes controlling the point where the graph switches to vertical is
only possible at this exact point.

Introduce a limit aspect-ratio that controls the change and use it for the
MediaQuery as well.

Make sure we don't delete/recreate the chart for no reason as well.
2024-07-24 16:56:08 +01:00
8fd8ce8220 vote_chart: Remove test code
This was written for testing the chart before plugging in to the database,
remove it now that is not useful anymore.
2024-07-24 16:27:43 +01:00
982a7ffd65 vote_chart: sort parsed votes
The SQL query retrieving the votes is deterministicly sorted, but goes through
a HashMap, for ease of processing and transfer, which does not maintaing order.

Sort the resulting object in the Javascript to keep a consistent order in the graph.
2024-07-24 15:23:52 +01:00
8547312a78 README: Update todo, fix typo 2024-07-23 22:14:18 +01:00
b6f3a49e9f vote: Reset the truth counter to 1 if the key changes
In order to fill the missing truths with 0, a counter follows the next expected
truth number.
If it suddenly drops down, we changed player and it should reset as well.

However, as not all players are voted for on all truths, we might change players
but get a higher truth, which was not taken into account and could miss all
the zeroes at the beggining for this player.

Reset the counter if we change players.
2024-07-23 21:51:59 +01:00
dc00e22dba vote_chart: Remove log of received datasets
Another debug print that I forgot for the release.
2024-07-23 21:51:59 +01:00
a2f70c318f auth: Fix auth token getting leaked to console
Remove a forgotten debug print that leaked auth tokens to the
console to check how they got saved and restored to the database.
2024-07-23 21:51:56 +01:00
67ce54e992 v1.1: Add weekly introductions
- Create a new migration adding a Weeks table, allowing for new weekly introductions
     and paving the way for multiple week handling.
 - Add route to update the weekly introduction
 - Move the week rendering to a specific week file
 - Update the templates to use the week number from the week data
 - Update templates to render and edit weekly introductions
2024-07-23 21:51:51 +01:00
9911895b5b v1.0: First production version
This first version allows login of pre-existing users, creation and update of truths
by admins, vote on the truths by users, their display as well as a simple graph
for the vote results.
Everything persisting in a SQLite database.
2024-07-23 21:51:42 +01:00