# gopher-to-gemini
gopher-to-gemini is a reverse proxy
written in Go that allows you to serve
your Gemini capsule over Gopher as well.
## What is Gemini?
I've realised that if you're viewing
this page over Gopher you might not
know what Gemini is (yet). Gemini is a
protocol that's vaguely similar to
Gopher, but has TLS and a different
menu format. See the Gemini protocol's
page for more information:
(TXT) gopher://geminiprotocol.net/0/docs/faq.t
xt
The Gemini protocol is unrelated to
Google's "Gemini" AI and predates it.
## Try it out
This page is natively in Gemini and is
available on Gopher using the proxy,
click the link below to try it (if you
aren't already on Gopher).
(DIR) Try it
Gemtext documents get translated into
Gophertext on-the-fly. Assumptions are
made about file types based on their
extensions where possible to try and
make using it less painful, so it may
not be compatible with sites that do
their own thing. Emojis are removed
from the start of links because some
Gopher clients don't work properly with
UTF-8.
Here are some example links to
demonstrate its Gemtext conversion (if
you are connected with Gopher):
(PNG) PNG image
(IMG) JPG image
(TXT) Text document
(DIR) Input (no special configuration)
(QRY) Input (configured in
`GOPHER_PROXY_INPUT_PATH_REGEX`)
> This is an example of a blockquote in
> Gemtext. The quote is all on one
> line, but will be wrapped.
## Options
You can add the following prefixes to
URL paths to change the behaviour of
the Gemtext translation:
* `/_raw`: Returns the raw content,
does not translate into Gemtext. Any
other options are ignored.
* `/_wrap=<chars>`: Changes how many
characters text gets wrapped at,
useful for mobile devices.
* `/_encoding=<encoding>`: Output
encoding. Supports `utf-8` (default),
`latin-1`, and `ascii`.
(DIR) Example with _wrap=40
(TXT) View the source of this page
## Source code
(HTM) Git repository
## Usage
It is configured with environment
variables because I didn't feel like
doing anything nicer.
Example configuration:
GOPHER_PROXY_BIND_PROTO=tcp
GOPHER_PROXY_BIND_ADDR=:7070
GOPHER_PROXY_PUBLIC_ADDR=mysite.example.com:7070
GOPHER_PROXY_TARGET=gemini://mysite.example.com
There's also an optional
`GOPHER_PROXY_INPUT_PATH_REGEX`
variable, any links that match this
regex that would otherwise become menu
links (type `1`) get converted to input
links (type `7`) if they don't already
have a query string. Can be used to
skip showing a "Gemini server has
requested input" page. Example:
GOPHER_PROXY_INPUT_PATH_REGEX=^/search$
(DIR) Homepage