diff options
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | lib/app.js | 1 | ||||
-rw-r--r-- | lib/serve.js | 11 |
3 files changed, 10 insertions, 4 deletions
@@ -84,6 +84,7 @@ To make config options persistent, set them in `~/.ssb/config`, e.g.: "filter": "all", "showPrivates": true, "previewVotes": true, + "voteBranches": false, "ooo": true, "nav": [ "new", @@ -124,6 +125,7 @@ To make config options persistent, set them in `~/.ssb/config`, e.g.: - `showPrivates`: Whether or not to show private messages. Default is `true`. Overridden by `filter=all`. - `previewVotes`: Whether to preview creating votes/likes/digs (`true`) or publish them immediately (`false`). default: `false` - `previewContacts`: Whether to preview creating contact/(un)follow/block messages (`true`) or publish them immediately (`false`). default: `false` +- `voteBranches`: whether to publish vote messages with thread `branch` and `root` properties, and include `vote` messages in `branch` properties of a posts. default: `false`. - `ooo`: if true, use `ssb-ooo` to try to fetch missing messages in threads. also can set per-request with query string `?ooo=1`. default: `false` `codeInTextareas`: if `true`, render markdown code blocks in textareas. if `false`, render them in `pre` tags. default: `false` - `nav`: array of nav links. Each item may be a string, object or special value. Special values are `"searchbox"` and `"self"`, which are the search field box, and link to the current feed id's page, respectively. Any other string is interpretted to be a link to the page of that name prefixed with a forward slash. An object may have properties `name` and `url`, and that will be interpretted as a link with given name and URL (with `toUrl` conversions applied). default is the list in the readme above. @@ -53,6 +53,7 @@ function App(sbot, config) { || new Buffer('pmr+IzM+4VAZgi5H5bOopXkwnzqrNussS7DtAJsfbf0=', 'base64') // sha256('peer-invites:DEVELOPMENT') */ + this.voteBranches = !!config.voteBranches this.hostname = (/:/.test(this.host) ? '[' + this.host + ']' : this.host) + this.port this.dir = path.join(config.path, conf.dir || 'patchfoo') diff --git a/lib/serve.js b/lib/serve.js index d8be4fc..ed8b20d 100644 --- a/lib/serve.js +++ b/lib/serve.js @@ -1297,12 +1297,14 @@ Serve.prototype.channel = function (path) { ) } -function threadHeads(msgs, rootId) { +function threadHeads(msgs, rootId, opts) { + var includeVotes = opts && opts.includeVotes return sort.heads(msgs.filter(function (msg) { var c = msg.value && msg.value.content return (c && ( c.type === 'web-root' ? c.site === rootId : c.type === 'talenet-idea-comment_reply' ? c.ideaKey === rootId : + c.type === 'vote' ? includeVotes : c.root === rootId)) || msg.key === rootId })) @@ -1311,6 +1313,7 @@ function threadHeads(msgs, rootId) { Serve.prototype.streamThreadWithComposer = function (opts) { var self = this var id = opts.root + var threadHeadsOpts = {includeVotes: self.app.voteBranches} return ph('table', {class: 'ssb-msgs'}, u.readNext(next)) function next(cb) { self.getMsgDecryptedMaybeOoo(id, function (err, rootMsg) { @@ -1346,10 +1349,10 @@ Serve.prototype.streamThreadWithComposer = function (opts) { ) function gotLinks(err, links) { if (err) return cb(new Error(err.stack)) - var branches = threadHeads(links, threadRootId) + var branches = threadHeads(links, threadRootId, threadHeadsOpts) cb(null, pull( pull.values(sort(links)), - pull.map(function (link) { + self.app.voteBranches && pull.map(function (link) { var o = {} for (var k in link) o[k] = link[k] o.threadBranches = branches @@ -1366,7 +1369,7 @@ Serve.prototype.streamThreadWithComposer = function (opts) { root: threadRootId, post: id, branches: branches, - postBranches: threadRootId !== id && threadHeads(links, id), + postBranches: threadRootId !== id && threadHeads(links, id, threadHeadsOpts), placeholder: opts.placeholder, channel: channel, }) |