add: achievements progress bar

This commit is contained in:
trisua 2025-06-27 13:36:10 -04:00
parent 5dd9fa01cb
commit 8d70f65863
4 changed files with 18 additions and 5 deletions

View file

@ -114,9 +114,10 @@
(div
("style" "display: contents")
(text "{{ self::post(post=post, owner=owner, secondary=secondary, community=community, show_community=show_community, can_manage_post=can_manage_post, repost=repost, expect_repost=true) }}"))
(text "{%- endmacro %} {% macro post(post, owner, question=false, secondary=false, community=false, show_community=true, can_manage_post=false, repost=false, expect_repost=false, poll=false, dont_show_title=false) -%} {% if community and show_community and community.id != config.town_square or question %}")
(text "{%- endmacro %} {% macro post(post, owner, question=false, secondary=false, community=false, show_community=true, can_manage_post=false, repost=false, expect_repost=false, poll=false, dont_show_title=false, is_repost=false) -%} {% if community and show_community and community.id != config.town_square or question %}")
(div
("class" "card-nest post_outer:{{ post.id }} post_outer")
("is_repost" "{{ is_repost }}")
(text "{% if question -%} {{ self::question(question=question[0], owner=question[1], profile=owner) }} {% else %}")
(div
("class" "card small")
@ -235,7 +236,7 @@
; content
(span ("id" "post_content:{{ post.id }}") (text "{{ post.content|markdown|safe }}"))
(text "{% if expect_repost -%} {% if repost -%} {{ self::post(post=repost[1], owner=repost[0], secondary=not secondary, community=false, show_community=false, can_manage_post=false) }} {% else %}")
(text "{% if expect_repost -%} {% if repost -%} {{ self::post(post=repost[1], owner=repost[0], secondary=not secondary, community=false, show_community=false, can_manage_post=false, is_repost=true) }} {% else %}")
(div
("class" "card lowered red flex items-center gap-2")
(text "{{ icon \"frown\" }}")

View file

@ -12,9 +12,12 @@
(icon (text "coffee"))
(span (text "Welcome to {{ config.name }}!")))
(div
("class" "card no_p_margin")
("class" "card no_p_margin flex flex-col gap-2")
(p (text "To help you move in, you'll be rewarded with small achievements for completing simple tasks on {{ config.name }}!"))
(p (text "You'll find out what each achievement is when you get it, so look around!"))))
(p (text "You'll find out what each achievement is when you get it, so look around!"))
(hr)
(span (b (text "Your progress: ")) (text "{{ percentage|round(method=\"floor\", precision=2) }}%"))
(div ("class" "poll_bar") ("style" "width: {{ percentage }}%"))))
(div
("class" "card-nest")

View file

@ -1295,6 +1295,10 @@ ${option.input_element_type === "textarea" ? `${option.value}</textarea>` : ""}
`.post${outer ? "_outer" : ""}\\:${id}`,
),
)) {
if (element.getAttribute("is_repost") === true) {
continue;
}
if (idx === 0) {
idx += 1;
continue;

View file

@ -10,7 +10,7 @@ use axum::{
use axum_extra::extract::CookieJar;
use serde::Deserialize;
use tetratto_core::model::{
auth::{AchievementName, DefaultTimelineChoice},
auth::{AchievementName, DefaultTimelineChoice, ACHIEVEMENTS},
permissions::FinePermission,
requests::ActionType,
Error,
@ -473,6 +473,11 @@ pub async fn achievements_request(
// ...
let lang = get_lang!(jar, data.0);
let mut context = initial_context(&data.0.0.0, lang, &Some(user)).await;
context.insert(
"percentage",
&((achievements.len() as f32 / ACHIEVEMENTS as f32) * 100.0),
);
context.insert("achievements", &achievements);
// return