diff --git a/routes/css.cpp b/routes/css.cpp index 3638df6..4ae4a70 100644 --- a/routes/css.cpp +++ b/routes/css.cpp @@ -29,7 +29,7 @@ html { font-family: sans-serif; padding: 10px; } -p { +p, details { margin-top: 1em; margin-bottom: 1em; } diff --git a/servehelper.cpp b/servehelper.cpp index e92d956..b33fec2 100644 --- a/servehelper.cpp +++ b/servehelper.cpp @@ -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); 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", {{"class", "post-header"}}, { 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; }