openvibers/openvibe.news Commits

/topics names its topics in its description (it said 'Topics on OpenVibe.News.') (#78)

OP OpenVibers committed 24 days ago · f3cd38d8ad · 2 files, +13 −1

Changes

ddiff --git a/server/http/public.js b/server/http/public.js
iindex e0b8fc5..50c176e 100644
---- a/server/http/public.js
++++ b/server/http/public.js
@@@ -207,7 +207,12 @@ function createPublicRoutes(ctx) {
}));
router.get('/topics', wrap(async (req, res) => {
-- send(req, res, 200, { title: 'Topics', description: 'Topics on OpenVibe.News.', decision: pageDecision('/topics'), canonical: publication.abs('/topics'), body: pages.topicsIndex({ topics: await topics.list() }) }, { cacheable: true });
++ const list = await topics.list();
++ // It said "Topics on OpenVibe.News." (24 characters); it now names them.
++ const names = list.map((t) => t.name).join(', ');
++ const text = `The ${list.length} topics OpenVibe.News follows, each with its stories, briefs and wire: ${names}.`;
++ const description = text.length <= 160 ? text : `${text.slice(0, 159).replace(/[\s,]+\S*$/, '')}…`;
++ send(req, res, 200, { title: 'Topics', description, decision: pageDecision('/topics'), canonical: publication.abs('/topics'), body: pages.topicsIndex({ topics: list }) }, { cacheable: true });
}));
router.get('/topics/:slug', wrap(async (req, res) => {
ddiff --git a/test/layout.test.js b/test/layout.test.js
iindex f94dd9b..a1f5a7c 100644
---- a/test/layout.test.js
++++ b/test/layout.test.js
@@@ -44,6 +44,13 @@ const count = (html, re) => (html.match(re) || []).length;
}
});
++ await check('/topics names its topics in its description (it said only "Topics on OpenVibe.News.")', async () => {
++ const html = (await t.get('/topics')).text;
++ const desc = (html.match(/<meta name="description" content="([^"]*)">/) || [])[1] || '';
++ assert.match(desc, /^The \d+ topics OpenVibe\.News follows, each with its stories, briefs and wire: /, desc);
++ assert.ok(desc.length <= 160, desc);
++ });
++
await check('the shared navbar signs in through the {path} template (sign-in returns to the current page)', async () => {
const home = await t.get('/');
assert.ok(home.text.includes('"loginUrl":"/auth/login?next={path}"'), 'loginUrl is a {path} template');