====================================================================================================

WHAT IS GOPHER AND GOPHERSPACE?

    GOPHER is a network protocol that enables multiple servers
    to create a single, uniform filesystem that transcends system
    architecure and operating systems (GOPHERSPACE).  With GOPHER,
    information holds the most value.  Since presentation is uniform
    across GOPHERSPACE, the user does not encounter any challenges
    in 'learning' a new site.  Because of its simplicity and its
    emphasis on the importance of informational texts, GOPHER is
    ideal for those who are visually impared.

    A GOPHER client can be called from SDF by typing 'gopher'.  A URL
    (Uniform Resource Locator) can be given as an argument.  The client
    itself is a document examiner.  You can use it to search text documents
    or download files.  Clients under X11, Macintosh and other systems
    can view pictures, and stream audio / video.

    Many people think the http protocol has deprecated gopher, but that
    just isn't true.  Where do you think GOPHERs live?  underground.

    When you build your GOPHERSPACE on SDF, you are contributing to an
    underground network of systems that still believe in the gopher
    protocol.  There is no commercialism, no banner ads, no spam, no
    pop-up ads.  GOPHER gives you what you want: information and files
    (in any form) without the silliness of HTML and clumsiness of websites.
    No HTML development is needed to contribute to GOPHERSPACE.. since
    sites are uniform, all you need to do is upload or create your files.

HOW CAN I SETUP MY GOPHERSPACE?

    This document was written with 'mkgopher' in mind.  You may be
    managing your space from the UNIX shell, but since 'mkgopher'
    uses common UNIX commands, this should still be helpful.

    SETUP
    ----
    This will create the directory for the top level of your GOPHERSPACE.
    Your URL will be "gopher://sdf.org/1/users/username" (or
    "gopher://sdf-eu.org/1/users/username") where 'username' is your UNIX
    user id.  During your 'mkgopher' session, this directory will be
    present.  If you don't create anyfiles or directories, the space
    will be removed to keep our site clean.

    NOTE: Unfortunately, most web browsers do not render gopher pages
    properly, let alone grok Gopher URLs.

    TITLE
    -----
    Your GOPHER URL is gopher://sdf.org/1/users/login (or
    gopher://sdf-eu.org/1/users/login) where 'login' is the UNIX user id
    you use to login to SDF.  Your SITE name is your 'login'.  Since that
    is limited to 8 characters, you can use TITLE to set a 50 character
    or less title for your site.

    DESCRIBE
    --------
    For each directory you create in your GOPHERSPACE you can use the
    DESCRIBE command to create a detailed description.  This entry is
    limited to 9 lines of roughly 50 characters per line.

    MKDIR
    -----
    Create a subdirectory within your GOPHERSPACE.
RMDIR
    -----
    Remove a subdirectory within your GOPHERSPACE.

    PICO
    ----
    Edit and publish a document.  You can also use this as a way to
    cut and paste text from your computer terminal to SDF.  ASCII upload
    mode can also be used, just start sending text once you open the
    editing buffer.

    UPLOAD
    ------
    This should be used for large text files or binary data that cannot
    be transmitted via an ASCII transfer.  UPLOAD uses the ZMODEM file
    transfer protocol which some terminal emulators support (TeraTerm ..)



====================================================================================================

Source code of a menu

Gopher menu items are defined by lines of tab-separated values in a text file.
This file is sometimes called a gophermap. As the source code to a gopher menu,
a gophermap is roughly analogous to an HTML file for a web page. Each
tab-separated line (called a selector line) gives the client software a
description of the menu item: what it is, what it is called, and where it leads
to. The client displays the menu items in the order that they appear in the
gophermap.

The first character in a selector line indicates the item type, which tells the
client what kind of file or protocol the menu item points to. This helps the
client decide what to do with it. Gopher's item types are a more basic
precursor to the media type system used by the Web and email attachments.

The item type is followed by the user display string (a description or label
that represents the item in the menu); the selector (a path or other string for
the resource on the server); the hostname (the domain name or IP address of the
server), and the network port.

All lines in a gopher menu are terminated by "CR + LF".

