add: block list stacks

This commit is contained in:
trisua 2025-06-15 11:52:44 -04:00
parent 9bb5f38f76
commit b71ae1f5a4
28 changed files with 700 additions and 219 deletions

View file

@ -56,7 +56,8 @@
animation: popin ease-in-out 1 0.15s forwards running;
}
.lightbox a {
.lightbox a,
.lightbox img {
--padding: 2rem;
cursor: zoom-in;
max-height: calc(100dvh - var(--padding));
@ -684,6 +685,9 @@ nav .button:not(.title):not(.active):hover {
gap: var(--pad-2);
align-items: center;
justify-content: space-between;
position: sticky;
top: 0;
z-index: 1;
}
/* mobile nav chip nav */

View file

@ -1817,3 +1817,20 @@
("class" "no_p_margin")
(text "{{ post.title|markdown|safe }}"))))
(text "{%- endmacro %}")
(text "{% macro stack_listing(stack) -%}")
(a
("href" "/stacks/{{ stack.id }}")
("class" "card secondary flex flex-col gap-2")
(div
("class" "flex items-center gap-2")
(text "{{ icon \"list\" }}")
(b
(text "{{ stack.name }}")))
(span
(text "Created ")
(span
("class" "date")
(text "{{ stack.created }}"))
(text "; {{ stack.privacy }}; {{ stack.users|length }} users")))
(text "{%- endmacro %}")

View file

@ -101,15 +101,15 @@
(li
(a ("href" "https://trisua.com/t/tetratto") (text "Source code")))
(li
(a ("href" "https://tetratto.com/reference/tetratto/index.html") (text "Source code reference")))
(a ("href" "https://tetratto.com/reference/tetratto/index.html") ("data-turbo" "false") (text "Source code reference")))
(li
(a ("href" "https://tetratto.com/reference/tetratto/model/struct.ApiReturn.html") (text "API response structure")))
(a ("href" "https://tetratto.com/reference/tetratto/model/struct.ApiReturn.html") ("data-turbo" "false") (text "API response structure")))
(li
(a ("href" "https://tetratto.com/reference/tetratto/model/oauth/enum.AppScope.html") (text "App scopes")))
(a ("href" "https://tetratto.com/reference/tetratto/model/oauth/enum.AppScope.html") ("data-turbo" "false") (text "App scopes")))
(li
(a ("href" "https://tetratto.com/reference/tetratto/model/permissions/struct.FinePermission.html") (text "User permissions")))
(a ("href" "https://tetratto.com/reference/tetratto/model/permissions/struct.FinePermission.html") ("data-turbo" "false") (text "User permissions")))
(li
(a ("href" "https://tetratto.com/reference/tetratto/model/communities_permissions/struct.CommunityPermission.html") (text "Community member permissions")))
(a ("href" "https://tetratto.com/reference/tetratto/model/communities_permissions/struct.CommunityPermission.html") ("data-turbo" "false") (text "Community member permissions")))
(li
(a ("href" "https://tetratto.com/forge/tetratto") (text "Report issues")))))))

View file

