diff options
| -rw-r--r-- | assets/startpage.txt | 32 | ||||
| -rw-r--r-- | 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 @@ | |||
| 1 | >>>> Gopher/Gemini proxy <<<< | 1 | P R O X Y |
| 2 | - - - - - - for - - - - - - | ||
| 3 | GOPHER + GEMINI | ||
| 4 | |||
| 5 | |||
| 6 | GETTING STARTED -- | ||
| 7 | |||
| 8 | Just click on startpage:// in the top left corner and enter | ||
| 9 | a gopher:// or gemini:// URL you'd like to visit. | ||
| 10 | |||
| 11 | Here's a good starting point: gopher://gopher.floodgap.com/ | ||
| 12 | |||
| 13 | |||
| 14 | WHAT'S GOPHER? -- | ||
| 15 | |||
| 16 | Gopher is an internet protocol that was developed in 1991. | ||
| 17 | It's a very simple protocol that, unlike the World Wide | ||
| 18 | Web, is very text-focused and doesn't support technologies | ||
| 19 | like CSS, JavaScript or even cookies. | ||
| 20 | |||
| 21 | -> Read more: gopher://gopher.floodgap.com/0/gopher/welcome | ||
| 22 | |||
| 23 | |||
| 24 | WHAT ABOUT GEMINI? -- | ||
| 25 | |||
| 26 | Gemini is a new internet protocol that is still in the | ||
| 27 | process of being developed. Its purpose is to be an | ||
| 28 | alternative to both Gopher and the WWW by being more | ||
| 29 | powerful than Gopher, but lighter than the WWW. | ||
| 30 | |||
| 31 | -> 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 | |||
| 96 | continue | 96 | continue |
| 97 | } | 97 | } |
| 98 | 98 | ||
| 99 | if strings.HasPrefix(x.Selector, "URL:") { | 99 | if strings.HasPrefix(x.Selector, "URL:") || strings.HasPrefix(x.Selector, "/URL:") { |
| 100 | tr.Link = template.URL(x.Selector[4:]) | 100 | link := strings.TrimPrefix(strings.TrimPrefix(x.Selector, "/"), "URL:") |
| 101 | } else if strings.HasPrefix(x.Selector, "/URL:") { | 101 | if strings.HasPrefix(link, "gemini://") { |
| 102 | tr.Link = template.URL(x.Selector[5:]) | 102 | link = fmt.Sprintf( |
| 103 | "/gemini/%s", | ||
| 104 | strings.TrimPrefix(link, "gemini://"), | ||
| 105 | ) | ||
| 106 | } else if strings.HasPrefix(link, "gopher://") { | ||
| 107 | link = fmt.Sprintf( | ||
| 108 | "/gopher/%s", | ||
| 109 | strings.TrimPrefix(link, "gopher://"), | ||
| 110 | ) | ||
| 111 | } | ||
| 112 | tr.Link = template.URL(link) | ||
| 103 | } else { | 113 | } else { |
| 104 | var hostport string | 114 | var hostport string |
| 105 | if x.Port == 70 { | 115 | if x.Port == 70 { |