Example of a selector line in a menu source: The following selector line
generates a link to the "/home" directory at the subdomain gopher.floodgap.com,
on port 70. The item type of 1 indicates that the linked resource is a Gopher
menu itself. The string "Floodgap Home" is what the client will show to the
user when visiting the example menu.

1Floodgap Home  /home   gopher.floodgap.com     70

Item type       User display string     Selector        Hostname                Port
1               Floodgap Home           /home           gopher.floodgap.com     70

Item types

In a Gopher menu's source code, a one-character code indicates what kind of
content the client should expect. This code may either be a digit or a letter
of the alphabet; letters are case-sensitive.

The technical specification for Gopher, RFC 1436, defines 14 item types. The
later gopher+ specification defined an additional 3 types.[24] A one-character
code indicates what kind of content the client should expect. Item type 3 is an
error code for exception handling. Gopher client authors improvised item types
h (HTML), i (informational message), and s (sound file) after the publication
of RFC 1436. Browsers like Netscape Navigator and early versions of Microsoft
Internet Explorer would prepend the item type code to the selector as described
in RFC 4266, so that the type of the gopher item could be determined by the url
itself. Most gopher browsers still available, use these prefixes in their urls.

----------------------------------------------------------------------------------------------------
Canonical types
----------------------------------------------------------------------------------------------------
0       Text file
1       Gopher submenu
2       CCSO Nameserver
3       Error code returned by a Gopher server to indicate failure
4       BinHex-encoded file (primarily for Macintosh computers)
5       DOS file
6       uuencoded file
7       Gopher full-text search
8       Telnet
9       Binary file
+       Mirror or alternate server (for load balancing or in case of primary server downtime)
g       GIF file
I       Image file
T       Telnet 3270
----------------------------------------------------------------------------------------------------
gopher+ types
----------------------------------------------------------------------------------------------------
:       Bitmap image
;       Movie file
<       Sound file
----------------------------------------------------------------------------------------------------
Non-canonical types
----------------------------------------------------------------------------------------------------
d       Doc. Seen used alongside PDF and .doc files
h       HTML file
i       Informational message, widely used.[25]
p       image file "(especially the PNG format)"
r       document RTF file ("Rich Text Format")
s       Sound file (especially the WAV format)
P       PDF (Portable Document Format) file
X       XML (Extensible Markup Language) file
----------------------------------------------------------------------------------------------------

Here is an example gopher session where the user requires a gopher menu (/Reference on the first line):

/Reference
1CIA World Factbook     /Archives/mirrors/textfiles.com/politics/CIA    gopher.quux.org 70
0Jargon 4.2.0   /Reference/Jargon 4.2.0 gopher.quux.org 70      +
1Online Libraries       /Reference/Online Libraries     gopher.quux.org 70     +
1RFCs: Internet Standards       /Computers/Standards and Specs/RFC      gopher.quux.org 70
1U.S. Gazetteer /Reference/U.S. Gazetteer       gopher.quux.org 70      +
iThis file contains information on United States        fake    (NULL)  0
icities, counties, and geographical areas.  It has      fake    (NULL)  0
ilatitude/longitude, population, land and water area,   fake    (NULL)  0
iand ZIP codes. fake    (NULL)  0
i       fake    (NULL)  0
iTo search for a city, enter the city's name.  To search        fake    (NULL) 0
ifor a county, use the name plus County -- for instance,        fake    (NULL) 0
iDallas County. fake    (NULL)  0

The gopher menu sent back from the server, is a sequence of lines each of which
describes an item that can be retrieved. Most clients will display these as
hypertext links, and so allow the user to navigate through gopherspace by
following the links.[5] This menu includes a text resource (itemtype 0 on the
third line), multiple links to submenus (itemtype 1, on the second line as well
as lines 4–6) and a non-standard information message (from line 7 on), broken
down to multiple lines by providing dummy values for selector, host and port.

External links

Historically, to create a link to a Web server, "GET /" was used as a
pseudo-selector to emulate an HTTP GET request.[26] John Goerzen created an
addition[27] to the Gopher protocol, commonly referred to as "URL links", that
allows links to any protocol that supports URLs. For example, to create a link
to http://gopher.quux.org/, the item type is h, the display string is the title
of the link, the item selector is "URL:http://gopher.quux.org/", and the domain
and port are that of the originating Gopher server (so that clients that do not
support URL links will query the server and receive an HTML redirection page).

