Commit graph

30 commits

Author SHA1 Message Date
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