add title to likes page

This commit is contained in:
Cinnamon 2020-02-04 13:59:54 -08:00
parent 479285d244
commit b79ece89e6
3 changed files with 37 additions and 13 deletions

View File

@ -48,6 +48,7 @@ const {
commentView,
extendedView,
latestView,
likesView,
listView,
markdownView,
metaView,
@ -360,10 +361,14 @@ router
})
.get("/likes/:feed", async ctx => {
const { feed } = ctx.params;
const likes = async ({ feed }) => {
const messages = await post.likes({ feed });
return listView({ messages });
const pendingMessages = post.likes({ feed });
const pendingName = about.name(feed);
return likesView({
messages: await pendingMessages,
feed,
name: await pendingName
});
};
ctx.body = await likes({ feed });
})

View File

@ -33,6 +33,8 @@ module.exports = {
relationshipConflict: "You are somehow both following and blocking",
// author view
viewLikes: "View likes",
// likes view
likedBy: "'s likes",
// composer
publish: "Publish",
commentWarning: [

View File

@ -516,6 +516,32 @@ exports.metaView = ({ status, peers, theme, themeNames }) => {
);
};
const viewInfoBox = ({ viewTitle = null, viewDescription = null }) => {
if (!viewTitle && !viewDescription) {
return null;
}
return section(
{ class: "viewInfo" },
viewTitle ? h1(viewTitle) : null,
viewDescription ? em(viewDescription) : null
);
};
exports.likesView = async ({ messages, feed, name }) => {
console.log(feed);
const authorLink = a(
{ href: `/author/${encodeURIComponent(feed)}` },
"@" + name
);
return template(
viewInfoBox({
viewTitle: span(authorLink, i18n.likedBy)
}),
messages.map(msg => post({ msg }))
);
};
exports.publicView = ({
messages,
prefix = null,
@ -524,17 +550,8 @@ exports.publicView = ({
}) => {
const publishForm = "/publish/";
let viewInfoBox = null;
if (viewTitle || viewDescription) {
viewInfoBox = section(
{ class: "viewInfo" },
viewTitle ? h1(viewTitle) : null,
viewDescription ? em(viewDescription) : null
);
}
return template(
viewInfoBox,
viewInfoBox({ viewTitle, viewDescription }),
prefix,
section(
header(strong(i18n.publish)),