diff options
author | cel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519> | 2017-02-03 16:17:20 -0800 |
---|---|---|
committer | cel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519> | 2017-02-04 12:34:43 -0800 |
commit | ac3d249d64c586e8e000b45b7ca96773b2de61af (patch) | |
tree | 4915a66c4ecf80cc138d0f13bc7e77ce572e9dee /lib | |
parent | 6aa4f24110c9aaaec2ef257bacb02f379032ae18 (diff) | |
download | patchfoo-ac3d249d64c586e8e000b45b7ca96773b2de61af.tar.gz patchfoo-ac3d249d64c586e8e000b45b7ca96773b2de61af.zip |
Add links view
Diffstat (limited to 'lib')
-rw-r--r-- | lib/serve.js | 36 |
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 } |