Move show all html stuff to render
This commit is contained in:
@@ -16,7 +16,8 @@ var {
|
|||||||
formatMsgs,
|
formatMsgs,
|
||||||
wrapPage,
|
wrapPage,
|
||||||
renderThread,
|
renderThread,
|
||||||
renderAbout
|
renderAbout,
|
||||||
|
renderShowAll
|
||||||
} = require('./render');
|
} = require('./render');
|
||||||
|
|
||||||
var appHash = hash([fs.readFileSync(__filename)])
|
var appHash = hash([fs.readFileSync(__filename)])
|
||||||
@@ -93,8 +94,7 @@ exports.init = function (sbot, config) {
|
|||||||
function serveFeed(req, res, feedId) {
|
function serveFeed(req, res, feedId) {
|
||||||
console.log("serving feed: " + feedId)
|
console.log("serving feed: " + feedId)
|
||||||
|
|
||||||
var showAll = req.url.endsWith("?showAll")
|
var showAll = req.url.endsWith("?showAll");
|
||||||
var showAllHTML = showAll ? '' : '<br/><a href="' + req.url + '?showAll">Show whole feed</a>'
|
|
||||||
|
|
||||||
getAbout(feedId, function (err, about) {
|
getAbout(feedId, function (err, about) {
|
||||||
if (err) return respond(res, 500, err.stack || err)
|
if (err) return respond(res, 500, err.stack || err)
|
||||||
@@ -112,7 +112,9 @@ exports.init = function (sbot, config) {
|
|||||||
paramap(addFollowAbout, 8),
|
paramap(addFollowAbout, 8),
|
||||||
paramap(addVoteMessage, 8),
|
paramap(addVoteMessage, 8),
|
||||||
paramap(addGitLinks, 8),
|
paramap(addGitLinks, 8),
|
||||||
pull(renderAbout(defaultOpts, about, showAllHTML), wrapPage(about.name)),
|
pull(renderAbout(defaultOpts, about,
|
||||||
|
renderShowAll(showAll, req.url)),
|
||||||
|
wrapPage(about.name)),
|
||||||
toPull(res, function (err) {
|
toPull(res, function (err) {
|
||||||
if (err) console.error('[viewer]', err)
|
if (err) console.error('[viewer]', err)
|
||||||
})
|
})
|
||||||
@@ -196,7 +198,6 @@ exports.init = function (sbot, config) {
|
|||||||
console.log("serving channel: " + channelId)
|
console.log("serving channel: " + channelId)
|
||||||
|
|
||||||
var showAll = req.url.endsWith("?showAll")
|
var showAll = req.url.endsWith("?showAll")
|
||||||
var showAllHTML = showAll ? '' : '<br/><a href="' + req.url + '?showAll">Show whole feed</a>'
|
|
||||||
|
|
||||||
pull(
|
pull(
|
||||||
sbot.query.read({ limit: showAll ? 300 : 10, reverse: true, query: [{$filter: { value: { content: { channel: channelId }}}}]}),
|
sbot.query.read({ limit: showAll ? 300 : 10, reverse: true, query: [{$filter: { value: { content: { channel: channelId }}}}]}),
|
||||||
@@ -209,7 +210,9 @@ exports.init = function (sbot, config) {
|
|||||||
pull.values(logs),
|
pull.values(logs),
|
||||||
paramap(addAuthorAbout, 8),
|
paramap(addAuthorAbout, 8),
|
||||||
paramap(addVoteMessage, 8),
|
paramap(addVoteMessage, 8),
|
||||||
pull(renderThread(defaultOpts, showAllHTML), wrapPage('#' + channelId)),
|
pull(renderThread(defaultOpts,
|
||||||
|
renderShowAll(showAll, req.url)),
|
||||||
|
wrapPage('#' + channelId)),
|
||||||
toPull(res, function (err) {
|
toPull(res, function (err) {
|
||||||
if (err) console.error('[viewer]', err)
|
if (err) console.error('[viewer]', err)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ exports.renderEmoji = renderEmoji;
|
|||||||
exports.formatMsgs = formatMsgs;
|
exports.formatMsgs = formatMsgs;
|
||||||
exports.renderThread = renderThread;
|
exports.renderThread = renderThread;
|
||||||
exports.renderAbout = renderAbout;
|
exports.renderAbout = renderAbout;
|
||||||
|
exports.renderShowAll = renderShowAll;
|
||||||
|
|
||||||
function MdRenderer(opts) {
|
function MdRenderer(opts) {
|
||||||
marked.Renderer.call(this, {});
|
marked.Renderer.call(this, {});
|
||||||
@@ -445,3 +446,10 @@ function renderPost(opts, c) {
|
|||||||
function renderDefault(c) {
|
function renderDefault(c) {
|
||||||
return h('pre', JSON.stringify(c, 0, 2));
|
return h('pre', JSON.stringify(c, 0, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function renderShowAll(showAll, url) {
|
||||||
|
if (showAll)
|
||||||
|
return '';
|
||||||
|
else
|
||||||
|
return '<br>' + h('a', { href : url + '?showAll' }, 'Show whole feed').outerHTML;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user