aboutsummaryrefslogtreecommitdiff
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
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.
-rw-r--r--lib/render-msg.js9
-rw-r--r--lib/render.js6
-rw-r--r--lib/serve.js19
3 files changed, 28 insertions, 6 deletions
diff --git a/lib/render-msg.js b/lib/render-msg.js
index 63489ff..dfface0 100644
--- a/lib/render-msg.js
+++ b/lib/render-msg.js
@@ -128,6 +128,7 @@ RenderMsg.prototype.wrap = function (content, cb) {
var done = multicb({pluck: 1, spread: true})
done()(null, [h('tr.msg-row',
h('td.msg-left',
+ this.serve.noAvatar ? '' :
h('div', this.render.avatarImage(this.msg.value.author, done())),
h('div', this.render.idLinkCopyable(this.msg.value.author, done())),
this.recpsLine(done())
@@ -192,6 +193,7 @@ RenderMsg.prototype.wrapMini = function (content, cb) {
RenderMsg.prototype.actions = function (mini) {
var lastMove
var ooo = this.serve && this.serve.query.ooo
+ if (this.serve.noActions) return
return this.msg.key ?
h('form', {method: 'post', action: ''},
this.msg.rel ? [this.msg.rel, ' '] : '',
@@ -240,8 +242,11 @@ RenderMsg.prototype.recpsLine = function (cb) {
var recpsNotAuthor = recps.filter(function (link) {
return u.linkDest(link) !== author
})
- var isAuthorRecp = recpsNotAuthor.length < recps.length
- return this.render.privateLine(recpsNotAuthor, isAuthorRecp, cb)
+ return this.render.privateLine({
+ recps: recpsNotAuthor,
+ isAuthorRecp: recpsNotAuthor.length < recps.length,
+ noLockIcon: this.serve.noLockIcon
+ }, cb)
}
RenderMsg.prototype.recpsIds = function () {
diff --git a/lib/render.js b/lib/render.js
index df5d1c6..680ba39 100644
--- a/lib/render.js
+++ b/lib/render.js
@@ -372,11 +372,13 @@ Render.prototype.idLinkCopyable = function (link, cb) {
return a
}
-Render.prototype.privateLine = function (recps, isAuthorRecp, cb) {
+Render.prototype.privateLine = function (opts, cb) {
+ var recps = opts.recps
+ var isAuthorRecp = opts.isAuthorRecp
var done = multicb({pluck: 1, spread: true})
var self = this
var el = h('div.recps',
- self.lockIcon(),
+ opts.noLockIcon ? '' : self.lockIcon(),
!isAuthorRecp ? [
h('span', {title: 'Author is not a recipient'}, '[!]'), ' '
] : '',
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 ?