diff options
author | cel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519> | 2019-12-05 12:10:04 -1000 |
---|---|---|
committer | cel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519> | 2019-12-07 16:35:45 -1000 |
commit | d4dfcf4d602dcdaa977d616bcda2dd7a4b8a25c4 (patch) | |
tree | 08d9402646b38eaa3f33c2ab981b31a4141646fc | |
parent | 7bd18ab4e39dbd1bc8339eae0daf9166a07a5dfa (diff) | |
download | patchfoo-d4dfcf4d602dcdaa977d616bcda2dd7a4b8a25c4.tar.gz patchfoo-d4dfcf4d602dcdaa977d616bcda2dd7a4b8a25c4.zip |
Make "previous" link in raw mode preserve raw and ooo modes
-rw-r--r-- | lib/render-msg.js | 21 | ||||
-rw-r--r-- | lib/render.js | 4 | ||||
-rw-r--r-- | lib/serve.js | 5 |
3 files changed, 24 insertions, 6 deletions
diff --git a/lib/render-msg.js b/lib/render-msg.js index 0c8fbf2..9d3e0df 100644 --- a/lib/render-msg.js +++ b/lib/render-msg.js @@ -62,6 +62,18 @@ RenderMsg.prototype.raw = function (cb) { m.value.sequence = tok } + // link to previous (raw) + if (m.value.previous) { + var tok = u.token() + tokens[tok] = h('a', { + href: this.toUrl(m.value.previous) + + '?raw' + + (this.serve && this.serve.query.ooo ? '&ooo=1' : '') + }, '"' + m.value.previous + '"') + isTokenNotString[tok] = true + m.value.previous = tok + } + if (typeof m.value.content === 'object' && m.value.content != null) { var c = m.value.content = {} for (k in this.c) c[k] = this.c[k] @@ -176,6 +188,7 @@ RenderMsg.prototype.wrapMini = function (content, cb) { RenderMsg.prototype.actions = function (mini) { var lastMove + var ooo = this.serve && this.serve.query.ooo return this.msg.key ? h('form', {method: 'post', action: ''}, this.msg.rel ? [this.msg.rel, ' '] : '', @@ -199,9 +212,9 @@ RenderMsg.prototype.actions = function (mini) { h('a', {href: this.toUrl(this.msg.key) + '?full', title: 'view full game board'}, 'full'), ' '] : '', typeof this.c.text === 'string' ? [ - h('a', {href: this.toUrl(this.msg.key) + '?raw=md', + h('a', {href: this.toUrl(this.msg.key) + '?raw=md' + (ooo ? '&ooo=1' : ''), title: 'view markdown source'}, 'md'), ' '] : '', - h('a', {href: this.toUrl(this.msg.key) + '?raw', + h('a', {href: this.toUrl(this.msg.key) + '?raw' + (ooo ? '&ooo=1' : ''), title: 'view raw message'}, 'raw'), ' ', this.buttonsCommon(), this.c.type === 'gathering' ? [this.attendButton(), ' '] : '', @@ -481,7 +494,7 @@ RenderMsg.prototype.getMsgName = function (id, cb) { }) function gotMsg(err, msg) { if (err) return cb(err) - new RenderMsg(self.render, self.app, msg, {wrap: false}).title(cb) + new RenderMsg(self.render, self.app, msg, {wrap: false, serve: self.serve}).title(cb) } } @@ -1146,7 +1159,7 @@ RenderMsg.prototype.repost = function (cb) { }) function gotMsg(err, msg) { if (err) return cb(err) - var renderMsg = new RenderMsg(self.render, self.app, msg, {wrap: false}) + var renderMsg = new RenderMsg(self.render, self.app, msg, {wrap: false, serve: self.serve}) renderMsg.message(function (err, msgEl) { self.wrapMini(['reposted ', h('code.ssb-id', diff --git a/lib/render.js b/lib/render.js index fc2407e..1aec728 100644 --- a/lib/render.js +++ b/lib/render.js @@ -368,7 +368,7 @@ Render.prototype.msgIdLink = function (id, cb) { var a = h('a', {href: self.toUrl(id)}, id) self.app.getMsgDecrypted(id, function (err, msg) { if (err) return el.appendChild(u.renderError(err)), cb() - var renderMsg = new RenderMsg(self, self.app, msg, {wrap: false}) + var renderMsg = new RenderMsg(self, self.app, msg, {wrap: false, serve: self.serve}) renderMsg.title(function (err, title) { if (err) return el.appendChild(u.renderError(err)), cb() a.childNodes[0].textContent = title @@ -383,7 +383,7 @@ Render.prototype.phMsgLink = function (msg) { return u.readNext(function (cb) { self.app.unboxMsg(msg, function (err, msg) { if (err) return cb(err) - var renderMsg = new RenderMsg(self, self.app, msg, {wrap: false}) + var renderMsg = new RenderMsg(self, self.app, msg, {wrap: false, serve: self.serve}) renderMsg.title(function (err, title) { if (err) return cb(err) cb(null, ph('a', {href: self.toUrl(msg.key)}, u.escapeHTML(title))) diff --git a/lib/serve.js b/lib/serve.js index cd63905..759477d 100644 --- a/lib/serve.js +++ b/lib/serve.js @@ -716,6 +716,7 @@ Serve.prototype.live = function (ext) { ph('table', {class: 'ssb-msgs'}, pull( self.app.sbot.createLogStream(opts), self.app.render.renderFeeds({ + serve: self, withGt: true, filter: q.filter, }), @@ -1672,6 +1673,7 @@ Serve.prototype.renderThreadPaginated = function (opts, feedId, q) { feed: opts && opts.feed, msgId: opts && opts.msgId, filter: this.query.filter, + serve: this, limit: Number(this.query.limit) || 12, }), function onLast(msg, cb) { @@ -1724,6 +1726,7 @@ Serve.prototype.renderRawMsgPage = function (id) { raw: raw, msgId: id, filter: this.query.filter, + serve: this, markdownSource: showMarkdownSource }), pull.map(u.toHTML), @@ -3970,6 +3973,7 @@ Serve.prototype.composer = function (opts, cb) { raw: raw, dualMarkdown: self.query.dualMd != null ? self.query.dualMd : self.conf.dualMarkdownPreview, + serve: self, filter: self.query.filter, }), pull.drain(function (el) { @@ -4022,6 +4026,7 @@ Serve.prototype.phPreview = function (content, opts) { pull.once(msg), this.app.unboxMessages(), this.app.render.renderFeeds({ + serve: self, raw: opts.raw, filter: this.query.filter, }), |