openvibers/openvibe.community Commits

Guide the community thread step (#371)

OP OpenVibers committed 2 days ago · 76ced0bbf8 · 2 files, +2 −1

Changes

ddiff --git a/server/render/forum.js b/server/render/forum.js
iindex 81c60f1..61f60aa 100644
---- a/server/render/forum.js
++++ b/server/render/forum.js
@@@ -360,7 +360,7 @@ function newThreadPage({ space, user, values = {}, error = null, categories = []
${labelsUi.picker({ current: values.labels || [], id: 'new-labels' })}
<label class="check"><input type="checkbox" name="members_only" value="1"${values.members_only ? ' checked' : ''}> Only my OpenVibe.VIP members can read and reply</label>
<div class="form-actions">
-- <button class="btn btn-primary" type="submit"><i class="fa-solid fa-paper-plane" aria-hidden="true"></i> Post thread</button>
++ <button class="btn btn-primary" type="submit" data-ov-guide="community.thread"><i class="fa-solid fa-paper-plane" aria-hidden="true"></i> Post thread</button>
<span class="muted small">Posting as <strong>${esc(user.display_name || user.username || 'you')}</strong>. By posting you agree to the <a href="/terms">rules</a>.</span>
</div>
</form>` : `<p class="alert"><a href="/auth/login?next=${encodeURIComponent(`/forum/${space.slug}/new`)}">Sign in with your OpenVibe account</a> to start a thread. Reading needs no account.</p>`;
ddiff --git a/test/forum-ssr.test.js b/test/forum-ssr.test.js
iindex d7727fa..8171114 100644
---- a/test/forum-ssr.test.js
++++ b/test/forum-ssr.test.js
@@@ -73,6 +73,7 @@ const form = (obj) => ({ method: 'POST', body: new URLSearchParams(obj).toString
const page = await t.get(target, as(alexJwt));
assert.strictEqual(page.status, 200);
++ has(page.text, 'data-ov-guide="community.thread"', 'the signed-in thread form has the guide target');
has(page.text, `value="${esc(title)}"`, 'the title is escaped in the form value');
has(page.text, `>${esc(body)}</textarea>`, 'the body is escaped in the textarea');
assert.ok(!page.text.includes('<script>alert("title")</script>') && !page.text.includes('<script>alert("body")</script>'), 'no raw draft HTML');