From 4fdfe9af0f5f4c0680a8d4148a276cc300d6c041 Mon Sep 17 00:00:00 2001 From: Feuerfuchs Date: Sun, 17 Nov 2019 11:28:53 +0100 Subject: Created proper startpage, support gemini:// links in Gopher mode --- assets/startpage.txt | 32 +++++++++++++++++++++++++++++++- gopherproxy.go | 18 ++++++++++++++---- 2 files changed, 45 insertions(+), 5 deletions(-) diff --git a/assets/startpage.txt b/assets/startpage.txt index b411de6..a48212e 100644 --- a/assets/startpage.txt +++ b/assets/startpage.txt @@ -1 +1,31 @@ ->>>> Gopher/Gemini proxy <<<< + P R O X Y + - - - - - - for - - - - - - + GOPHER + GEMINI + + +GETTING STARTED -- + +Just click on startpage:// in the top left corner and enter +a gopher:// or gemini:// URL you'd like to visit. + +Here's a good starting point: gopher://gopher.floodgap.com/ + + +WHAT'S GOPHER? -- + +Gopher is an internet protocol that was developed in 1991. +It's a very simple protocol that, unlike the World Wide +Web, is very text-focused and doesn't support technologies +like CSS, JavaScript or even cookies. + +-> Read more: gopher://gopher.floodgap.com/0/gopher/welcome + + +WHAT ABOUT GEMINI? -- + +Gemini is a new internet protocol that is still in the +process of being developed. Its purpose is to be an +alternative to both Gopher and the WWW by being more +powerful than Gopher, but lighter than the WWW. + +-> Read more: gemini://gemini.circumlunar.space diff --git a/gopherproxy.go b/gopherproxy.go index a91e057..8c0bb89 100644 --- a/gopherproxy.go +++ b/gopherproxy.go @@ -96,10 +96,20 @@ func renderGopherDirectory(w http.ResponseWriter, tpl *template.Template, assetL continue } - if strings.HasPrefix(x.Selector, "URL:") { - tr.Link = template.URL(x.Selector[4:]) - } else if strings.HasPrefix(x.Selector, "/URL:") { - tr.Link = template.URL(x.Selector[5:]) + if strings.HasPrefix(x.Selector, "URL:") || strings.HasPrefix(x.Selector, "/URL:") { + link := strings.TrimPrefix(strings.TrimPrefix(x.Selector, "/"), "URL:") + if strings.HasPrefix(link, "gemini://") { + link = fmt.Sprintf( + "/gemini/%s", + strings.TrimPrefix(link, "gemini://"), + ) + } else if strings.HasPrefix(link, "gopher://") { + link = fmt.Sprintf( + "/gopher/%s", + strings.TrimPrefix(link, "gopher://"), + ) + } + tr.Link = template.URL(link) } else { var hostport string if x.Port == 70 { -- cgit v1.2.3-70-g09d2