Merge pull request #148 from christianbundy/add-topics-page
Add topics page
This commit is contained in:
10
src/index.js
10
src/index.js
@ -121,15 +121,15 @@ router
|
|||||||
ctx.body = await publicPopular({ period });
|
ctx.body = await publicPopular({ period });
|
||||||
})
|
})
|
||||||
.get("/public/latest", async ctx => {
|
.get("/public/latest", async ctx => {
|
||||||
const publicLatest = async () => {
|
|
||||||
const messages = await post.latest();
|
const messages = await post.latest();
|
||||||
return publicView({ messages });
|
ctx.body = await publicView({ messages });
|
||||||
};
|
|
||||||
ctx.body = await publicLatest();
|
|
||||||
})
|
})
|
||||||
.get("/public/latest/extended", async ctx => {
|
.get("/public/latest/extended", async ctx => {
|
||||||
const messages = await post.latestExtended();
|
const messages = await post.latestExtended();
|
||||||
|
ctx.body = await publicView({ messages });
|
||||||
|
})
|
||||||
|
.get("/public/latest/topics", async ctx => {
|
||||||
|
const messages = await post.latestTopics();
|
||||||
ctx.body = await publicView({ messages });
|
ctx.body = await publicView({ messages });
|
||||||
})
|
})
|
||||||
.get("/author/:feed", async ctx => {
|
.get("/author/:feed", async ctx => {
|
||||||
|
@ -679,6 +679,44 @@ module.exports = cooler => {
|
|||||||
|
|
||||||
return messages;
|
return messages;
|
||||||
},
|
},
|
||||||
|
latestTopics: async () => {
|
||||||
|
const ssb = await cooler.connect();
|
||||||
|
|
||||||
|
const myFeedId = ssb.id;
|
||||||
|
|
||||||
|
const options = configure({
|
||||||
|
type: "post",
|
||||||
|
private: false
|
||||||
|
});
|
||||||
|
|
||||||
|
const source = await cooler.read(ssb.messagesByType, options);
|
||||||
|
|
||||||
|
const extendedFilter = await socialFilter({
|
||||||
|
following: true
|
||||||
|
});
|
||||||
|
|
||||||
|
const messages = await new Promise((resolve, reject) => {
|
||||||
|
pull(
|
||||||
|
source,
|
||||||
|
pull.filter(
|
||||||
|
message =>
|
||||||
|
typeof message.value.content !== "string" &&
|
||||||
|
message.value.content.root == null
|
||||||
|
),
|
||||||
|
extendedFilter,
|
||||||
|
pull.take(maxMessages),
|
||||||
|
pull.collect((err, collectedMessages) => {
|
||||||
|
if (err) {
|
||||||
|
reject(err);
|
||||||
|
} else {
|
||||||
|
resolve(transform(ssb, collectedMessages, myFeedId));
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
return messages;
|
||||||
|
},
|
||||||
popular: async ({ period }) => {
|
popular: async ({ period }) => {
|
||||||
const ssb = await cooler.connect();
|
const ssb = await cooler.connect();
|
||||||
|
|
||||||
|
@ -46,6 +46,7 @@ module.exports = (...elements) => {
|
|||||||
li(a({ href: "/public/latest/extended" }, "🗺️ Extended")),
|
li(a({ href: "/public/latest/extended" }, "🗺️ Extended")),
|
||||||
li(a({ href: "/" }, "📣 Popular")),
|
li(a({ href: "/" }, "📣 Popular")),
|
||||||
li(a({ href: "/public/latest" }, "🐇 Latest")),
|
li(a({ href: "/public/latest" }, "🐇 Latest")),
|
||||||
|
li(a({ href: "/public/latest/topics" }, "📖 Topics")),
|
||||||
li(a({ href: "/profile" }, "🐱 Profile")),
|
li(a({ href: "/profile" }, "🐱 Profile")),
|
||||||
li(a({ href: "/mentions" }, "💬 Mentions")),
|
li(a({ href: "/mentions" }, "💬 Mentions")),
|
||||||
li(a({ href: "/inbox" }, "✉️ Private")),
|
li(a({ href: "/inbox" }, "✉️ Private")),
|
||||||
|
Reference in New Issue
Block a user