Add content warning support
This commit is contained in:
parent
aab50e06b2
commit
8cb8e86de6
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue