aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-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
5 files changed, 20 insertions, 7 deletions
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
+}