openvibers/openvibe.community Commits
The Feed names a wiki page by its title (#321)
Changes
@@@ -71,7 +71,8 @@ function itemFor(event) {// blog.post.published names its blog as { id, handle } (contracts payload v1); a plain string is still read.const blogName = clean(p.blog && typeof p.blog === 'object' ? p.blog.handle : p.blog, 60);const title = k[0] === 'blog' ? (blogName ? `New post on the ${blogName} blog` : 'New post on an OpenVibe blog')-- : k[0] === 'wiki' ? `Wiki: ${clean(p.space, 40)} / ${clean(p.slug, 60)}`++ // A wiki page by its title when the event carries one (contracts 0.366.0), else by where it lives.++ : k[0] === 'wiki' ? (clean(p.title, 160) || `Wiki: ${clean(p.space, 40)} / ${clean(p.slug, 60)}`): `News: ${clean(p.topic, 60) || 'a new story'}`;const actor = event.actor && event.actor.type === 'user' ? subjectOf(event.actor) : null;// An edited page moves to the top: the feed says "new and updated Wiki articles", not only first publications.@@@ -148,6 +148,11 @@ let SECRET, db, app, vipDrops, USR, seq, evt;const wikiRows = await db.prepare("SELECT * FROM pulse_items WHERE source_service = 'wiki' AND source_id = 'pg_3'").all();assert.strictEqual(wikiRows.length, 1, 'one row per page');assert.notStrictEqual(wikiRows[0].occurred_at, oldAt, 'an edit moves it up');++ // With a title (contracts 0.366.0) the item is named by it, not by where it lives.++ r = await post(evt({ event_type: 'wiki.page.published', source: 'wiki', subject: { type: 'page', id: 'pg_titled' },++ payload: { canonical_url: 'https://openvibe.wiki/w/help/titled', publication_state: 'published', visibility: 'public', space: 'help', slug: 'titled', title: 'How to go live from a phone', indexability: { decision: 'index', reasons: [] } } }));++ const titled = await db.prepare("SELECT title FROM pulse_items WHERE source_service = 'wiki' AND source_id = 'pg_titled'").get();++ assert.strictEqual(titled && titled.title, 'How to go live from a phone', JSON.stringify(r.json));assert.strictEqual(wikiRows[0].source_type, 'page');// Chat: a public room's fifth message in an hour becomes one summary card, refreshed only every five after that.
@@ -71,7 +71,8 @@ function itemFor(event) {
@@ -71,7 +71,8 @@ function itemFor(event) {
// blog.post.published names its blog as { id, handle } (contracts payload v1); a plain string is still read.
// blog.post.published names its blog as { id, handle } (contracts payload v1); a plain string is still read.
const blogName = clean(p.blog && typeof p.blog === 'object' ? p.blog.handle : p.blog, 60);
const blogName = clean(p.blog && typeof p.blog === 'object' ? p.blog.handle : p.blog, 60);
const title = k[0] === 'blog' ? (blogName ? `New post on the ${blogName} blog` : 'New post on an OpenVibe blog')
const title = k[0] === 'blog' ? (blogName ? `New post on the ${blogName} blog` : 'New post on an OpenVibe blog')
- : k[0] === 'wiki' ? `Wiki: ${clean(p.space, 40)} / ${clean(p.slug, 60)}`
+ // A wiki page by its title when the event carries one (contracts 0.366.0), else by where it lives.
+ : k[0] === 'wiki' ? (clean(p.title, 160) || `Wiki: ${clean(p.space, 40)} / ${clean(p.slug, 60)}`)
: `News: ${clean(p.topic, 60) || 'a new story'}`;
: `News: ${clean(p.topic, 60) || 'a new story'}`;
const actor = event.actor && event.actor.type === 'user' ? subjectOf(event.actor) : null;
const actor = event.actor && event.actor.type === 'user' ? subjectOf(event.actor) : null;
// An edited page moves to the top: the feed says "new and updated Wiki articles", not only first publications.
// An edited page moves to the top: the feed says "new and updated Wiki articles", not only first publications.
@@ -148,6 +148,11 @@ let SECRET, db, app, vipDrops, USR, seq, evt;
@@ -148,6 +148,11 @@ let SECRET, db, app, vipDrops, USR, seq, evt;
const wikiRows = await db.prepare("SELECT * FROM pulse_items WHERE source_service = 'wiki' AND source_id = 'pg_3'").all();
const wikiRows = await db.prepare("SELECT * FROM pulse_items WHERE source_service = 'wiki' AND source_id = 'pg_3'").all();
assert.strictEqual(wikiRows.length, 1, 'one row per page');
assert.strictEqual(wikiRows.length, 1, 'one row per page');
assert.notStrictEqual(wikiRows[0].occurred_at, oldAt, 'an edit moves it up');
assert.notStrictEqual(wikiRows[0].occurred_at, oldAt, 'an edit moves it up');
+ // With a title (contracts 0.366.0) the item is named by it, not by where it lives.
+ r = await post(evt({ event_type: 'wiki.page.published', source: 'wiki', subject: { type: 'page', id: 'pg_titled' },
+ payload: { canonical_url: 'https://openvibe.wiki/w/help/titled', publication_state: 'published', visibility: 'public', space: 'help', slug: 'titled', title: 'How to go live from a phone', indexability: { decision: 'index', reasons: [] } } }));
+ const titled = await db.prepare("SELECT title FROM pulse_items WHERE source_service = 'wiki' AND source_id = 'pg_titled'").get();
+ assert.strictEqual(titled && titled.title, 'How to go live from a phone', JSON.stringify(r.json));
assert.strictEqual(wikiRows[0].source_type, 'page');
assert.strictEqual(wikiRows[0].source_type, 'page');
// Chat: a public room's fifth message in an hour becomes one summary card, refreshed only every five after that.
// Chat: a public room's fifth message in an hour becomes one summary card, refreshed only every five after that.