aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-05-26 11:39:28 -1000
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-05-31 16:08:59 -1000
commit32a86d6e8bf6ffedf4c7dd37e49f58cf07a95e80 (patch)
tree74648045a4f0b5f609cedec71641f727f9d34bac
parent95a25a44b6a1b9f4124030a0c4ec658f63f3e307 (diff)
downloadpatchfoo-32a86d6e8bf6ffedf4c7dd37e49f58cf07a95e80.tar.gz
patchfoo-32a86d6e8bf6ffedf4c7dd37e49f58cf07a95e80.zip
Add link to show markdown source
-rw-r--r--lib/render-msg.js18
-rw-r--r--lib/serve.js7
2 files changed, 23 insertions, 2 deletions
diff --git a/lib/render-msg.js b/lib/render-msg.js
index 0c53894..48a5777 100644
--- a/lib/render-msg.js
+++ b/lib/render-msg.js
@@ -147,7 +147,11 @@ RenderMsg.prototype.actions = function () {
h('a', {href: '?gt=' + this.msg.timestamp}, '↓'), ' '] : '',
this.c.type === 'gathering' ? [
h('a', {href: this.render.toUrl('/about/' + encodeURIComponent(this.msg.key))}, 'about'), ' '] : '',
- h('a', {href: this.toUrl(this.msg.key) + '?raw'}, 'raw'), ' ',
+ typeof this.c.text === 'string' ? [
+ h('a', {href: this.toUrl(this.msg.key) + '?raw=md',
+ title: 'view markdown source'}, 'md'), ' '] : '',
+ h('a', {href: this.toUrl(this.msg.key) + '?raw',
+ title: 'view raw message'}, 'raw'), ' ',
this.buttonsCommon(),
this.c.type === 'gathering' ? [this.attendButton(), ' '] : '',
this.voteButton('dig')
@@ -246,9 +250,21 @@ RenderMsg.prototype.encrypted = function (cb) {
}
RenderMsg.prototype.markdown = function (cb) {
+ if (this.opts.markdownSource)
+ return this.markdownSource(this.c.text, this.c.mentions)
return this.render.markdown(this.c.text, this.c.mentions)
}
+RenderMsg.prototype.markdownSource = function (text, mentions) {
+ return h('div',
+ h('pre', String(text)),
+ mentions ? [
+ h('div', h('em', 'mentions:')),
+ this.valueTable(mentions, function () {})
+ ] : ''
+ ).innerHTML
+}
+
RenderMsg.prototype.post = function (cb) {
var self = this
var done = multicb({pluck: 1, spread: true})
diff --git a/lib/serve.js b/lib/serve.js
index 98a34e0..4481439 100644
--- a/lib/serve.js
+++ b/lib/serve.js
@@ -1079,8 +1079,13 @@ Serve.prototype.renderThreadPaginated = function (opts, feedId, q) {
}
Serve.prototype.renderRawMsgPage = function (id) {
+ var showMarkdownSource = (this.query.raw === 'md')
+ var raw = !showMarkdownSource
return pull(
- this.app.render.renderFeeds(true),
+ this.app.render.renderFeeds({
+ raw: raw,
+ markdownSource: showMarkdownSource
+ }),
pull.map(u.toHTML),
this.wrapMessages(),
this.wrapPage(id)