aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/serve.js36
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/serve.js b/lib/serve.js
index f104e3a..f850302 100644
--- a/lib/serve.js
+++ b/lib/serve.js
@@ -124,6 +124,7 @@ Serve.prototype.path = function (url) {
m = /^(\/?[^\/]*)(\/.*)?$/.exec(url)
switch (m[1]) {
case '/type': return this.type(m[2])
+ case '/links': return this.links(m[2])
case '/static': return this.static(m[2])
case '/emoji': return this.emoji(m[2])
}
@@ -236,6 +237,27 @@ Serve.prototype.type = function (path) {
)
}
+Serve.prototype.links = function (path) {
+ var q = this.query
+ var dest = path.substr(1)
+ var opts = {
+ dest: dest,
+ reverse: true,
+ values: true,
+ }
+
+ pull(
+ this.app.sbot.links(opts),
+ this.renderThread(opts, null, q),
+ this.wrapMessages(),
+ this.wrapLinks(dest),
+ this.wrapPage('links: ' + dest),
+ this.respondSink(200, {
+ 'Content-Type': ctype('html')
+ })
+ )
+}
+
Serve.prototype.vote = function (ext) {
var self = this
@@ -717,6 +739,20 @@ Serve.prototype.wrapType = function (type) {
})
}
+Serve.prototype.wrapLinks = function (dest) {
+ var self = this
+ return u.hyperwrap(function (thread, cb) {
+ cb(null, [
+ h('section',
+ h('h3.feed-name', 'links: ',
+ h('a', {href: self.app.render.toUrl('/links/' + dest)},
+ h('code', dest)))
+ ),
+ thread
+ ])
+ })
+}
+
function rows(str) {
return String(str).split(/[^\n]{70}|\n/).length
}