aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/app.js1
-rw-r--r--lib/render-msg.js4
-rw-r--r--lib/render.js26
-rw-r--r--static/styles.css13
4 files changed, 42 insertions, 2 deletions
diff --git a/lib/app.js b/lib/app.js
index 7caab05..d0ff7f4 100644
--- a/lib/app.js
+++ b/lib/app.js
@@ -49,6 +49,7 @@ function App(sbot, config) {
|| new Buffer('HT0wIYuk3OWc2FtaCfHNnakV68jSGRrjRMP9Kos7IQc=', 'base64') // sha256('peer-invites')
this.devPeerInviteCap = new Buffer('pmr+IzM+4VAZgi5H5bOopXkwnzqrNussS7DtAJsfbf0=', 'base64') // sha256('peer-invites:DEVELOPMENT')
this.voteBranches = !!config.voteBranches
+ this.copyableIds = config.copyableIds == null ? true : config.copyableIds
this.hostname = (/:/.test(this.host) ? '[' + this.host + ']' : this.host) + this.port
this.dir = path.join(config.path, conf.dir || 'patchfoo')
diff --git a/lib/render-msg.js b/lib/render-msg.js
index 4b8c8c0..5411974 100644
--- a/lib/render-msg.js
+++ b/lib/render-msg.js
@@ -129,7 +129,7 @@ RenderMsg.prototype.wrap = function (content, cb) {
done()(null, [h('tr.msg-row',
h('td.msg-left',
h('div', this.render.avatarImage(this.msg.value.author, done())),
- h('div', this.render.idLink(this.msg.value.author, done())),
+ h('div', this.render.idLinkCopyable(this.msg.value.author, done())),
this.recpsLine(done())
),
h('td.msg-main',
@@ -167,7 +167,7 @@ RenderMsg.prototype.wrapMini = function (content, cb) {
var done = multicb({pluck: 1, spread: true})
done()(null, h('tr.msg-row',
h('td.msg-left',
- this.render.idLink(this.value.author, done()), ' ',
+ this.render.idLinkCopyable(this.value.author, done()), ' ',
this.recpsLine(done()),
channel ? [h('a', {href: this.toUrl(channel)}, channel), ' '] : ''),
h('td.msg-main',
diff --git a/lib/render.js b/lib/render.js
index e694396..df5d1c6 100644
--- a/lib/render.js
+++ b/lib/render.js
@@ -346,6 +346,32 @@ Render.prototype.idLink = function (link, cb) {
return a
}
+// %NM8tXGBBDKKcpRbbyd/5uN1p/2OtBMFDylLMDPGoq8Q=.sha256
+var idRegex = /^[A-Za-z0-9._\-+=/]*[A-Za-z0-9_\-+=/]$/
+
+Render.prototype.idLinkCopyable = function (link, cb) {
+ var self = this
+ if (!self.app.copyableIds) return idLink(link, cb)
+ if (!link) return cb(), ''
+ var a = h('a', ' ')
+ self.prepareLink(link, function (err, link) {
+ if (err) return cb(err)
+ a.href = self.toUrl(link.link)
+ var name = link.name || String(link.link).substr(1, 8) + '…'
+ if (idRegex.test(name)) a.childNodes[0].textContent = '@' + name
+ else {
+ a.className = 'id-copyable-link'
+ a.innerHTML = h('span', [
+ h('span.id-deemphasize', '['),
+ h('span.id-name', '@' + link.name),
+ h('span.id-deemphasize', '](', link.link, ')'),
+ ]).innerHTML
+ }
+ cb()
+ })
+ return a
+}
+
Render.prototype.privateLine = function (recps, isAuthorRecp, cb) {
var done = multicb({pluck: 1, spread: true})
var self = this
diff --git a/static/styles.css b/static/styles.css
index 9c64d48..e182ae5 100644
--- a/static/styles.css
+++ b/static/styles.css
@@ -120,6 +120,19 @@ pre {
font-size: smaller;
}
+.id-copyable-link {
+ text-decoration: none;
+}
+
+.id-deemphasize {
+ color: #67f;
+ font-size: smaller;
+}
+
+.id-name {
+ text-decoration: underline;
+}
+
.msg-header {
margin-bottom: .25ex;
}