aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-02-18 23:25:49 -0500
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-02-18 23:25:49 -0500
commitb1e230d4b884ddea8cb20893b9e16f7b3a881336 (patch)
tree31e7c6c22e42fc4ff92e8830adc58d7e6ab278b5
parentdcd0a2ae1f87f95016e1dbab1c6b0a72fc6bcabc (diff)
downloadpatchfoo-b1e230d4b884ddea8cb20893b9e16f7b3a881336.tar.gz
patchfoo-b1e230d4b884ddea8cb20893b9e16f7b3a881336.zip
Give options in paginator for limit
-rw-r--r--lib/serve.js41
-rw-r--r--static/styles.css4
2 files changed, 26 insertions, 19 deletions
diff --git a/lib/serve.js b/lib/serve.js
index 5f5a97e..8e563fb 100644
--- a/lib/serve.js
+++ b/lib/serve.js
@@ -530,58 +530,69 @@ function mergeOpts(a, b) {
}
Serve.prototype.renderThreadPaginated = function (opts, feedId, q) {
- function link(opts, name, cb) {
- cb(null, h('tr', h('td.paginate', {colspan: 2},
- h('a', {href: '?' + qs.stringify(mergeOpts(q, opts))}, name))))
+ var self = this
+ function linkA(opts, name) {
+ var q1 = mergeOpts(q, opts)
+ return h('a', {href: '?' + qs.stringify(q1)}, name || q1.limit)
+ }
+ function links(opts) {
+ var limit = opts.limit || q.limit || 10
+ return h('tr', h('td.paginate', {colspan: 2},
+ opts.forwards ? '↑ newer ' : '↓ older ',
+ linkA(mergeOpts(opts, {limit: 1})), ' ',
+ linkA(mergeOpts(opts, {limit: 10})), ' ',
+ linkA(mergeOpts(opts, {limit: 100}))
+ ))
}
+
return pull(
paginate(
function onFirst(msg, cb) {
var num = feedId ? msg.value.sequence : msg.timestamp || msg.ts
if (q.forwards) {
- link({
+ cb(null, links({
lt: num,
gt: null,
forwards: null,
- }, '↓ older', cb)
+ }))
} else {
- link({
+ cb(null, links({
lt: null,
gt: num,
forwards: 1,
- }, '↑ newer', cb)
+ }))
}
},
this.app.render.renderFeeds(),
function onLast(msg, cb) {
var num = feedId ? msg.value.sequence : msg.timestamp || msg.ts
if (q.forwards) {
- link({
+ cb(null, links({
lt: null,
gt: num,
forwards: 1,
- }, '↑ newer', cb)
+ }))
} else {
- link({
+ cb(null, links({
lt: num,
gt: null,
forwards: null,
- }, '↓ older', cb)
+ }))
}
},
function onEmpty(cb) {
if (q.forwards) {
- link({
+ cb(null, links({
gt: null,
lt: opts.gt + 1,
forwards: null,
- }, '↓ older', cb)
+ }))
} else {
- link({
+ cb(null, links({
gt: opts.lt - 1,
lt: null,
forwards: 1,
- }, '↑ newer', cb)
+ }))
}
}
),
diff --git a/static/styles.css b/static/styles.css
index d27ca0a..ccda4cb 100644
--- a/static/styles.css
+++ b/static/styles.css
@@ -36,10 +36,6 @@ img.ssb-emoji {
width: 24ex;
}
-.paginate {
- padding-left: 1ex;
-}
-
footer {
font-size: smaller;
text-align: center;