Commit 2ee923fecc38c7bee0a0f0520fae62c565d18e63
Show what people vote on inline
Anders Rune Jensen committed on 4/15/2017, 7:29:04 PMParent: dd5c82b06c5cfb2c717fd3b9a9598d789092587c
Files changed
index.js | changed |
index.js | ||
---|---|---|
@@ -127,8 +127,9 @@ | ||
127 | 127 … | pull( |
128 | 128 … | pull.values(logs), |
129 | 129 … | paramap(addAuthorAbout, 8), |
130 | 130 … | paramap(addFollowAbout, 8), |
131 … | + paramap(addVoteMessage, 8), | |
131 | 132 … | pull(renderThread(opts), wrapPage(feedId)), |
132 | 133 … | toPull(res, function (err) { |
133 | 134 … | if (err) console.error('[viewer]', err) |
134 | 135 … | }) |
@@ -181,9 +182,9 @@ | ||
181 | 182 … | sbot.createLogStream({ reverse: true, limit: 1000 }), |
182 | 183 … | pull.filter((msg) => { |
183 | 184 … | return !msg.value || msg.value.author in following |
184 | 185 … | }), |
185 | - pull.filter((msg) => { | |
186 … | + pull.filter((msg) => { // channel subscription | |
186 | 187 … | return !msg.value.content.subscribed |
187 | 188 … | }), |
188 | 189 … | pull.collect(function (err, logs) { |
189 | 190 … | if (err) return respond(res, 500, err.stack || err) |
@@ -193,8 +194,9 @@ | ||
193 | 194 … | pull( |
194 | 195 … | pull.values(logs), |
195 | 196 … | paramap(addAuthorAbout, 8), |
196 | 197 … | paramap(addFollowAbout, 8), |
198 … | + paramap(addVoteMessage, 8), | |
197 | 199 … | pull(renderThread(opts), wrapPage(feedId)), |
198 | 200 … | toPull(res, function (err) { |
199 | 201 … | if (err) console.error('[viewer]', err) |
200 | 202 … | }) |
@@ -222,23 +224,21 @@ | ||
222 | 224 … | renderer: new MdRenderer(opts) |
223 | 225 … | } |
224 | 226 … | |
225 | 227 … | pull( |
226 | - sbot.createLogStream({ reverse: true, limit: 10000 }), | |
228 … | + sbot.createLogStream({ reverse: true, limit: 2000 }), | |
227 | 229 … | pull.filter((msg) => { |
228 | 230 … | return !msg.value || msg.value.content.channel == channelId |
229 | 231 … | }), |
230 | - pull.filter((msg) => { | |
231 | - return !msg.value.content.subscribed | |
232 | - }), | |
233 | 232 … | pull.collect(function (err, logs) { |
234 | 233 … | if (err) return respond(res, 500, err.stack || err) |
235 | 234 … | res.writeHead(200, { |
236 | 235 … | 'Content-Type': ctype("html") |
237 | 236 … | }) |
238 | 237 … | pull( |
239 | 238 … | pull.values(logs), |
240 | 239 … | paramap(addAuthorAbout, 8), |
240 … | + paramap(addVoteMessage, 8), | |
241 | 241 … | pull(renderThread(opts), wrapPage(channelId)), |
242 | 242 … | toPull(res, function (err) { |
243 | 243 … | if (err) console.error('[viewer]', err) |
244 | 244 … | }) |
@@ -256,9 +256,20 @@ | ||
256 | 256 … | }) |
257 | 257 … | else |
258 | 258 … | cb(null, msg) |
259 | 259 … | } |
260 | - | |
260 … | + | |
261 … | + function addVoteMessage(msg, cb) { | |
262 … | + if (msg.value.content.type == 'vote') | |
263 … | + getMsg(msg.value.content.vote.link, function (err, linkedMsg) { | |
264 … | + if (err) return cb(err) | |
265 … | + msg.value.content.vote.linkedText = linkedMsg.value.content.text | |
266 … | + cb(null, msg) | |
267 … | + }) | |
268 … | + else | |
269 … | + cb(null, msg) | |
270 … | + } | |
271 … | + | |
261 | 272 … | function serveId(req, res, id, ext, query) { |
262 | 273 … | var q = query ? qs.parse(query) : {} |
263 | 274 … | var includeRoot = !('noroot' in q) |
264 | 275 … | var base = q.base || conf.base |
@@ -551,15 +562,21 @@ | ||
551 | 562 … | function render(opts, c) |
552 | 563 … | { |
553 | 564 … | if (c.type === 'post') |
554 | 565 … | return renderPost(opts, c) |
555 | - else if (c.type == 'vote' && c.vote.expression == 'Dig') | |
556 | - { | |
557 | - var channel = c.channel ? ' in #' + c.channel : '' | |
558 | - return ' dug ' + '<a href="/' + c.vote.link + '">this</a>' + channel | |
566 … | + else if (c.type == 'vote' && c.vote.expression == 'Dig') { | |
567 … | + var channel = c.channel ? ' in #' + c.channel : '' | |
568 … | + var linkedText = 'this' | |
569 … | + if (typeof c.vote.linkedText != 'undefined') | |
570 … | + linkedText = c.vote.linkedText.substring(0, 100) | |
571 … | + return ' dug ' + '<a href="/' + c.vote.link + '">' + linkedText + '</a>' + channel | |
559 | 572 … | } |
560 | - else if (c.type == 'vote') | |
561 | - return ' voted <a href="/' + c.vote.link + '">this</a>' | |
573 … | + else if (c.type == 'vote') { | |
574 … | + var linkedText = 'this' | |
575 … | + if (typeof c.vote.linkedText != 'undefined') | |
576 … | + linkedText = c.vote.linkedText.substring(0, 100) | |
577 … | + return ' voted <a href="/' + c.vote.link + '">' + linkedText + '</a>' | |
578 … | + } | |
562 | 579 … | else if (c.type == 'contact' && c.following) |
563 | 580 … | return ' followed <a href="/user/' + c.contact + '">' + c.contactAbout.name + "</a>" |
564 | 581 … | else if (typeof c == 'string') |
565 | 582 … | return ' wrote something private ' |
Built with git-ssb-web