diff options
| author | Joe Mou <dev@mou.fo> | 2026-08-27 14:08:06 -0400 |
|---|---|---|
| committer | Joe Mou <dev@mou.fo> | 2026-08-27 14:53:38 -0400 |
| commit | 4797a627f461204b289f95f61b64e3dab8bc00ff (patch) | |
| tree | a044ef3d0419c95aad9fa98a093e0c39bdce5459 /views | |
| parent | 7c928d30b16b37624841c4615c0d4bda426e4159 (diff) | |
Display PDF blobs
GitHub renders a PDF with a viewer of its own and so ships no content for
one, leaving the blob view with nothing to show. Its raw bytes come as
application/octet-stream, which browsers download rather than display, so
serve them from a new embed route that retypes them and point an <object>
at that.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BErPR92xppzGFXkPqXPYj2
Diffstat (limited to 'views')
| -rw-r--r-- | views/blob.eta | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/views/blob.eta b/views/blob.eta index c7315f6..444508e 100644 --- a/views/blob.eta +++ b/views/blob.eta @@ -14,6 +14,11 @@ <% if (it.image) { %> <div class="box"><img src="/<%= it.repo.owner %>/<%= it.repo.name %>/raw/<%= it.branch %>/<%= it.path %>"></div> +<% } else if (it.renderFileType === "pdf") { %> + <object class="box pdf" type="application/pdf" + data="/<%= it.repo.owner %>/<%= it.repo.name %>/embed/<%= it.renderFileType %>/<%= it.branch %>/<%= it.path %>"> + This file cannot be displayed. + </object> <% } else if (it.htmlContent) { %> <div class="box"><%~ it.htmlContent %></div> <% } else if (it.htmlLines) { %> @@ -21,5 +26,5 @@ <% } else if (it.textLines) { %> <pre class="box"><code><%= it.textLines.join("\n") %></code></pre> <% } else { %> - <div class="box">This file cannot be displayed</div> + <div class="box">This file cannot be displayed.</div> <% } %> |
