git ssb

0+

Daan Patchwork / ssb-viewer



forked from cel / ssb-viewer

Commit e042fb79339f605bb9bea4d8d2e0c4db84d8ec89

Move show all html stuff to render

Anders Rune Jensen committed on 6/8/2017, 6:34:36 PM
Parent: c5cabd1c1390883a88e7ce23acc23075309f39bd

Files changed

index.jschanged
render.jschanged
index.jsView
@@ -15,9 +15,10 @@
1515 renderEmoji,
1616 formatMsgs,
1717 wrapPage,
1818 renderThread,
19- renderAbout
19+ renderAbout,
20+ renderShowAll
2021 } = require('./render');
2122
2223 var appHash = hash([fs.readFileSync(__filename)])
2324
@@ -92,10 +93,9 @@
9293
9394 function serveFeed(req, res, feedId) {
9495 console.log("serving feed: " + feedId)
9596
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");
9898
9999 getAbout(feedId, function (err, about) {
100100 if (err) return respond(res, 500, err.stack || err)
101101
@@ -111,9 +111,11 @@
111111 paramap(addAuthorAbout, 8),
112112 paramap(addFollowAbout, 8),
113113 paramap(addVoteMessage, 8),
114114 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)),
116118 toPull(res, function (err) {
117119 if (err) console.error('[viewer]', err)
118120 })
119121 )
@@ -195,9 +197,8 @@
195197 var channelId = url.substring(url.lastIndexOf('channel/')+8, 100)
196198 console.log("serving channel: " + channelId)
197199
198200 var showAll = req.url.endsWith("?showAll")
199- var showAllHTML = showAll ? '' : '<br/><a href="' + req.url + '?showAll">Show whole feed</a>'
200201
201202 pull(
202203 sbot.query.read({ limit: showAll ? 300 : 10, reverse: true, query: [{$filter: { value: { content: { channel: channelId }}}}]}),
203204 pull.collect(function (err, logs) {
@@ -208,9 +209,11 @@
208209 pull(
209210 pull.values(logs),
210211 paramap(addAuthorAbout, 8),
211212 paramap(addVoteMessage, 8),
212- pull(renderThread(defaultOpts, showAllHTML), wrapPage('#' + channelId)),
213+ pull(renderThread(defaultOpts,
214+ renderShowAll(showAll, req.url)),
215+ wrapPage('#' + channelId)),
213216 toPull(res, function (err) {
214217 if (err) console.error('[viewer]', err)
215218 })
216219 )
render.jsView
@@ -13,8 +13,9 @@
1313 exports.renderEmoji = renderEmoji;
1414 exports.formatMsgs = formatMsgs;
1515 exports.renderThread = renderThread;
1616 exports.renderAbout = renderAbout;
17+exports.renderShowAll = renderShowAll;
1718
1819 function MdRenderer(opts) {
1920 marked.Renderer.call(this, {});
2021 this.opts = opts;
@@ -444,4 +445,11 @@
444445
445446 function renderDefault(c) {
446447 return h('pre', JSON.stringify(c, 0, 2));
447448 }
449+
450+function renderShowAll(showAll, url) {
451+ if (showAll)
452+ return '';
453+ else
454+ return '<br>' + h('a', { href : url + '?showAll' }, 'Show whole feed').outerHTML;
455+}

Built with git-ssb-web