mirror of
https://github.com/hoytech/strfry.git
synced 2025-06-20 09:50:28 +00:00
title
This commit is contained in:
@ -241,7 +241,7 @@ struct Event {
|
|||||||
// FIXME: Don't truncate UTF-8 mid-sequence
|
// FIXME: Don't truncate UTF-8 mid-sequence
|
||||||
// FIXME: Don't put ellipsis if truncated text ends in punctuation
|
// FIXME: Don't put ellipsis if truncated text ends in punctuation
|
||||||
|
|
||||||
std::string summaryHtml() const {
|
std::string summaryHtml(bool withLink = true) const {
|
||||||
std::string content = json.at("content").get_string();
|
std::string content = json.at("content").get_string();
|
||||||
auto firstUrl = stripUrls(content);
|
auto firstUrl = stripUrls(content);
|
||||||
|
|
||||||
@ -252,7 +252,7 @@ struct Event {
|
|||||||
textAbbrev(content, 100);
|
textAbbrev(content, 100);
|
||||||
templarInternal::htmlEscape(content, true);
|
templarInternal::htmlEscape(content, true);
|
||||||
|
|
||||||
if (firstUrl.size()) {
|
if (withLink && firstUrl.size()) {
|
||||||
while (content.size() && isspace(content.back())) content.pop_back();
|
while (content.size() && isspace(content.back())) content.pop_back();
|
||||||
if (content.empty()) {
|
if (content.empty()) {
|
||||||
content = firstUrl;
|
content = firstUrl;
|
||||||
@ -513,6 +513,17 @@ struct EventThread {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::string getSummary() {
|
||||||
|
if (!rootEventId.size()) return "";
|
||||||
|
|
||||||
|
auto p = eventCache.find(rootEventId);
|
||||||
|
if (p == eventCache.end()) return "";
|
||||||
|
|
||||||
|
const auto &elem = p->second;
|
||||||
|
return elem.summaryHtml(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
TemplarResult render(lmdb::txn &txn, Decompressor &decomp, UserCache &userCache, std::optional<std::string> focusOnPubkey = std::nullopt) {
|
TemplarResult render(lmdb::txn &txn, Decompressor &decomp, UserCache &userCache, std::optional<std::string> focusOnPubkey = std::nullopt) {
|
||||||
auto now = hoytech::curr_time_s();
|
auto now = hoytech::curr_time_s();
|
||||||
flat_hash_set<uint64_t> processedLevIds;
|
flat_hash_set<uint64_t> processedLevIds;
|
||||||
|
@ -178,6 +178,7 @@ HTTPResponse WebServer::generateReadResponse(lmdb::txn &txn, Decompressor &decom
|
|||||||
if (u.path.size() == 2) {
|
if (u.path.size() == 2) {
|
||||||
EventThread et(txn, decomp, decodeBech32Simple(u.path[1]));
|
EventThread et(txn, decomp, decodeBech32Simple(u.path[1]));
|
||||||
body = et.render(txn, decomp, userCache);
|
body = et.render(txn, decomp, userCache);
|
||||||
|
title = et.getSummary();
|
||||||
} else if (u.path.size() == 3) {
|
} else if (u.path.size() == 3) {
|
||||||
if (u.path[2] == "reply") {
|
if (u.path[2] == "reply") {
|
||||||
auto ev = Event::fromIdExternal(txn, u.path[1]);
|
auto ev = Event::fromIdExternal(txn, u.path[1]);
|
||||||
|
Reference in New Issue
Block a user