Gopher+

Gopher+ is a forward compatible enhancement to the Gopher protocol. Gopher+
works by sending metadata between the client and the server. The enhancement
was never widely adopted by Gopher servers.[28][29][30] The client sends a tab
followed by a +. A Gopher+ server will respond with a status line followed by
the content the client requested. An item is marked as supporting Gopher+ in
the Gopher directory listing by a tab + after the port (this is the case of
some of the items in the example above).

Other features of Gopher+ include:

   Item attributes, which can include the items
       Administrator
       Last date of modification
       Different views of the file, like PostScript or plain text, or different languages
       Abstract, or description of the item
   Interactive queries

====================================================================================================

SZCZEŻUJA
----------------------------------------------------------------------------------------------------
Setting a Gopher hole
=====================

As the beginning of the 2021 came through as setting a Gemini capsule,
the  beginning of  the  2022 is  coming through  as  setting a  Gopher
hole. I've decided to sign up  for sdf.org account, because there is a
big gopher  community and I  didn't want to  stuck in as  some pioneer
somewhere  else. So  it should  be easy  thing to  set up  Gopher hole
there. No it wasn't so obvious.

My "setting" recipe
--------------------

The whole process of  setting up a Gopher hole is  easy, of course for
everyone who  had set  up earlier  one. There  aren't any  special and
complicated software, there are only text files and Unix-like system.

As a  model user  I started  from manual. I  visited [SDF  Gopher FAQ]
which can't be described as a very detailed source of knowledge. There
is  reference for  `mkgopher` internal  command, which  is helper  for
doing  so. So...  I tried  it.  It confused  me more,  than it  helped
me. After  a while, I  knew that I  must make everything  from command
line  on  my  own.  I  noticed  on  [SDF  Gopher  Tutorial]  two  more
helpers. There  is 'mkgopherentry'  script and `phlog`  command. First
one also confused me in creation of gophermap file (script's output is
a bit oddy).  The second one was  a bit mysterious, but  finally I got
its purpose (it's only a trigger for linking on [Gopher Club Phlogs]).

So as  I had written  before, it's better to  set your Gopher  hole on
your own. But there are hidden  traps, which aren't described in clear
way in FAQ or tutorial.

* You  need   a  symlink   from  your   home  directory:   `gopher  ->
 /ftp/pub/users/szczezuja`, which I made by 'mkgopher' command and by
 calling "SETUP" inside it;

* You  need some  content, for  example  textfile, which  you want  to
 publish on Gopher;

* You need to create a gophermap text file, which is pointing for that
 content;

* You need to  set up proper file permission in  your home directory -
 as  described on  [Slugmax SDF  Gopher Tutorial]:  `chmod o+r  file`
 (read for others)  and `chmod g+r file` (read for  group) and `chmod
 o+rx directory`;

As [Ruari @ 2022-01-11 23:41] told  me, the last point is specific for
sdf.org, and  it's caused by  default permissions on this  server. But
it's good  to know  about it,  because it is  showing a  simplicity of
Gopher servers.  There are no a  special layer of permissions,  if you
are  set  "read  for  everyone"  your  files  are  public.  In  modern
web-servers  era, we  sometimes believe  in some  kind of  magic which
would protect us. In the era of Gopher things were simpler.

Further thoughts
-----------------

It took me  a while to settled  gophermap topic in my  mind. The whole
idea  is also  simple, but  I was  spoiled by  `mkgopherentry` example
output.  In  the  most  cases  we  need only  a  little  of  the  full
gophermap. And  as I  understand, part  of the  rest isn't  a official
standard (so sometimes could be served in a different way in different
servers  and clients).  So as  it's described  in [Slugmax  SDF Gopher
Tutorial]:

``
 XSome text here<TAB>/path/to/content<TAB>example.org<TAB>N


Where  X  in  most  cases  is  0  -  for  text  files,  and  1  -  for
directories.  And that's  enough  for gophermap,  you  don't need  any
scripts for it.

