index.jsView |
---|
15 | 15 | renderEmoji, |
16 | 16 | formatMsgs, |
17 | 17 | wrapPage, |
18 | 18 | renderThread, |
19 | | - renderAbout |
| 19 | + renderAbout, |
| 20 | + renderShowAll |
20 | 21 | } = require('./render'); |
21 | 22 | |
22 | 23 | var appHash = hash([fs.readFileSync(__filename)]) |
23 | 24 | |
92 | 93 | |
93 | 94 | function serveFeed(req, res, feedId) { |
94 | 95 | console.log("serving feed: " + feedId) |
95 | 96 | |
96 | | - var showAll = req.url.endsWith("?showAll") |
97 | | - var showAllHTML = showAll ? '' : '<br/><a href="' + req.url + '?showAll">Show whole feed</a>' |
| 97 | + var showAll = req.url.endsWith("?showAll"); |
98 | 98 | |
99 | 99 | getAbout(feedId, function (err, about) { |
100 | 100 | if (err) return respond(res, 500, err.stack || err) |
101 | 101 | |
111 | 111 | paramap(addAuthorAbout, 8), |
112 | 112 | paramap(addFollowAbout, 8), |
113 | 113 | paramap(addVoteMessage, 8), |
114 | 114 | paramap(addGitLinks, 8), |
115 | | - pull(renderAbout(defaultOpts, about, showAllHTML), wrapPage(about.name)), |
| 115 | + pull(renderAbout(defaultOpts, about, |
| 116 | + renderShowAll(showAll, req.url)), |
| 117 | + wrapPage(about.name)), |
116 | 118 | toPull(res, function (err) { |
117 | 119 | if (err) console.error('[viewer]', err) |
118 | 120 | }) |
119 | 121 | ) |
195 | 197 | var channelId = url.substring(url.lastIndexOf('channel/')+8, 100) |
196 | 198 | console.log("serving channel: " + channelId) |
197 | 199 | |
198 | 200 | var showAll = req.url.endsWith("?showAll") |
199 | | - var showAllHTML = showAll ? '' : '<br/><a href="' + req.url + '?showAll">Show whole feed</a>' |
200 | 201 | |
201 | 202 | pull( |
202 | 203 | sbot.query.read({ limit: showAll ? 300 : 10, reverse: true, query: [{$filter: { value: { content: { channel: channelId }}}}]}), |
203 | 204 | pull.collect(function (err, logs) { |
208 | 209 | pull( |
209 | 210 | pull.values(logs), |
210 | 211 | paramap(addAuthorAbout, 8), |
211 | 212 | paramap(addVoteMessage, 8), |
212 | | - pull(renderThread(defaultOpts, showAllHTML), wrapPage('#' + channelId)), |
| 213 | + pull(renderThread(defaultOpts, |
| 214 | + renderShowAll(showAll, req.url)), |
| 215 | + wrapPage('#' + channelId)), |
213 | 216 | toPull(res, function (err) { |
214 | 217 | if (err) console.error('[viewer]', err) |
215 | 218 | }) |
216 | 219 | ) |