jetforce
jetforce copied to clipboard
charset CP437 for ANSI art
The diohsc is a client that has ANSI support, but I am not aware of a server that serves ANSI art correctly.
https://mbays.sdf.org/diohsc/
For example: https://16colo.rs/pack/blocktronics-dsotb/ndh-johnny.ans
If you serve this ans file via jetforce the header that is returned is 20 text/plain; charset=utf-8
Due to this, the art is not displayed correctly. It should return charset=CP437
I haven't tested it, but Molly Brown could probably support this using a .molly
file with the MimeOverrides
section. https://tildegit.org/solderpunk/molly-brown
Unfortunately, the standard mime.types
file that jetforce uses for detecting file types doesn't work with custom charsets. If you don't mind getting your hands dirty with python, it would only take a couple of lines to extend the jetforce server to do this.
#!/usr/local/env python3
from jetforce import GeminiServer, StaticDirectoryApplication
class CustomApplication(StaticDirectoryApplication):
def guess_mimetype(self, filename):
if filename.endswith(".asc"):
return "text/plain; charset=CP437"
else:
return super().guess_mimetype(filename)
app = StaticDirectoryApplication("/var/gemini")
if __name__ == "__main__":
# Add the rest of your command-line arguments here
server = GeminiServer(app, host="127.0.0.1", hostname="localhost", ...)
server.run()
Thanks for the guidance, will test your suggestion next week. Would you accept a pull request to natively have this logic?
In regards to molly-brown, it's not supported yet: https://tildegit.org/solderpunk/molly-brown/issues/19
Thanks for the guidance, will test your suggestion next week. Would you accept a pull request to natively have this logic?
Thanks for asking ahead of time, I probably wouldn't accept a PR for this. The built-in static file server is intentionally zero-config with pretty limited options to keep things simple. I have been pushing for "configuration as code" type examples like the one above as the preferred way to implement advanced behavior like redirects and virtual hosts. I think custom charsets fall into the same bucket.
- https://github.com/michael-lazar/jetforce/blob/master/examples/redirect.py
- https://github.com/michael-lazar/jetforce/blob/master/examples/vhost.py
That being said, I would definitely accept PRs to add scripts to the example directory or improve the documentation 😄
ANSI support would be really nice. There's a big BBS community (I'm 1:102/127) and would love to have this support from folks that visit my Gemini services from that realm. diohsc looks nice too, btw, and I'm wondering about implementing something like that as a door or something.
I remember well over a year ago when the first ANSI art image was served in Gemini space (Can't remember what server, or the client I used), and it was a thrill to get an 'almost' discernable image.
So there's ANSI support now?
@tallship Nothing has changed from the previous discussion. If you want to use a custom charset based on the file extension, you need to set it up in python as outlined above.
Edit: I changed the status to "Not Planned", if that was the source of the confusion.