From 2860cb0909482a016a97d6e564e8b52ee227f7f1 Mon Sep 17 00:00:00 2001 From: Doug Hoyte Date: Mon, 16 Dec 2024 23:39:59 -0500 Subject: [PATCH] np --- src/apps/web/FeedReader.h | 7 +++++++ src/apps/web/WebReader.cpp | 19 +++++++++++++++++++ src/apps/web/static/oddbean.css | 16 ++++++++++++++++ src/apps/web/tmpls/feed/info.tmpl | 14 +++++++++----- 4 files changed, 51 insertions(+), 5 deletions(-) diff --git a/src/apps/web/FeedReader.h b/src/apps/web/FeedReader.h index fc05d4a..42fe86b 100644 --- a/src/apps/web/FeedReader.h +++ b/src/apps/web/FeedReader.h @@ -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 getEvents(lmdb::txn &txn, Decompressor &decomp, uint64_t resultsPerPage, uint64_t page) const { diff --git a/src/apps/web/WebReader.cpp b/src/apps/web/WebReader.cpp index d13cc99..bfbf565 100644 --- a/src/apps/web/WebReader.cpp +++ b/src/apps/web/WebReader.cpp @@ -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; + 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); diff --git a/src/apps/web/static/oddbean.css b/src/apps/web/static/oddbean.css index a35b6e0..39d6ad2 100644 --- a/src/apps/web/static/oddbean.css +++ b/src/apps/web/static/oddbean.css @@ -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 */ diff --git a/src/apps/web/tmpls/feed/info.tmpl b/src/apps/web/tmpls/feed/info.tmpl index 75d5f89..0c9e5ab 100644 --- a/src/apps/web/tmpls/feed/info.tmpl +++ b/src/apps/web/tmpls/feed/info.tmpl @@ -1,9 +1,13 @@ -
-

- Feed: $(ctx.feedReader->feedName) +

+

Feed: $(ctx.title)

+ +
$(ctx.feedReader->feedId)
+ +

+ Curator: $(ctx.curator.username)

-

- ID: $(ctx.feedReader->feedId) +

+ $(ctx.description)