openvibers/openvibe.news Commits
/topics names its topics in its description (it said 'Topics on OpenVibe.News.') (#78)
Changes
@@@ -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) => {@@@ -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');
@@ -207,7 +207,12 @@ function createPublicRoutes(ctx) {
@@ -207,7 +207,12 @@ function createPublicRoutes(ctx) {
}));
}));
router.get('/topics', wrap(async (req, res) => {
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) => {
router.get('/topics/:slug', wrap(async (req, res) => {
@@ -44,6 +44,13 @@ const count = (html, re) => (html.match(re) || []).length;
@@ -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 () => {
await check('the shared navbar signs in through the {path} template (sign-in returns to the current page)', async () => {
const home = await t.get('/');
const home = await t.get('/');
assert.ok(home.text.includes('"loginUrl":"/auth/login?next={path}"'), 'loginUrl is a {path} template');
assert.ok(home.text.includes('"loginUrl":"/auth/login?next={path}"'), 'loginUrl is a {path} template');