💾 Archived View for capsule.wetterberg.nu › 2021 › 2021-01-29-http-proxy.gmi captured on 2022-03-01 at 14:59:27. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2021-11-30)

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

HTTP Proxy for the smolnet ignorant 👋

Surprise, not everyone uses gemini! Sharing something with your friends is nice, but it's even better if they can read it. So I created a proxy that translates my gemini stuff to http/html.

This gemlog over HTTP

The code

One upside with this proxy is that it can be configured so that the http/gemini pages are completely symmetric. Swap out gemini:// for https:// and whatever you want to share is avaliable outside of the plaintext nerddom.

It also provides an option for following gemsub over HTTP & Atom, if a page contains gemsub links an Atom feed link will be added at the end.

The state of the thing

At the moment the proxy is dumb as dirt. It views all non-success statuses from gemini as errors (including redirects and input requests). Much of the markup generation is hardcoded, and it pretty much completely lacks any knobs to tweak except the ability to run under a different port when using plaintext HTTP. But it gets the job done for now.

Formatting test

gemini://example.com

Example link

Quote: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis suscipit mi purus, in auctor nulla posuere in. Morbi commodo tellus ex, non ultricies lectus tempus eu. Suspendisse aliquam nisl orci, vel consequat purus ornare sed. Vivamus semper lectus ut mi maximus, et cursus ligula tincidunt. Morbi tristique aliquet arcu vitae dictum.

Some code

title := getGeminiTitle(text)
if title == "" {
	title = req.Host
}

feedURL := req.URL.String() + ".gemsub.atom"

gp.render(w, "header", struct {
	Title   string
	FeedURL string
}{title, feedURL})