add: achievements progress bar
This commit is contained in:
parent
5dd9fa01cb
commit
8d70f65863
4 changed files with 18 additions and 5 deletions
|
@ -114,9 +114,10 @@
|
||||||
(div
|
(div
|
||||||
("style" "display: contents")
|
("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 "{{ 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
|
(div
|
||||||
("class" "card-nest post_outer:{{ post.id }} post_outer")
|
("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 %}")
|
(text "{% if question -%} {{ self::question(question=question[0], owner=question[1], profile=owner) }} {% else %}")
|
||||||
(div
|
(div
|
||||||
("class" "card small")
|
("class" "card small")
|
||||||
|
@ -235,7 +236,7 @@
|
||||||
|
|
||||||
; content
|
; content
|
||||||
(span ("id" "post_content:{{ post.id }}") (text "{{ post.content|markdown|safe }}"))
|
(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
|
(div
|
||||||
("class" "card lowered red flex items-center gap-2")
|
("class" "card lowered red flex items-center gap-2")
|
||||||
(text "{{ icon \"frown\" }}")
|
(text "{{ icon \"frown\" }}")
|
||||||
|
|
|
@ -12,9 +12,12 @@
|
||||||
(icon (text "coffee"))
|
(icon (text "coffee"))
|
||||||
(span (text "Welcome to {{ config.name }}!")))
|
(span (text "Welcome to {{ config.name }}!")))
|
||||||
(div
|
(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 "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
|
(div
|
||||||
("class" "card-nest")
|
("class" "card-nest")
|
||||||
|
|
|
@ -1295,6 +1295,10 @@ ${option.input_element_type === "textarea" ? `${option.value}</textarea>` : ""}
|
||||||
`.post${outer ? "_outer" : ""}\\:${id}`,
|
`.post${outer ? "_outer" : ""}\\:${id}`,
|
||||||
),
|
),
|
||||||
)) {
|
)) {
|
||||||
|
if (element.getAttribute("is_repost") === true) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (idx === 0) {
|
if (idx === 0) {
|
||||||
idx += 1;
|
idx += 1;
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -10,7 +10,7 @@ use axum::{
|
||||||
use axum_extra::extract::CookieJar;
|
use axum_extra::extract::CookieJar;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use tetratto_core::model::{
|
use tetratto_core::model::{
|
||||||
auth::{AchievementName, DefaultTimelineChoice},
|
auth::{AchievementName, DefaultTimelineChoice, ACHIEVEMENTS},
|
||||||
permissions::FinePermission,
|
permissions::FinePermission,
|
||||||
requests::ActionType,
|
requests::ActionType,
|
||||||
Error,
|
Error,
|
||||||
|
@ -473,6 +473,11 @@ pub async fn achievements_request(
|
||||||
// ...
|
// ...
|
||||||
let lang = get_lang!(jar, data.0);
|
let lang = get_lang!(jar, data.0);
|
||||||
let mut context = initial_context(&data.0.0.0, lang, &Some(user)).await;
|
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);
|
context.insert("achievements", &achievements);
|
||||||
|
|
||||||
// return
|
// return
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue