add: post titles
This commit is contained in:
parent
1279536609
commit
5b1db42c51
14 changed files with 230 additions and 13 deletions
|
@ -87,7 +87,7 @@
|
|||
(text "{{ components::avatar(username=user.id, size=\"32px\", selector_type=\"id\") }}")
|
||||
(select
|
||||
("id" "community_to_post_to")
|
||||
("onchange" "update_community_avatar(event)")
|
||||
("onchange" "update_community_avatar(event); check_community_supports_title(event)")
|
||||
(option
|
||||
("value" "{{ config.town_square }}")
|
||||
("selected" "{% if not selected_community -%}true{% else %}false{%- endif %}")
|
||||
|
@ -102,6 +102,19 @@
|
|||
("class" "card flex flex-col gap-2")
|
||||
("id" "create_form")
|
||||
("onsubmit" "create_post_from_form(event)")
|
||||
(div
|
||||
("class" "flex flex-col gap-1 hidden")
|
||||
("id" "title_field")
|
||||
(label
|
||||
("for" "content")
|
||||
(text "{{ text \"communities:label.title\" }}"))
|
||||
(input
|
||||
("type" "text")
|
||||
("name" "title")
|
||||
("id" "title")
|
||||
("placeholder" "title")
|
||||
("minlength" "2")
|
||||
("maxlength" "128")))
|
||||
(div
|
||||
("class" "flex flex-col gap-1")
|
||||
(label
|
||||
|
@ -179,6 +192,7 @@
|
|||
\"community_to_post_to\",
|
||||
).selectedOptions[0].value,
|
||||
poll: poll_data[1],
|
||||
title: e.target.title.value,
|
||||
}),
|
||||
);
|
||||
|
||||
|
@ -397,10 +411,29 @@
|
|||
}
|
||||
}
|
||||
|
||||
function check_community_supports_title(e) {
|
||||
const element = document.getElementById(\"title_field\");
|
||||
const id = e.target.selectedOptions[0].value;
|
||||
|
||||
fetch(`/api/v1/communities/${id}/supports_titles`)
|
||||
.then((res) => res.json())
|
||||
.then((res) => {
|
||||
if (res.message === \"yes\") {
|
||||
element.classList.remove(\"hidden\");
|
||||
} else {
|
||||
element.classList.add(\"hidden\");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
update_community_avatar({
|
||||
target: document.getElementById(\"community_to_post_to\"),
|
||||
});
|
||||
|
||||
check_community_supports_title({
|
||||
target: document.getElementById(\"community_to_post_to\"),
|
||||
});
|
||||
}, 150);
|
||||
|
||||
async function cancel_create_post() {
|
||||
|
|
|
@ -922,6 +922,22 @@
|
|||
\"{{ community.context.enable_questions }}\",
|
||||
\"checkbox\",
|
||||
],
|
||||
[
|
||||
[
|
||||
\"enable_titles\",
|
||||
\"Allow users to attach a title to their posts\",
|
||||
],
|
||||
\"{{ community.context.enable_titles }}\",
|
||||
\"checkbox\",
|
||||
],
|
||||
[
|
||||
[
|
||||
\"require_titles\",
|
||||
\"Require users to attach a title to their posts\",
|
||||
],
|
||||
\"{{ community.context.require_titles }}\",
|
||||
\"checkbox\",
|
||||
],
|
||||
],
|
||||
settings,
|
||||
);
|
||||
|
|
|
@ -111,7 +111,7 @@
|
|||
("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) -%} {% 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) -%} {% if community and show_community and community.id != config.town_square or question %}")
|
||||
(div
|
||||
("class" "card-nest")
|
||||
(text "{% if question -%} {{ self::question(question=question[0], owner=question[1], profile=owner) }} {% else %}")
|
||||
|
@ -188,11 +188,32 @@
|
|||
("style" "color: var(--color-primary)")
|
||||
(text "{{ icon \"trash-2\" }}"))
|
||||
(text "{%- endif %}"))
|
||||
(text "{% if not dont_show_title and post.title and community and community.context.enable_titles -%}")
|
||||
; post has a title AND whatever is rendering this component wants to see it
|
||||
(a
|
||||
("class" "flush")
|
||||
("href" "/post/{{ post.id }}")
|
||||
(h2
|
||||
("id" "post-content:{{ post.id }}")
|
||||
("class" "no_p_margin post_content")
|
||||
("hook" "long")
|
||||
(text "{{ post.title }}"))
|
||||
|
||||
(button ("class" "small quaternary") (icon (text "ellipsis"))))
|
||||
(text "{% else %}")
|
||||
(text "{% if not post.context.content_warning -%}")
|
||||
(span
|
||||
("id" "post-content:{{ post.id }}")
|
||||
("class" "no_p_margin post_content")
|
||||
("hook" "long")
|
||||
|
||||
; title
|
||||
(text "{% if post.title and community and community.context.enable_titles -%}")
|
||||
(h2 (text "{{ post.title }}"))
|
||||
(hr ("class" "margin"))
|
||||
(text "{%- endif %}")
|
||||
|
||||
; content
|
||||
(text "{{ post.content|markdown|safe }} {% 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 %}")
|
||||
(div
|
||||
("class" "card tertiary red flex items-center gap-2")
|
||||
|
@ -213,6 +234,13 @@
|
|||
("id" "post-content:{{ post.id }}")
|
||||
("class" "no_p_margin post_content")
|
||||
("hook" "long")
|
||||
|
||||
; title
|
||||
(text "{% if post.title and community and community.settings.enable_titles %}")
|
||||
(h2 (text "{{ post.title }}"))
|
||||
(text "{% endif %}")
|
||||
|
||||
; content
|
||||
(text "{{ post.content|markdown|safe }} {% 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 %}")
|
||||
(div
|
||||
("class" "card tertiary red flex items-center gap-2")
|
||||
|
@ -221,7 +249,7 @@
|
|||
(text "Could not find original post...")))
|
||||
(text "{%- endif %} {%- endif %}"))
|
||||
(text "{{ self::post_media(upload_ids=post.uploads) }}")))
|
||||
(text "{%- endif %}")
|
||||
(text "{%- endif %} {%- endif %}")
|
||||
|
||||
(text "{% if poll -%} {{ self::poll(post=post, poll=poll) }} {%- endif %}")
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
(text "{%- endif %}")
|
||||
(div
|
||||
("style" "display: contents;")
|
||||
(text "{% if post.context.repost and post.context.repost.reposting -%} {{ components::repost(repost=reposting, post=post, owner=owner, community=community, show_community=true, can_manage_post=can_manage_posts) }} {% else %} {{ components::post(post=post, owner=owner, question=question, community=community, show_community=true, can_manage_post=can_manage_posts) }} {%- endif %}"))
|
||||
(text "{% if post.context.repost and post.context.repost.reposting -%} {{ components::repost(repost=reposting, post=post, owner=owner, community=community, show_community=true, can_manage_post=can_manage_posts) }} {% else %} {{ components::post(post=post, owner=owner, question=question, community=community, show_community=true, can_manage_post=can_manage_posts, dont_show_title=true) }} {%- endif %}"))
|
||||
(div
|
||||
("class" "pillmenu")
|
||||
(a
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
(text "{%- endif %}")
|
||||
(div
|
||||
("style" "display: contents;")
|
||||
(text "{% if post.context.repost and post.context.repost.reposting -%} {{ components::repost(repost=reposting, post=post, owner=owner, community=community, show_community=true, can_manage_post=can_manage_posts) }} {% else %} {{ components::post(post=post, owner=owner, question=question, community=community, show_community=true, can_manage_post=can_manage_posts, poll=poll) }} {%- endif %}"))
|
||||
(text "{% if post.context.repost and post.context.repost.reposting -%} {{ components::repost(repost=reposting, post=post, owner=owner, community=community, show_community=true, can_manage_post=can_manage_posts) }} {% else %} {{ components::post(post=post, owner=owner, question=question, community=community, show_community=true, can_manage_post=can_manage_posts, poll=poll, dont_show_title=true) }} {%- endif %}"))
|
||||
(text "{% if user and post.context.comments_enabled -%}")
|
||||
(div
|
||||
("class" "card-nest")
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
(text "{%- endif %}")
|
||||
(div
|
||||
("style" "display: contents;")
|
||||
(text "{% if post.context.repost and post.context.repost.reposting -%} {{ components::repost(repost=reposting, post=post, owner=owner, community=community, show_community=true, can_manage_post=can_manage_posts) }} {% else %} {{ components::post(post=post, owner=owner, question=question, community=community, show_community=true, can_manage_post=can_manage_posts) }} {%- endif %}"))
|
||||
(text "{% if post.context.repost and post.context.repost.reposting -%} {{ components::repost(repost=reposting, post=post, owner=owner, community=community, show_community=true, can_manage_post=can_manage_posts) }} {% else %} {{ components::post(post=post, owner=owner, question=question, community=community, show_community=true, can_manage_post=can_manage_posts, dont_show_title=true) }} {%- endif %}"))
|
||||
(div
|
||||
("class" "pillmenu")
|
||||
(a
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
(text "{%- endif %}")
|
||||
(div
|
||||
("style" "display: contents;")
|
||||
(text "{% if post.context.repost and post.context.repost.reposting -%} {{ components::repost(repost=reposting, post=post, owner=owner, community=community, show_community=true, can_manage_post=can_manage_posts) }} {% else %} {{ components::post(post=post, owner=owner, question=question, community=community, show_community=true, can_manage_post=can_manage_posts) }} {%- endif %}"))
|
||||
(text "{% if post.context.repost and post.context.repost.reposting -%} {{ components::repost(repost=reposting, post=post, owner=owner, community=community, show_community=true, can_manage_post=can_manage_posts) }} {% else %} {{ components::post(post=post, owner=owner, question=question, community=community, show_community=true, can_manage_post=can_manage_posts, dont_show_title=true) }} {%- endif %}"))
|
||||
(div
|
||||
("class" "pillmenu")
|
||||
(a
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue