darcs repository web UI and hosting app. This is the main darcsden trunk, which also runs hub.darcs.net. (https://hub.darcs.net)
#143embedded svg images don't display
The svgs aren't showing at http://hub.darcs.net/pointfree/darcs-swag for some reason.
I found that when I change
(\(OK _) -> serveFileAs "text/plain" $ repoDir (view rOwner r) (view rName r) </> f)
to(\(OK _) -> serveFile $ repoDir (view rOwner r) (view rName r) </> f)
ingetBrowseRawFileR
the SVGs display as images in the README.md just fine because then darcsden is not trying to display them as text files (when I embed the image I link to the/raw-file
url). So then, naturally/raw-file
PDFs display as PDFs, not as text files.However, that's not really a solution yet in IMHO because when we want to view a
.md
file as/raw-file
we don't necessarily want to download it which is what would happen when we go for the latter method.One solution for display text files as text and binary files as their own filetype is to detect the character encoding of the file. If
Nothing
is detected, assume it is binary, if a character encoding is detected assume it istext/plain
.https://github.com/aelve/charsetdetect-ae/blob/master/example/Main.hs
Thoughts?
Hm, maybe http://hackage.haskell.org/package/magic-1.1 is more the thing for this. I will have to try it out.
The following patch will render binary files under
raw-file/
if they are recognized by the browser and download them otherwise. As I think about it, I think more and more this is a good behavior (we view files astext/plain
underbrowse/
...right?) So, PDFs will be displayed as PDFs and SVGs will be displayed as SVGs under `raw-file/'http://hub.darcs.net/pointfree/darcsden-ui/patch/445b4b8f496df2b3b3dc9a77041e938ab9b607c3
This fixes this issue because I was using
raw-file/
paths to display the SVG images.It would be nice to display unrecognized formats as
text/plain
if they are identified as plain text by magic (uses the same system as the unixfile
command). We may want to view the raw markdown of a.md
file...I have new patches to solve this problem in a more satisfactory way.
Displays
raw-file/
astext/plain
if MIME type begins withtext/
Markdown files will be rendered as markdown under
browse/
and viewed as text/plain underraw-file/
SVGs will be rendered when embedded or viewed asraw-file/
and viewed as code underbrowse/
http://hub.darcs.net/pointfree/darcsden-ui/patch/f1df518f487b405acca4a0b8fe1933131c0c8981
Also added
application/pdf
MIME type:http://hub.darcs.net/pointfree/darcsden-ui/patch/a6c0300b902cf0e87e5638e4f1bdade7067999cd
@simon, is this now WONTFIX?
No! Thanks for the bump. I am working on a new build now.
@pointfree, I have merged and deployed this, and see images at http://hub.darcs.net/pointfree/darcs-swag/browse/README.md (after shift-reloading), so I think it's working. Thanks!
(Unrelated: darcs hub's last darcsden build was in january, so we should now also have your username linkification in issues patch, but I don't see it working.)
- status set to closed
This works now.