For me the whole  idea of content and gophermap is  a bit fragile. One
mistaken character  or permission,  during the  first or  next uploads
could broke  our Gopher hole.  It could be hard  to test all  links. I
understand why many things in Gophersphere are broken.

But the most difficult part of  Gopher protocol for today's user could
be  lack  of UTF-8.  I  don't  think  about  emojis or  other  special
things. Rather  about letters  of non English  alphabet (like  "Z with
overdot"  in "Szczezuja")  or (which  was also  found in  my articles)
characters like double typographic quotes.

Finally
-------

So  I safely  landed  in  Gophersphere. You  can  read  my content  at
[Szczezuja's Gopher hole]. I plan  to publish there subset of articles
from Geminispace  (via [Formatting  Gemtext for Gopher]  script) about
Gopher. It's aim to be closer to Gophersphere user, which could be not
interested in Gemini.

It wasn't so easy,  but it's easy. For me easier was  to set up Gemini
capsule.

====================================================================================================

SlugMax
----------------------------------------------------------------------------------------------------
!Sample gophermap for Gophernicus

##
## This is a sample gophermap.
##
#
Creating a file called "gophermap" into a directory disables the
normal resource listing and replaces it with the contents of the map
file. You can also have inline gophermaps - files with a ".gophermap"
extension are parsed as gophermaps and displayed in between normal
resources in alphabetical order.

In a gophermap any line that doesn't contain a <TAB> character is
automatically converted to an type "i" gopher resource which are
displayed as plain text in the client. Lines which contain tabs are
intepreted as gopher resource lines which the client will render as
links. The first line of a gophermap should be a !Title line
describing the menu.

Dynamic gophermaps are possible by making the gophermap a script and
marking it as executable. All script output is parsed just like a
static gophermap, for example lines without tabs are converted to "i"
resources. Executable gophermaps are always ran through the default
shell (/bin/sh) so depending on your operating system that's either
slow, or really unbearably slow...

The format of a gophermap resource line is simple:
Xname<TAB>selector<TAB>host<TAB>port

Where:
  X          is the gopher filetype
  name       is an explanation of the resource
  selector   is the path to resource
  host:port  are the hostname and port number to go to

Type and name are mandatory. If you don't specify a selector, the
name field will be also used as the selector. If you don't specify
host or port the host:port of the current server are used instead.
Also make sure to use ONLY ONE TAB between the fields.

Valid filetypes include:
  0   text file
  1   directory
  3   error message
  5   archive file (zip, tar etc)
  7   search query
  8   telnet session
  9   binary file
  g   GIF image
  h   HTML file
  i   info text
  I   generic image file (other than GIF)
  d   document file (ps, pdf, doc etc)
  s   sound file
  ;   video file
  c   calendar file
  M   MIME file (mbox, emails etc)

Additional type characters supported by Gophernicus:
  #          comment - rest of the line is ignored
  !title     menu title (use on the first line)
  -file      hide the file from listings
  :ext=type  change filetype (for this directory only)
  ~          include a list of users with valid ~/public_gopher
  %          include a list of available virtual hosts
  =mapfile   include or execute other gophermap
  *          stop processing gophermap, include file listing
  .          stop processing gophermap (default)

Examples of valid resource lines:

1subdir
1Relative internal link subdir
1Absolute internal link /subdir
1External link  /       gopher.floodgap.com     70
1External relative link (which shouldn't work)  subdir/ gopher.domain.dom       70
0Finger-to-gopher link  kim     holviala.com    79
hLink to a website      URL:http://www.google.com/

hLink to a local html page      /path/to/file.html
5Link to an tar archive /path/to/archive.tar.gz
9Link to a binary file  /path/to/binary

7Search engine query    /query
8Telnet session kim     holviala.com    79

# Hide a few files from the menu listing generated by *
-hiddenfile.txt
-hiddendir

# Change filetypes for this directory
:png=g
:foo=b

Include links to users own gopherspaces:
~

List all available virtual hosts:
%

Include sub-gophermap:
=LICENSE

Execute script and parse output as subgophermap:
=/usr/bin/uptime

Here we stop processing the gophermap and include the regular menu:
*

====================================================================================================