Add content warning support

This commit is contained in:
blankie 2023-11-23 19:58:44 +11:00
parent aab50e06b2
commit 8cb8e86de6
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
2 changed files with 11 additions and 2 deletions

View File

@ -29,7 +29,7 @@ html {
font-family: sans-serif; font-family: sans-serif;
padding: 10px; padding: 10px;
} }
p { p, details {
margin-top: 1em; margin-top: 1em;
margin-bottom: 1em; margin-bottom: 1em;
} }

View File

@ -176,6 +176,15 @@ Element serialize_post(const httplib::Request& req, const std::string& server, c
: "Created: "s + full_time(post.created_at) + "\nEdited: " + full_time(post.edited_at); : "Created: "s + full_time(post.created_at) + "\nEdited: " + full_time(post.edited_at);
const char* time_badge = post.edited_at < 0 ? "" : " (edited)"; const char* time_badge = post.edited_at < 0 ? "" : " (edited)";
Node contents = preprocess_html(req, server, post.emojis, post.content);
if (post.sensitive) {
std::string spoiler_text = !post.spoiler_text.empty() ? post.spoiler_text : "See more";
contents = Element("details", {
Element("summary", {preprocess_html(req, post.emojis, std::move(spoiler_text))}),
std::move(contents),
});
}
Element div("div", {{"class", "post"}}, { Element div("div", {{"class", "post"}}, {
Element("div", {{"class", "post-header"}}, { Element("div", {{"class", "post-header"}}, {
Element("a", {{"href", get_origin(req) + '/' + server + "/@" + post.account.acct(false)}}, { Element("a", {{"href", get_origin(req) + '/' + server + "/@" + post.account.acct(false)}}, {
@ -190,7 +199,7 @@ Element serialize_post(const httplib::Request& req, const std::string& server, c
}), }),
}), }),
preprocess_html(req, server, post.emojis, post.content), contents,
}); });
return div; return div;
} }