aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md1
-rw-r--r--lib/app.js1
-rw-r--r--lib/render-msg.js4
-rw-r--r--lib/render.js12
-rw-r--r--lib/serve.js6
-rw-r--r--lib/util.js4
-rw-r--r--static/styles.css2
7 files changed, 22 insertions, 8 deletions
diff --git a/README.md b/README.md
index 66e95cd..2aea4c7 100644
--- a/README.md
+++ b/README.md
@@ -94,6 +94,7 @@ To make config options persistent, set them in `~/.ssb/config`, e.g.:
- `previewVotes`: Whether to preview creating votes/likes/digs (`true`) or publish them immediately (`false`). default: `false`
- `previewContacts`: Whether to preview creating contact/(un)follow/block messages (`true`) or publish them immediately (`false`). default: `false`
- `ooo`: if true, use `ssb-ooo` to try to fetch missing messages in threads. also can set per-request with query string `?ooo=1`. default: `false`
+`codeInTextareas`: if `true`, render markdown code blocks in textareas. if `false`, render them in `pre` tags. default: `false`
## TODO
diff --git a/lib/app.js b/lib/app.js
index 9166eb2..4abd666 100644
--- a/lib/app.js
+++ b/lib/app.js
@@ -42,6 +42,7 @@ function App(sbot, config) {
img_base: conf.img_base || (base + 'image/'),
emoji_base: conf.emoji_base || (base + 'emoji/'),
encode_msgids: conf.encode_msgids == null ? true : Boolean(conf.encode_msgids),
+ codeInTextareas: conf.codeInTextareas,
}
sbot.get = memo({cache: lru(100)}, sbot.get)
diff --git a/lib/render-msg.js b/lib/render-msg.js
index 1603d24..cfc32c7 100644
--- a/lib/render-msg.js
+++ b/lib/render-msg.js
@@ -110,7 +110,7 @@ RenderMsg.prototype.wrap = function (content, cb) {
var channel = this.c.channel ? '#' + this.c.channel : ''
var done = multicb({pluck: 1, spread: true})
done()(null, [h('tr.msg-row',
- h('td.msg-left', {rowspan: 2},
+ h('td.msg-left',
h('div', this.render.avatarImage(this.msg.value.author, done())),
h('div', this.render.idLink(this.msg.value.author, done())),
this.recpsLine(done())
@@ -126,7 +126,7 @@ RenderMsg.prototype.wrap = function (content, cb) {
channel ? [' ', h('a', {href: this.toUrl(channel)}, channel)] : '')),
h('td.msg-right', this.actions())
), h('tr',
- h('td.msg-content', {colspan: 2},
+ h('td.msg-content', {colspan: 3},
this.issues(done()),
content)
)])
diff --git a/lib/render.js b/lib/render.js
index df4f112..bf61a43 100644
--- a/lib/render.js
+++ b/lib/render.js
@@ -62,6 +62,18 @@ MdRenderer.prototype.mention = function (preceding, id) {
}, id).outerHTML
}
+MdRenderer.prototype.code = function (code, lang, escaped) {
+ if (this.render.opts.codeInTextareas) {
+ return h('div', h('textarea', {
+ cols: 80,
+ rows: u.rows(code),
+ innerHTML: escaped ? code : u.escapeHTML(code)
+ })).outerHTML
+ } else {
+ return marked.Renderer.prototype.code.call(this, code, lang, escaped)
+ }
+}
+
function lexerRenderEmoji(emoji) {
var el = this.renderer.render.emoji(emoji)
return el && el.outerHTML || el
diff --git a/lib/serve.js b/lib/serve.js
index 8f7d1de..7e2fe3b 100644
--- a/lib/serve.js
+++ b/lib/serve.js
@@ -2939,10 +2939,6 @@ Serve.prototype.wrapMyChannels = function (opts) {
})
}
-function rows(str) {
- return String(str).split(/[^\n]{150}|\n/).length
-}
-
Serve.prototype.composer = function (opts, cb) {
var self = this
opts = opts || {}
@@ -3063,7 +3059,7 @@ Serve.prototype.composer = function (opts, cb) {
h('textarea', {
id: opts.id,
name: 'text',
- rows: Math.max(4, rows(data.text)),
+ rows: Math.max(4, u.rows(data.text)),
cols: 70,
placeholder: opts.placeholder || 'public message',
}, data.text || ''),
diff --git a/lib/util.js b/lib/util.js
index 7425513..15eb295 100644
--- a/lib/util.js
+++ b/lib/util.js
@@ -218,3 +218,7 @@ u.unescapeId = function (str) {
if (!m) return b64url.unescape(str)
return m[1] + b64url.unescape(m[2]) + m[3]
}
+
+u.rows = function (str) {
+ return String(str).split(/[^\n]{150}|\n/).length
+}
diff --git a/static/styles.css b/static/styles.css
index b22074f..7b22dcf 100644
--- a/static/styles.css
+++ b/static/styles.css
@@ -133,7 +133,7 @@ pre {
}
.msg-content {
- padding: 0 .5ex .5ex 0;
+ padding: 0 .5ex .5ex .5ex;
}
.composer-actions {