v0.0.6
prepared the readme to v0.0.6
basic gopher:// url view activity handling
Yo dawg, we put a browser in your browser, so you can browse Gopher while you browse KaiOS UI
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.
Installation is as usual, via WebIDE. For GerdaOS, you can prepare the kopher.gpkg.zip
file as follows:
zip -9r --exclude=*.git* --exclude=*.DS_Store* --exclude=README.md ../application.zip .
cd ..
echo {\"version\": 1, \"manifestURL\": \"app://kopher.luxferre.top/manifest.webapp\"} > metadata.json
zip -9 kopher.gpkg.zip application.zip metadata.json
Tested on 2.5.x up to 2.5.4. Doesn't work on 1.0 (some bug with mozTCPSockets I'm not gonna investigate) and definitely won't work on 3.x.
More specifically, as of now, Kopher has been tested on the following devices and KaiOS versions (ordered from oldest to newest):
* install-via-FFBM trick; also, the system statusbar on the Doro is larger than usual, so the addressbar is a bit overlapped (doesn't hamper its readability)
** there is a bug with displaying Blob-type images on the sKai, so only the download option works correctly
N.B. If you want to debug Kopher to support KaiOS 1.0, make sure to replace the '\u{1f310}'
reference in js/app.js
with '\uD83C\uDF10'
surrogate pair first.
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 as g
(GIF image file)i
(information message), as well as I
(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. The 8-type entries are just converted to telnet://
URIs with no logic attached.
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.
gopher://
scheme is assumed by default (no need to enter it manually), same for the port 70Kopher's controls were inspired by old WAP browsers and partially Opera Mini. Once you get used to them, navigation becomes blazingly fast.
Up
/Down
/Left
/Right
2
/5
Center
1
or Right Soft Key3
Call
8
/0
7
/9
# *
# [num]
* *
* [num]
* Call
4
6
# #
For image files supported by KaiOS, Kopher prompts whether or not you want to just view or store them, and if you choose to store them, they are saved to your default gallery storage. All other types are downloaded directly to the root of your default storage (the storage you selected in KaiOS setttings as the default media location, be it internal or the SD card). Note that Kopher does not do any heuristics on how the downloads folder should be named, nor does it create any by itself. Different phones handle the download storage place differently and B2G doesn't have a specific designator for it, so just using the root is the safest and most cross-device way of saving the files.
Note that in most KaiOS phones the internal storage root isn't fully viewable with the stock file manager, so you might have to use MTP and/or third-party file managers like Explorer to see the files if this is the case with your device. For more consistent UX with downloads, please consider using an SD card as the default storage.
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.
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.
As of April 2023, Kopher implements a subset of ANSI terminal escape codes for text styling purposes with the following limitations:
All these limitations are intended to keep Kopher's codebase simple, and not likely to change in the foreseeable future.
It almost doesn't. But, whatever could be done without hacks, has been done since the version 0.0.6. First, you can share the current URL (in the gopher://
format) using Bluetooth/Messages/Email share menu (if you select Bluetooth or any other provider that requires blobs, it gets sent as a vCard 2.1 file with the N
and URL
fields set to the same value) by pressing *
and Call key. Second, Kopher itself registers a view
activity handler for every URL that starts with gopher:
. If you just updated Kopher to version 0.0.6, you need to reboot your phone for this feature to start working. In the current state of KaiOS, gopher:
URLs aren't picked up and translated into proper activities by the stock KaiOS browser or the window.open()
call, but any other application that sends URLs to the view
activity according to the spec should be able to open gopher://
URLs in Kopher.
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.
Fully public domain.