Open damascene opened 1 month ago
Thanks, I dont yet support .toml mime type, which are listed here:
https://github.com/nosdav/server/blob/gh-pages/index.js#L50
I'll try and fix this later today and redeploy the server
I looked at this a bit more, actually it's saving fine, its just the browser displays text like that without newlines
see:
https://nosdav.net/de7ecd1e2976a6adb2ffa5f4db81a7d812c8bb6698aa00dcf1e76adb55efd645/test.toml
But if you view browser source you get
Also try
curl https://nosdav.net/de7ecd1e2976a6adb2ffa5f4db81a7d812c8bb6698aa00dcf1e76adb55efd645/test.toml
# This is a TOML document
title = "TOML Example"
[owner]
name = "Tom Preston-Werner"
dob = 1979-05-27T07:32:00-08:00
[database]
enabled = true
ports = [ 8000, 8001, 8002 ]
data = [ ["delta", "phi"], [3.14] ]
temp_targets = { cpu = 79.5, case = 72.0 }
[servers]
[servers.alpha]
ip = "10.0.0.1"
role = "frontend"
[servers.beta]
ip = "10.0.0.2"
So this should be working
I've compared the source of the web pages between Nosdav and gitlab snippet and found that snippests and other services shows the plain content while Nosdav render it differently:
The content are inserted in html tags. Your test.toml file after saving from the webpage.
<html><head>
<meta http-equiv="content-type" content="text/html; charset=windows-1252"></head><body># This is a TOML document
title = "TOML Example"
[owner]
name = "Tom Preston-Werner"
dob = 1979-05-27T07:32:00-08:00
[database]
enabled = true
ports = [ 8000, 8001, 8002 ]
data = [ ["delta", "phi"], [3.14] ]
temp_targets = { cpu = 79.5, case = 72.0 }
[servers]
[servers.alpha]
ip = "10.0.0.1"
role = "frontend"
[servers.beta]
ip = "10.0.0.2"
role = "backend"</body></html>
the view source shows this:
Seems the website is using some type of rendering and not the raw content on the link.
Here is the same content in Gitlab snippet for compression https://gitlab.com/-/snippets/3708145/raw/main/TOML.toml
Also notice that content-type
is text/html
while in snippets it's text/plain; charset=utf-8
Good info, but it's fundamental to the design of nosdav that users own their own data, and that the system does not change it.
While gitlab understandably offers some quality of life enhancements for toml files (and .md) I dont think the core of nosdav should do that. I could be persuaded otherwise, but I am unsure right now that is a good thing to change.
There are other ways to do this, based on the architecture. Since NosDAV builds on REST, see: Layered System then it is possible to layer on some middleware to add something based on the mime type, if that system needs it.
Similarly a small script in a reverse proxy could insert some HTML tags. But I think the core of NosDAV should be to maintain the integrity of the data, which is a REST principle.
That said, a NAV for this use case could be developed if there is enough interest.
Does that make sense to you?
Also notice that
content-type
istext/html
while in snippets it'stext/plain; charset=utf-8
Yes, that could be fixed, do you know the correct mime type of .toml? My research shows me it is application/toml
but im not 100% sure. But this might trigger a download from the browser, which might even be a worse UX.
My research shows me it is
application/toml
but im not 100% sure.
True. https://toml.io/en/v0.5.0#mime-type
The link says "file" with download icon so I supposed that is what it should be doing, right?
Storing files using
paste.toml
as name and TOML content produces a link to file that displays non valid TOML file with all new lines removed. I've noticed similar issue with text format also. JSON files with.json
extension are displayed correctly.Original toml:
Result on the link:
However using the load button inside the editor can still retrieve a well formatted toml file. Issue seems is when you open the file link.
I've tested with json file and there was no issue.