4.7 KiB
Kopher: a simple Gopher client/browser for KaiOS
Yo dawg, we put a browser in your browser, so you can browse Gopher while you browse KaiOS UI
What is it?
Kopher is a really small (under 500 SLOC of HTML+JS) client to browse pages ("holes") using Gopher protocol. Besides Gophermaps, it also allows to display plain text downloaded via this protocol "as is" and redirect to the system browser to view non-Gopher protocol links and download non-text media file types.
Structurally, Kopher is a KaiOS-specific frontend to the hi01379.js library which is developed under the same project. Both the library and the app are designed to be as lightweight as practically possible.
Which KaiOS versions are supported?
Tested on 2.5 up to 2.5.4. May work on 1.0 (e.g. Alcatel Cingular Flip 2), definitely won't work on 3.x.
Which Gophermap entry types are supported?
They are listed in the hi01379.js library name:
0(plain text)1(Gophermap)3(error message)7(search request)9(arbitrary binary type), as well asg(GIF image file)i(information message), as well asI(generic image file)h(external URL)
Outside this list, unknown binary types (5, s, ;, d) are just treated as type 9 internally, and every other type is assumed to be plain text on access.
In the Gophermap, any line that doesn't contain tabulation characters is automatically considered an information line by Kopher client and hi01379.js library. This allows to display messages from Gopher servers that don't strictly adhere to the format, such as Gophernicus or PyGopherd.
Note that currently, Kopher and hi01379.js assume that the search request from a 7-type entry will lead to another Gophermap and not to any other resource type. This was necessary to remove ambiguity, as the client doesn't heuristically determine the response type from its body.
Which UI features are supported?
- Minimalistic but easy and quick WAP-like navigation (see "Controls")
- The
gopher://scheme is assumed by default (no need to enter it manually), same for the port 70 - One-key light/dark theme toggle
- One-key switching the line wrapping mode between off (default) and on (for comfortable reading)
- Unlimited navigation history (doesn't persist between sessions)
- Up to 10 numbered bookmarks plus customizable homepage
Controls
Kopher's controls were inspired by old WAP browsers and partially Opera Mini. Once you get used to them, navigation becomes blazingly fast.
- Scrolling:
Up/Down/Left/Right - Previous/next link:
2/5 - Click on the link:
Center - Enter address: Left Soft Key
- Go back:
1or Right Soft Key - Go forward:
3 - Refresh:
Call - Page start/end:
8/0 - Line start/end:
7/9 - Open the homepage:
# * - Open a bookmark:
# [num] - Save to the homepage:
* * - Save to a bookmark:
* [num] - Toggle light/dark theme:
4 - Toggle line wrapping:
6 - Version and page info:
# # - Exit: End
Wait... no input fields in the UI?!
Exactly. No need to reinvent the wheel when the JS engine offers the prompt() method. You enter the starting address in the popup window, same way you enter search queries in the gopherholes.
For your convenience, only the current hole hostname is always displayed in the header bar, and the status bar with service messages or the current resource path is always displayed below. You can view the full URL/URI in the "Version and page info" popup accessed with # # combo.
Does it have Unicode support?
Yes. In fact, UTF-8 is the only supported encoding. As ASCII is a subset of UTF-8, old ASCII-only resources will be displayed just fine as well.
Does it have terminal emulation support for character coloring purposes?
No, but that feature is considered to be implemented if this client gains more traction and if there still is enough amount of the resources that actually use VT escape characters.
Can I use the hi01379.js library in non-KaiOS environments?
Yes, but you'll need to supply your own gopherRequest(resource, input, successCb, errorCb) function/method that performs the actual resource download over TCP. The success callback must always return a raw binary data string. See the js/transport.js file for the reference of how it's done for KaiOS (using mozTCPSocket API).
If you only need the Gophermap rendering functionality, you can provide a dummy function and only use the Hi01379.render() method. Note that the library generates links in its own internal and more efficient hi:[type]|[selector]|[host]|[port] URI format, where the fields are specified in the same order they appear in the Gophermap. It's up to the callers to convert these links to the standard gopher://[host]:[port]/[type][selector] URL scheme if they need to.
What's the license on this?
Fully public domain.