aboutsummaryrefslogtreecommitdiff
path: root/lib/serve.js
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2019-12-30 11:36:41 -0500
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2019-12-31 22:04:23 -0500
commit5be1b3cc78358abd45376b05e9d59fecb67402f8 (patch)
tree0b9f565c108ea70f592e64e7fb840ba6b158a9d8 /lib/serve.js
parentb729872005ad1fea03e7c96e496823c0784c75c1 (diff)
downloadpatchfoo-5be1b3cc78358abd45376b05e9d59fecb67402f8.tar.gz
patchfoo-5be1b3cc78358abd45376b05e9d59fecb67402f8.zip
Add printView and noThread query string options
- printView: no nav header, footer, action links, composer, or avatar. - noThread: show only the target message, no replies/mentions.
Diffstat (limited to 'lib/serve.js')
-rw-r--r--lib/serve.js19
1 files changed, 17 insertions, 2 deletions
diff --git a/lib/serve.js b/lib/serve.js
index 17f809c..034915c 100644
--- a/lib/serve.js
+++ b/lib/serve.js
@@ -394,6 +394,17 @@ Serve.prototype.handle = function () {
this.query = m[5] ? qs.parse(m[5]) : {}
this.useOoo = this.query.ooo != null ?
Boolean(this.query.ooo) : this.app.useOoo
+ if (this.query.printView != null) {
+ this.noNav = true
+ this.noFooter = true
+ this.noComposer = true
+ this.noActions = true
+ this.noAvatar = true
+ }
+ if (this.query.noThread != null) {
+ this.noThread = true
+ }
+
switch (m[2]) {
case '%25': m[2] = '%'; m[1] = decodeURIComponent(m[1])
case '%': return this.id(m[1], m[3])
@@ -1356,7 +1367,7 @@ Serve.prototype.streamThreadWithComposer = function (opts) {
var channel = opts.channel
pull(
- self.app.getThread(rootMsg),
+ self.noThread ? pull.once(rootMsg) : self.app.getThread(rootMsg),
pull.unique('key'),
self.app.unboxMessages(),
pull.through(function (msg) {
@@ -1777,6 +1788,7 @@ function styles() {
Serve.prototype.appendFooter = function () {
var self = this
return function (read) {
+ if (self.noFooter) return read
return cat([read, u.readNext(function (cb) {
var ms = new Date() - self.startDate
cb(null, pull.once(h('footer',
@@ -1805,6 +1817,7 @@ Serve.prototype.wrapPage = function (title, searchQ) {
h('link', {rel: 'stylesheet', href: render.toUrl('/highlight/foundation.css')})
),
h('body',
+ self.noNav ? '' :
h('nav.nav-bar', h('form', {action: render.toUrl('/search'), method: 'get'},
self.app.navLinks.map(function (link, i) {
return [i == 0 ? '' : ' ',
@@ -3397,6 +3410,7 @@ Serve.prototype.wrapThread = function (opts) {
return u.hyperwrap(function (thread, cb) {
self.app.render.prepareLinks(opts.recps, function (err, recps) {
if (err) return cb(er)
+ if (self.noComposer) return cb(null, thread)
self.composer({
placeholder: opts.placeholder
|| (recps ? 'private reply' : 'reply'),
@@ -3693,7 +3707,8 @@ Serve.prototype.composer = function (opts, cb) {
value: JSON.stringify(blobs)}),
h('input', {type: 'hidden', name: 'url', value: self.req.url}),
h('input', {type: 'hidden', name: 'composer_id', value: opts.id}),
- opts.recps ? self.app.render.privateLine(opts.recps, true, done()) :
+ opts.recps ? self.app.render.privateLine({recps: opts.recps,
+ isAuthorRecp: true}, done()) :
opts.private ? h('div', h('input.wide', {name: 'recps', size: 70,
value: data.recps || '', placeholder: 'recipient ids'})) : '',
channel != null ?