From e31abb560ad402ff7927d435b5fa395d255a8791 Mon Sep 17 00:00:00 2001 From: cel Date: Tue, 3 Mar 2020 14:57:43 -0500 Subject: printView: show message date on right --- lib/render-msg.js | 28 ++++++++++++++++------------ lib/serve.js | 1 + static/styles.css | 4 ++++ 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/lib/render-msg.js b/lib/render-msg.js index cc85190..d056bc4 100644 --- a/lib/render-msg.js +++ b/lib/render-msg.js @@ -24,6 +24,8 @@ function RenderMsg(render, app, msg, opts) { if (typeof opts === 'boolean') opts = {raw: opts} this.opts = opts || {} this.shouldWrap = this.opts.wrap !== false + var ts = this.value.timestamp + this.date = ts ? new Date(ts) : null } RenderMsg.prototype.getMsg = function (id, cb) { @@ -121,8 +123,6 @@ RenderMsg.prototype.raw = function (cb) { RenderMsg.prototype.wrap = function (content, cb) { if (!this.shouldWrap) return cb(null, content) - var ts = this.msg.value.timestamp - var date = ts ? new Date(ts) : null var self = this var channel = this.c.channel ? '#' + u.toString(this.c.channel) : '' var done = multicb({pluck: 1, spread: true}) @@ -135,10 +135,10 @@ RenderMsg.prototype.wrap = function (content, cb) { ), h('td.msg-main', h('div.msg-header', - date && !this.serve.noMsgTime ? [h('a.ssb-timestamp', { - title: date.toLocaleString(), + this.date && !this.serve.noMsgTime ? [h('a.ssb-timestamp', { + title: this.date.toLocaleString(), href: this.msg.key ? this.toUrl(this.msg.key) : undefined - }, htime(date)), ' '] : '', + }, htime(this.date)), ' '] : '', h('code', h('a.ssb-id', { href: this.toUrl(this.msg.key) + (this.hasFullLink && this.opts.full ? '?full' : '') @@ -163,8 +163,6 @@ RenderMsg.prototype.wrap = function (content, cb) { RenderMsg.prototype.wrapMini = function (content, cb) { if (!this.shouldWrap) return cb(null, content) - var ts = this.value.timestamp - var date = ts ? new Date(ts) : null var self = this var channel = this.c.channel ? '#' + this.c.channel : '' var done = multicb({pluck: 1, spread: true}) @@ -174,10 +172,10 @@ RenderMsg.prototype.wrapMini = function (content, cb) { this.recpsLine(done()), channel ? [h('a', {href: this.toUrl(channel)}, channel), ' '] : ''), h('td.msg-main', - date ? [h('a.ssb-timestamp', { - title: date.toLocaleString(), + this.date ? [h('a.ssb-timestamp', { + title: this.date.toLocaleString(), href: this.msg.key ? this.toUrl(this.msg.key) : undefined - }, htime(date)), ' '] : '', + }, htime(this.date)), ' '] : '', this.issues(done()), this.c.contentWarning ? [ h('details', [ @@ -193,7 +191,12 @@ 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 + var extra = [ + this.serve.msgDate ? [ + this.date.toISOString().substr(0, 10) + ] : '' + ] + if (this.serve.noActions) return extra return this.msg.key ? h('form', {method: 'post', action: ''}, this.msg.rel ? [this.msg.rel, ' '] : '', @@ -223,7 +226,8 @@ RenderMsg.prototype.actions = function (mini) { title: 'view raw message'}, 'raw'), ' ', this.buttonsCommon(), this.c.type === 'gathering' ? [this.attendButton(), ' '] : '', - this.voteButton('dig') + this.voteButton('dig'), + extra ) : [ this.msg.rel ? [this.msg.rel, ' '] : '' ] diff --git a/lib/serve.js b/lib/serve.js index 0fef358..653a1e0 100644 --- a/lib/serve.js +++ b/lib/serve.js @@ -402,6 +402,7 @@ Serve.prototype.handle = function () { this.noActions = true this.noAvatar = true this.noMsgTime = true + this.msgDate = true } if (this.query.noThread != null) { this.noThread = true diff --git a/static/styles.css b/static/styles.css index 3ffdddc..d168d21 100644 --- a/static/styles.css +++ b/static/styles.css @@ -162,6 +162,10 @@ pre { border-bottom: 0; } +.print-view .msg-main { + text-align: center; +} + .msg-content { padding: 0 .5ex .5ex .5ex; } -- cgit v1.2.3