💾 Archived View for oppen.digital › memex › 20210905_2024 › index.gmi captured on 2021-12-17 at 13:26:06. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2021-12-03)

-=-=-=-=-=-=-

A bare-bones Mariner Protocol client written in Chipmunk Basic. I played with Chipmunk Basic back in the 90s when I had an Apple Performa 5200 (widely regarded as the worst Apple computer ever manufactured), I'm hoping the code below would still run fine on an old Mac and enable access to oppen.digital via the Mariner Protocol

More about Mariner Protocol on the Phaedra page

Chipmunk Basic Mariner Protocol screenshot

' A Mariner Protocol client written in Chipmunk Basic 3.6.7b6 for Mac OS X 
' ifelse appears broken in this version so there's some inelegant syntax
' Chipmunk Basic Language Reference: http://anoved.net/cbasdox/index.html
' Chipmunk Basic pocketManual https://en.wikibooks.org/wiki/Chipmunk_Basic_pocketManual
cls
print "Chipmunk BASIC Mercury Client"
print "Written by ÖLAB: oppen.digital"

' All arrays must be dimensioned before use...
dim history$(128)
historyIndex = 0

input "Enter address: "; initialAddress$

if initialAddress$ = "" then
    address$ = "mercury://oppen.digital"
else
    address$ = initialAddress$
endif

if (left$ (address$, 9 ) = "mercury://") then
    nav(address$)
else
print "Error: initial address must be a full mercury:// url: " + address$
endif

nav()

sub nav()
    cls
    extractHost$()
    print "Address: " + address$
    print "Host: " + host$
    print ""
    open "socket:" + host$,1963 for input as #1
    open "socket:" + host$,1963 for output as #2

    request$ = address$ + newline$
    print #2, request$;
    pushHistory()

    dim links$(128)
    links$(0) = ""
    linkCount = 1
    while
        input #1, line$ : if eof(1) then exit while

        if left$(line$, 2) = "=>" then         
            uri$ = mid$(line$, 3)
            uri$ = field$(uri$, 1) 

            handled = 0

            if left$(uri$, 10) = "mercury://" then
                links$(linkCount) = uri$;
                handled = 1
            endif

            if left$(uri$, 1) = "/" then
                links$(linkCount) = address$ + uri$;
                handled = 1
            endif

            if handled = 0 then
                links$(linkCount) = address$ + "/" + uri$
            endif
            
            print str$(linkCount) + " " + line$
            linkCount = linkCount + 1
        else 
            print line$
        endif  
    wend

    close #1
    close #2

    input "> "; command
    if command = -1 then: popHistory() else: address$ = links$(command)
    nav()
end sub

sub extractHost$()
    if left$(address$, 10) = "mercury://" then: host$ = field$(address$, 3, "/")
end sub

sub pushHistory()
    history$(historyIndex) = address$
    historyIndex = historyIndex + 1
end sub

sub popHistory()
    historyIndex = historyIndex - 2
    address$ = history$(historyIndex)
end sub