This commit is contained in:
Doug Hoyte
2024-12-16 23:39:59 -05:00
parent b82c269cc3
commit 2860cb0909
4 changed files with 51 additions and 5 deletions

View File

@ -5,6 +5,7 @@ struct FeedReader {
bool found = false;
tao::json::value feedJson;
tao::json::value content;
std::string pubkey;
std::string feedName;
@ -39,6 +40,12 @@ struct FeedReader {
found = true;
return false;
});
if (!found) return;
try {
content = tao::json::from_string(feedJson.at("content").get_string());
} catch (...) {}
}
std::vector<FeedEvent> getEvents(lmdb::txn &txn, Decompressor &decomp, uint64_t resultsPerPage, uint64_t page) const {

View File

@ -282,11 +282,30 @@ HTTPResponse WebServer::generateReadResponse(lmdb::txn &txn, Decompressor &decom
} else if (u.path.size() == 3 && u.path[2] == "info") {
feedReader.emplace(txn, decomp, u.path[1]);
std::string title, description, styleHeaderShade;
if (feedReader->content.get_object().contains("title")) title = feedReader->content["title"].get_string();
if (feedReader->content.get_object().contains("description")) description = feedReader->content["description"].get_string();
std::string feedPath;
if (u.path[1] == "homepage") feedPath = "/";
else {
feedPath = "/f/";
feedPath += u.path[1];
}
if (feedReader->found) {
struct {
const std::optional<FeedReader> &feedReader;
const User &curator;
const std::string &title;
const std::string &description;
const std::string &feedPath;
} ctx = {
feedReader,
*userCache.getUser(txn, decomp, feedReader->pubkey),
title,
description,
feedPath,
};
body = tmpl::feed::info(ctx);

View File

@ -283,6 +283,22 @@ table.vert {
margin-left: 40px;
}
.feed-info {
.feed-id {
background-color: #dfdfdf;
font-family: monospace;
font-size: 90%;
display: inline;
padding: 5px;
}
.feed-description {
padding-left: 20px;
border-left: 2px solid blue;
white-space: pre;
}
}
/* voting */

View File

@ -1,9 +1,13 @@
<div class="feed-info-page">
<p>
Feed: $(ctx.feedReader->feedName)
<div class="info-page feed-info">
<h2>Feed: <a href="$(ctx.feedPath)">$(ctx.title)</a></h2>
<pre class="feed-id">$(ctx.feedReader->feedId)</pre>
<p class="feed-curator">
Curator: <a href="/u/$(ctx.curator.npubId)">$(ctx.curator.username)</a>
</p>
<p>
ID: $(ctx.feedReader->feedId)
<p class="feed-description">
$(ctx.description)
</p>
</div>