aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/render.js11
-rw-r--r--lib/serve.js8
2 files changed, 13 insertions, 6 deletions
diff --git a/lib/render.js b/lib/render.js
index 7e8ffc9..09030db 100644
--- a/lib/render.js
+++ b/lib/render.js
@@ -403,11 +403,18 @@ Render.prototype.getName = function (id, cb) {
}
}
-Render.prototype.getNameLink = function (id, cb) {
+function truncate(str, len) {
+ str = String(str)
+ return str.length > len ? str.substr(0, len) + '...' : str
+}
+
+Render.prototype.getNameLink = function (id, opts, cb) {
+ if (!cb && typeof opts === 'function') cb = opts, opts = null
+ var length = opts && opts.length || Infinity
var self = this
self.getName(id, function (err, name) {
if (err) return cb(err)
- cb(null, h('a', {href: self.toUrl(id)}, name))
+ cb(null, h('a', {href: self.toUrl(id)}, truncate(name, length)))
})
}
diff --git a/lib/serve.js b/lib/serve.js
index f71e083..9224f28 100644
--- a/lib/serve.js
+++ b/lib/serve.js
@@ -1697,10 +1697,10 @@ Serve.prototype.wrapPage = function (title, searchQ) {
)
}
-Serve.prototype.phIdLink = function (id) {
+Serve.prototype.phIdLink = function (id, opts) {
return pull(
pull.once(id),
- this.renderIdsList()
+ this.renderIdsList(opts)
)
}
@@ -1734,11 +1734,11 @@ Serve.prototype.friends = function (path) {
)
}
-Serve.prototype.renderIdsList = function () {
+Serve.prototype.renderIdsList = function (opts) {
var self = this
return pull(
paramap(function (id, cb) {
- self.app.render.getNameLink(id, cb)
+ self.app.render.getNameLink(id, opts, cb)
}, 8),
pull.map(function (el) {
return [el, ' ']