@ -388,6 +388,22 @@
(text "{{ icon \"arrow-left\" }}")
(span
(text "{{ text \"general:action.back\" }}")))
; stack blocks
(div
("class" "card-nest")
(div
("class" "card flex items-center gap-2 small")
(text "{{ icon \"layers\" }}")
(span
(text "{{ text \"stacks:link.stacks\" }}")))
(div
("class" "card flex flex-col gap-2")
(text "{% for stack in stackblocks %}")
(text "{{ components::stack_listing(stack=stack) }}")
(text "{% endfor %}")))
; user blocks
(div
("class" "card-nest")
(div

View file

@ -0,0 +1,85 @@
(text "{% extends \"root.html\" %} {% block head %}")
(title
(text "{{ stack.name }} - {{ config.name }}"))
(text "{% endblock %} {% block body %} {{ macros::nav() }}")
(main
("class" "flex flex-col gap-2")
(text "{{ macros::timelines_nav(selected=\"stacks\") }}")
(div
("class" "card-nest w-full")
(div
("class" "card small flex items-center justify-between gap-2")
(div
("class" "flex items-center gap-2")
(text "{{ icon \"list\" }}")
(span
(text "{{ stack.name }}")))
(text "{% if user and user.id == stack.owner -%}")
(a
("href" "/stacks/{{ stack.id }}/manage")
("class" "button lowered small")
(text "{{ icon \"pencil\" }}")
(span
(text "{{ text \"general:action.manage\" }}")))
(text "{%- endif %}"))
(div
("class" "card w-full flex flex-col gap-2")
(text "{% if list|length == 0 -%}")
(p
(text "No items yet! Maybe ")
(a
("href" "/stacks/{{ stack.id }}/manage#/users")
(text "add a user to this stack"))
(text "!"))
(text "{%- endif %}")
(text "{% if stack.mode == 'BlockList' -%}")
(text "{% if not is_blocked -%}")
(button
("onclick" "block_all()")
(str (text "stacks:label.block_all")))
(text "{% else %}")
(button
("onclick" "block_all(false)")
(str (text "stacks:label.unblock_all")))
(text "{%- endif %}")
(div
("class" "flex gap-2 flex-wrap w-full")
(text "{% for user in list %} {{ components::user_plate(user=user, secondary=true) }} {% endfor %}"))
(text "{% else %}")
(text "{% for post in list %}
{% if post[2].read_access == \"Everybody\" -%}
{% if post[0].context.repost and post[0].context.repost.reposting -%}
{{ components::repost(repost=post[3], post=post[0], owner=post[1], secondary=true, community=post[2], show_community=true) }}
{% else %}
{{ components::post(post=post[0], owner=post[1], question=post[4], secondary=true, community=post[2], poll=post[5]) }}
{%- endif %} {%- endif %} {% endfor %}")
(text "{%- endif %} {{ components::pagination(page=page, items=list|length) }}"))))
(script
(text "async function block_all(block = true) {
if (
!(await trigger(\"atto::confirm\", [
\"Are you sure you would like to do this?\",
]))
) {
return;
}
fetch(\"/api/v1/stacks/{{ stack.id }}/block\", {
method: block ? \"POST\" : \"DELETE\",
})
.then((res) => res.json())
.then((res) => {
trigger(\"atto::toast\", [
res.ok ? \"success\" : \"error\",
res.message,
]);
if (res.ok) {
window.location.href = \"/settings#/account/blocks\";
}
});
}"))
(text "{% endblock %}")

View file

@ -44,20 +44,7 @@
(div
("class" "card flex flex-col gap-2")
(text "{% for item in list %}")
(a
("href" "/stacks/{{ item.id }}")
("class" "card secondary flex flex-col gap-2")
(div
("class" "flex items-center gap-2")
(text "{{ icon \"list\" }}")
(b
(text "{{ item.name }}")))
(span
(text "Created ")
(span
("class" "date")
(text "{{ item.created }}"))
(text "; {{ item.privacy }}; {{ item.users|length }} users")))
(text "{{ components::stack_listing(stack=item) }}")
(text "{% endfor %}"))))
(script

View file

@ -63,7 +63,11 @@
(option
("value" "Exclude")
("selected" "{% if stack.mode == 'Exclude' -%}true{% else %}false{%- endif %}")
(text "Exclude")))))
(text "Exclude"))
(option
("value" "BlockList")
("selected" "{% if stack.mode == 'BlockList' -%}true{% else %}false{%- endif %}")
(text "Block list")))))
(div
("class" "card-nest")
("ui_ident" "sort")

View file

@ -1,37 +0,0 @@
(text "{% extends \"root.html\" %} {% block head %}")
(title
(text "{{ stack.name }} - {{ config.name }}"))
(text "{% endblock %} {% block body %} {{ macros::nav() }}")
(main
("class" "flex flex-col gap-2")
(text "{{ macros::timelines_nav(selected=\"stacks\") }}")
(div
("class" "card-nest w-full")
(div
("class" "card small flex items-center justify-between gap-2")
(div
("class" "flex items-center gap-2")
(text "{{ icon \"list\" }}")
(span
(text "{{ stack.name }}")))
(text "{% if user and user.id == stack.owner -%}")
(a
("href" "/stacks/{{ stack.id }}/manage")
("class" "button lowered small")
(text "{{ icon \"pencil\" }}")
(span
(text "{{ text \"general:action.manage\" }}")))
(text "{%- endif %}"))
(div
("class" "card w-full flex flex-col gap-2")
(text "{% if list|length == 0 -%}")
(p
(text "No posts yet! Maybe ")
(a
("href" "/stacks/{{ stack.id }}/manage#/users")
(text "add a user to this stack"))
(text "!"))
(text "{%- endif %} {% for post in list %} {% if post[2].read_access == \"Everybody\" -%} {% if post[0].context.repost and post[0].context.repost.reposting -%} {{ components::repost(repost=post[3], post=post[0], owner=post[1], secondary=true, community=post[2], show_community=true) }} {% else %} {{ components::post(post=post[0], owner=post[1], question=post[4], secondary=true, community=post[2], poll=post[5]) }} {%- endif %} {%- endif %} {% endfor %} {{ components::pagination(page=page, items=list|length) }}"))))
(text "{% endblock %}")

View file

@ -1104,24 +1104,9 @@ ${option.input_element_type === "textarea" ? `${option.value}</textarea>` : ""}
);
// lightbox
self.define("lightbox_open", async (_, src) => {
self.define("lightbox_open", (_, src) => {
document.getElementById("lightbox_img").src = src;
document.getElementById("lightbox_img_a").href = src;
await (async () => {
return new Promise((resolve, reject) => {
let idx = 0;
const inter = setInterval(() => {
idx += 1;
if (document.getElementById("lightbox_img").complete) {
console.log(`img loaded (took ${idx})`);
clearInterval(inter);
return resolve();
}
}, 25);
});
})();
document.getElementById("lightbox").classList.remove("hidden");
});