mirror of
https://github.com/sigoden/dufs.git
synced 2026-04-08 16:49:02 +03:00
[GH-ISSUE #458] Add a feature to serve any file as text/plain in the browser #249
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @tkapias on GitHub (Oct 1, 2024).
Original GitHub issue: https://github.com/sigoden/dufs/issues/458
Specific Demand
Can you add a button in the web interface, like the edit button, which would force to display any file as text/plain in a new browser tab?
https://dufs.example.com/path/file.ext?plain.Context
Before Dufs, I had too many file servers (seafile, privatebin, syncthing, kopia...). I got ride of seafile and I would like to replace privatebin's usage by dufs too.
The main issue is that sometime I would like to display some content in the browser with syntax highlighting.
For plain files, it 's pretty easy:
But, there are 2 issues:
text/*types, some of them where pushed for download. Even markdown's.mdwere like that.Apparently, Firefox's release 128 changed that: bugzilla-1319262, bugzilla-196078. But it will take some time to get this on Firefox ESR.
I tried to force mimetypes in nginx, but apparently Firefox ultimately parse the extension.
text/*mime types are considered as plain in Firefox, there are other filetypes that a user would like to view, and there are also other browsers with the same issue.Implement Suggestion
Not sure.
Maybe use js to serve the file with a fake extension and mimetype by appending
.plainto it?But testing binary files probably needs to be done server-side.
@tkapias commented on GitHub (Oct 1, 2024):
I just saw that you can get the editor to display the file content with
?view(without edition toolbar) and that it does check for binaries or large files.It's really close to what I requested.
New Suggestion
?plain.Differences with
?view:Open in a new tab.
Make
class="editor-page"the only element in the body.Maybe disable the editing feature for this view.
Add 2 new buttons for "View file" and "View plain file", near the "Edit file" in the index.
@sigoden commented on GitHub (Oct 2, 2024):
We will not support this feature. This demand is too niche.
To display the file in the browser with syntax highlighting, you should use browser extensions.
@tkapias commented on GitHub (Oct 2, 2024):
You were right not to work on it, after your message I found afew external solutions.
I just leave the comment for other users.
text/*content-types to those opening inline, but Firefox ESR will not get this feature for a long time.proxy_hide_headerandadd_header:Thanks for Dufs, it's a good tool.