kopher

A simple Gopher client for KaiOS
git clone git://git.luxferre.top/kopher.git
Log | Files | Refs | README | LICENSE

commit 53f9dc3a46af138fc2f302cf0bb6ee87de7a60ff
parent 69d974103749911cea63b63ca0cb93a83552e2c5
Author: Luxferre <lux@ferre>
Date:   Sun,  2 Apr 2023 23:00:47 +0300

Implemented URL sharing

Diffstat:
MREADME.md | 1+
Mjs/app.js | 22++++++++++++++++++++++
Mpages/help.txt | 1+
3 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/README.md b/README.md @@ -83,6 +83,7 @@ Kopher's controls were inspired by old WAP browsers and partially Opera Mini. On - Open a bookmark: `# [num]` - Save to the homepage: `* *` - Save to a bookmark: `* [num]` +- Share the URL: `* Call` - Toggle light/dark theme: `4` - Toggle line wrapping: `6` - Version and page info: `# #` diff --git a/js/app.js b/js/app.js @@ -15,6 +15,11 @@ function saveBlob(blob, fname, successCb, errorCb) { freeSpaceReq.onerror = errorCb } +function hi2gopher(hiurl) { + var parts = hiurl.split(':')[1].split('|') + return 'gopher://'+parts[2]+':'+parts[3]+'/'+parts[0]+parts[1] +} + function openURL(url, successCb, errorCb) { if(url.startsWith('about:')) { // handle about: pages first var pageName = url.split(':')[1], allowedPageNames = ['kopher', 'blank', 'help'] @@ -267,6 +272,23 @@ addEventListener('DOMContentLoaded', function() { if(currentUrl && confirm('Save current URL as the homepage?')) setBookmark(0, currentUrl) break + case '*Call': // share current URL as text in messages/email or via Bluetooth in vCard format + var hgoph = hi2gopher(currentUrl), htype = 'text/vcard', + btext = 'BEGIN:VCARD\r\nVERSION:2.1\r\nN:'+hgoph+'\r\nURL:'+hgoph+'\r\nEND:VCARD', + hblob = new Blob([btext], {type: htype}), + hname = hgoph.replace(/[\/:]+/g, '_') + '.vcf' + hblob.name = hname + new MozActivity({ + name: 'share', + data: { + type: 'url', + number: 1, + url: hgoph, + blobs: [hblob], + filenames: [hname] + } + }) + break case '#1': // load bookmark case '#2': case '#3': diff --git a/pages/help.txt b/pages/help.txt @@ -12,6 +12,7 @@ Kopher controls * Open bookmark: # [num] * Save to homepage: * * * Save bookmark: * [num] +* Share the URL: * Call * Toggle theme: 4 * Toggle line wrapping: 6 * Version+page info: # #