diff options
author | cel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519> | 2017-05-06 18:20:57 -1000 |
---|---|---|
committer | cel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519> | 2017-05-06 19:33:44 -1000 |
commit | d437d4de396b37033f03626660b510d7b32e7377 (patch) | |
tree | 6148c114c205583a25e4d69900e11ae02b4ab068 /lib | |
parent | e79a3cd5ed3aa4d4be1707927c4e2d647032349a (diff) | |
download | patchfoo-d437d4de396b37033f03626660b510d7b32e7377.tar.gz patchfoo-d437d4de396b37033f03626660b510d7b32e7377.zip |
Implement thread forking option
Diffstat (limited to 'lib')
-rw-r--r-- | lib/serve.js | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/lib/serve.js b/lib/serve.js index d9cbfe7..183c8c3 100644 --- a/lib/serve.js +++ b/lib/serve.js @@ -741,7 +741,9 @@ Serve.prototype.id = function (id, ext) { self.wrapThread({ recps: recps, root: threadRootId, - branches: id === threadRootId ? threadHeads(links, id) : id, + post: id, + branches: threadHeads(links, threadRootId), + postBranches: threadRootId !== id && threadHeads(links, id), channel: channel, }), self.wrapPage(id), @@ -1179,8 +1181,10 @@ Serve.prototype.wrapThread = function (opts) { placeholder: recps ? 'private reply' : 'reply', id: 'reply', root: opts.root, + post: opts.post, channel: opts.channel || '', branches: opts.branches, + postBranches: opts.postBranches, recps: recps, }, function (err, composer) { if (err) return cb(err) @@ -1360,6 +1364,12 @@ Serve.prototype.composer = function (opts, cb) { channel != null ? h('div', '#', h('input', {name: 'channel', placeholder: 'channel', value: channel})) : '', + opts.root !== opts.post ? h('div', + h('label', {for: 'fork_thread'}, + h('input', {id: 'fork_thread', type: 'checkbox', name: 'fork_thread', value: 'post', checked: data.fork_thread || undefined}), + ' fork thread' + ) + ) : '', h('textarea', { id: opts.id, name: 'text', @@ -1433,8 +1443,13 @@ Serve.prototype.composer = function (opts, cb) { } else { if (opts.recps) content.recps = opts.recps } - if (opts.root) content.root = opts.root - if (opts.branches) content.branch = u.fromArray(opts.branches) + if (data.fork_thread) { + content.root = opts.post || undefined + content.branch = u.fromArray(opts.postBranches) || undefined + } else { + content.root = opts.root || undefined + content.branch = u.fromArray(opts.branches) || undefined + } if (channel) content.channel = data.channel } var msg = { |