From 995c0fbf37398ddeafe6eddc7b61137090601b3a Mon Sep 17 00:00:00 2001 From: cel Date: Tue, 5 Jan 2021 07:46:12 -0500 Subject: Fix serving boxed blob with range request - Fix error handling - Calculate size of unboxed blob --- lib/serve.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/serve.js b/lib/serve.js index a06f566..a9a3691 100644 --- a/lib/serve.js +++ b/lib/serve.js @@ -2101,6 +2101,13 @@ Serve.prototype.blob = function (id, path) { if (/^invalid/.test(err.message)) return self.respond(400, err.message) else return self.respond(500, err.message || err) } + if (key) { + // Transform size of boxed blob to size of cleartext. + // Assume that the blob contains box-stream packets that are all full 4096-byte packets except maybe the last one, plus one goodbye packet + // boxedlen = origlen + ceil(origlen / 4096)*34 + 34 + const numBoxHeaders = Math.ceil((size - 34) / 4130) + 1 + size -= numBoxHeaders * 34 + } self.res.setHeader('Accept-Ranges', 'bytes') var range = self.req.headers.range if (range) { @@ -2120,7 +2127,7 @@ Serve.prototype.blob = function (id, path) { start = Number(start) last = Number(last) } - if (start > size || last >= size) return res.writeHead(416, 'Range not satisfiable') + if (start > size || last >= size) return self.respond(416, 'Range not satisfiable') var end = last + 1 var length = end - start var wroteHeaders = false -- cgit v1.2.3 From 44ee859ad60c38deae338671f4fc1b3f3d665ec9 Mon Sep 17 00:00:00 2001 From: cel Date: Thu, 14 Jan 2021 20:24:18 -0500 Subject: Truncate image alt text Reduce horizontal scrollbar --- lib/render.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/render.js b/lib/render.js index 91bd2ab..1777c88 100644 --- a/lib/render.js +++ b/lib/render.js @@ -41,6 +41,7 @@ MdRenderer.prototype.urltransform = function (href) { MdRenderer.prototype.image = function (ref, title, text) { if (ref[0] !== '&') return this.link(ref, title, text) var alt = this.render.getImageAlt(ref, text) + if (alt.length > 60) alt = alt.substr(0, 60) + '…' return (/^video:/.test(text) ? h('video', { controls: 'controls', src: this.render.toUrl(ref), -- cgit v1.2.3 From 283e57119d86f442bc6184ae26303b9cd1b9e0e8 Mon Sep 17 00:00:00 2001 From: cel Date: Sat, 16 Jan 2021 17:37:03 -0500 Subject: Render post titles %QzXfFomGeBhkM5cUB+YdPgl8AHceAXjmVr9omM30UuQ=.sha256 --- lib/render-msg.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/render-msg.js b/lib/render-msg.js index 3957694..e5846ac 100644 --- a/lib/render-msg.js +++ b/lib/render-msg.js @@ -479,6 +479,7 @@ RenderMsg.prototype.post = function (cb) { self.c.tags ? h('div', h('small', 'tags: ', u.toArray(self.c.tags).map(function (tag, i) { return [i > 0 ? ', ' : '', h('code', tag)] }))) : '', + self.c.title ? h('h4', u.toString(self.c.title)) : '', h('div.ssb-post-text', {innerHTML: self.markdown()}) ), cb) }) -- cgit v1.2.3